C++ Usage Issues - Problems, Solutions, and Suggestions

Joel Sherrill joel.sherrill at oarcorp.com
Thu Jun 21 15:43:34 UTC 2007


Robert S. Grimes wrote:
> Ralf Corsepius wrote:
>   
>>>     LD_LIBS   += -lstdc++
>>>     
>>>       
>> No, using "<target>-gcc -lstdc++" is never correct. You have to use 
>> "<target>-g++" instead of "<target>-gcc" to link c++ code.
>>   
>>     
> Oops, I missed that - of course, I didn't know that I had.  I was about
> to ask, but then a bit of poking around led me to virtex.cfg, where
> there is a make-cxx-exe rule, which indeed fixes it correctly - Thanks Ralf!
>
> For others who may be in my "naive" camp, the rule in the Template
> makefile (make/Templates/Makefile.leaf) that links a C executable looks
> like this:
>
>     ${ARCH}/xxx-your-program-here: ${OBJS} ${LINK_FILES}
>         $(make-exe)
>
>
> For C++ applications, change it to this:
>
>     ${ARCH}/xxx-your-program-here: ${OBJS} ${LINK_FILES}
>         $(make-cxx-exe)
>
> Joel, maybe this should also be in the Template file, at least a
> commented-out version?  I'm not sure I ever would have figured out the
> correct way to link if Ralf had not corrected me.
>   
That's not a bad idea.  I just did it.
>>   
>>     
>>> The other errors are due to the rtems/rtems_bsdnet.h header file, and
>>> can be eliminated by changing the inclusion of this file like this:
>>>
>>>     extern "C" {
>>>     #include <rtems/rtems_bsdnet.h>
>>>     }
>>>     
>>>       
>> If this works, you've found a bug inside of this header. This header must be C-safe.
>>   
>>     
> Yes, this header is not correct.
>   

I just committed a fix for this and the others in the libnetworking/rtems
directory that were not doing an extern "C".

--joel
>> Ralf
>>
>>
>>
>>   
>>     
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   




More information about the users mailing list