Re: Use C++ in RT-Linux.
Roberto Guzman <[email protected]> Tue, 14 Feb 2006 08:35:38 +0100
| Newsgroups | gmane.linux.real-time.rtlinux.general |
|---|---|
| Message-ID | <[email protected]> |
Dear Vasin,
To use C++ in RTLinux modules, you need to:
-insert rtl_cpp.o support module.
-first modify rtl_cpp.c and include:
void __cxa_pure_virtual (void)
{
Rtl_printf(=93__cxa_pure_virtual called\n=94);
}
- #include rtl_cpp.h in your RT-program
- if you have statically allocated objects that
need initializing, call __do_global_ctors_aux() in init_module
and __do_global_dtors_aux() in cleanup_module (see hello.o)
- link your module with crtbegin.o and crtend.o; the
order is important (see Makefile example CPP)
- the rtl.mk file provides needed CXXFLAGS
-Add =96fno-use-cxa-atexit to CXXFLAGS in /usr/src/rtlinux=85/rtl.mk
all: app.o rtl_cpp.o
include /usr/src/rtlinux/rtl.mk
CRTBEGIN=3D`g++ -print-file-name=3Dcrtbegin.o`
CRTEND=3D`g++ -print-file-name=3Dcrtend.o`
app.o: rover.o
$(LD) -r -o app.o $(CRTBEGIN) rover.o $(CRTEND)
clean:
rm -f *.o
test: all
@echo "RESCUER RT_MODULE"
@echo "First we remove any existing rtl-modules"
@echo "You may see error warnings from \"make\" - ignore them"
@echo "Type <return> to continue"
@read junk
-rmmod rtl_cpp
(cd $(RTL_DIR); scripts/rmrtl)
@echo "Now start RTLINUX (script insrtl)"
@echo "Type <return> to continue"
@read junk
(cd $(RTL_DIR); scripts/insrtl)
@echo "Insert the C++ support module"
insmod rtl_cpp.o
@echo "Now start the real-time tasks module"
@echo "Type <return> to continue"
@read junk
@insmod app.o
@sleep 3
@echo "Now let's stop the application"
@echo "Type <return> to finish"
@read junk
@rmmod app
@rmmod rtlcpp
include $(RTL_DIR)/Rules.make
Best Regards,
Robert
--=20
Roberto Guzman
Robotnik Automation, SLL
Bern=ED y Catal=E1, 53 bajo izq.
46019 - Valencia
Tel y fax. (+34) 96 338 38 35
www.robotnik.es
Vasin Pichitsurakij escribi=F3:
> I try to run a hello.c (C language)that is an example program coming wi=
th
> rtlinux and everything work fine but I really want to use C++ instead o=
f
> C.
>
> I try to run a hello.cpp that is an example program for C++ that come w=
ith
> rtlinux. I can compile hello.cpp. after that I do this
>
> [root@ss-sw1 cpp]# insmod rtl_cpp.o
> [root@ss-sw1 cpp]# insmod app.o
> app.o: unresolved symbol __cxa_pure_virtual
> app.o: unresolved symbol __cxa_atexit
> app.o:
> Hint: You are trying to load a module without a GPL compatible license
> and it has unresolved symbols. Contact the module supplier for
> assistance, only they can help you.
>
> [root@ss-sw1 cpp]# insmod hello.o
> hello.o: unresolved symbol __cxa_pure_virtual
> hello.o: unresolved symbol __do_global_ctors_aux
> hello.o: unresolved symbol __cxa_atexit
> hello.o: unresolved symbol __dso_handle
> hello.o: unresolved symbol __do_global_dtors_aux
> hello.o:
> Hint: You are trying to load a module without a GPL compatible license
> and it has unresolved symbols. Contact the module supplier for
> assistance, only they can help you.
>
>
> How can I use C++ in RT-Linux.
> Thank you very much.
>
> _______________________________________________
> Rtl mailing list
> [email protected]
> http://hq.fsmlabs.com/mailman/listinfo/rtl
> http:/www.rtlinux-gpl.org/
>
>
> =20
_______________________________________________
Rtl mailing list
[email protected]
http://hq.fsmlabs.com/mailman/listinfo/rtl
http:/www.rtlinux-gpl.org/