Ivan Martinez wrote:
>
> Sure? It doesn't complain at all when compiling and linking, only when
> installing app.o.
The compiler doesn't care, it sees a prototype and assumes it is a C++
prototype so no problem there.
The linker does complain, just not on the place where you expected it, the
kernel module is basicaly dynamicaly linked with the kernel , so the last
linking is done when loading your module in the kernel, and there it does
complain.
> If I add:
>
> extern "C" int rtl_printf(const char * fmt, ...);
>
> at the begining of matrix.cpp then its compilation says:
>
> /usr/src/rtlinux-3.1/include/rtl_printf.h:4: previous declaration of `int
> rtl_printf (const char *,
> ...)' with C++ linkage
> matrix.cpp:4: conflicts with new declaration with C linkage
> make: *** [matrix.o] Error 1
You inlcuded the prototype already via the include file. wrap your include
file in a extern "C" and remove the extra prototype.
so at the top of your C++ source file add the rtl?printf.h include file (and
any other include file not written for C++) like this:
extern "C" {
#include <rtl_printf.h>
#include <c_header_file.h>
}
- Erwin
>
> So if rtl_printf is already declared with C++ linkage, why it can't find the
> C++ mangled name?. Why using extern "C"?.
> Thank you,
> Ivan Martinez
>
> On Tuesday 23 October 2001 17:27, Erwin Rol wrote:
> > rtl_printf__FPCce is a mangled C++ name for a function, you forgot
> > extern "C" at some place.
> >
> > - Erwin
> >
> > Ivan Martinez wrote:
> > > Hello all,
> > > I'm writing a simple realtime module to learn how to compile and
> > > use C++ code. I include the files that I'm using:
> > > - rtmatrix.h and rtmatrix.cpp will define the class that I want
> > > to handle, at the moment they just define the A and C classes of the cpp
> > > example. - rtmodule.cpp is a realtime module generated by the next
> > > release of DSLib, v1.3. It's generated from an empty dynamic system so it
> > > does nothing. - Makefile is a slight modification of cpp-example's
> > > makefile, which compiles rtmodule.cpp instead of hello.cpp and includes
> > > rtmatrix.o in linking. All this compiles fine, the problem is I get the
> > > following error when installing app.o:
> > >
> > > Now start the real-time tasks module
> > > Type <return> to continue
> > >
> > > app.o: unresolved symbol rtl_printf__FPCce
> > > make: *** [test] Error 1
> > >
> > > rtmatrix.cpp includes rtl_printf.h and is compiled the same way
> > > than rtmodule.cpp (which I can't understand as I said in my last
> > > posting). Do you know what the problem is?.
> > > Regards,
> > > Ivan Martinez
> > >
> > >
> > > -------------------------------------------------------------------------
> > >----- Name: rtmatrix.h
> > > rtmatrix.h Type: C Header file
> > > (application/x-unknown-content-type-hfile) Encoding: base64
> > >
> > > Name: rtmatrix.cpp
> > > rtmatrix.cpp Type: C++ Source file
> > > (application/x-unknown-content-type-cppfile) Encoding: base64
> > >
> > > Name: rtmodule.cpp
> > > rtmodule.cpp Type: C++ Source file
> > > (application/x-unknown-content-type-cppfile) Encoding: base64
> > >
> > > Name: Makefile
> > > Makefile Type: text/x-makefile
> > > Encoding: base64
> >
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/