[Bug 840] New: linker errors with ORO_LIST_COMPONENT_TYPE macro

http://bugs.orocos.org/show_bug.cgi?id=840

Summary: linker errors with ORO_LIST_COMPONENT_TYPE macro
Product: Toolchain
Version: 2.3.0
Platform: All
OS/Version: GNU/Linux
Status: NEW
Severity: enhancement
Priority: P3
Component: RTT
AssignedTo: orocos-dev [..] ...
ReportedBy: meyer [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Using the ORO_LIST_COMPONENT_TYPE macro in multiple source files and linking
them to a single Orocos component results in the following linker error:

CMakeLists.txt:
orocos_component(navigation Navigation.cpp GPS.cpp Compass.cpp)

Linker output:
Linking CXX shared library
/opt/uxvcos/demo/lib/orocos/gnulinux/libnavigation-gnulinux.so
CMakeFiles/navigation.dir/GPS.o: In function `Instance':
/usr/include/rtt/Component.hpp:72: undefined reference to `RTT::(anonymous
namespace)::ComponentFactories::Factories'
/usr/bin/ld: CMakeFiles/navigation.dir/GPS.o: relocation R_386_GOTOFF against
undefined symbol `RTT::(anonymous namespace)::ComponentFactories::Factories'
can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value

Only one of the source files contains the ORO_CREATE_COMPONENT_LIBRARY macro.
When all macro calls are in the same source file, everything works fine.

gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5gcc

[Bug 840] linker errors with ORO_LIST_COMPONENT_TYPE macro

http://bugs.orocos.org/show_bug.cgi?id=840

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED

--- Comment #4 from Peter Soetens <peter [..] ...> 2011-03-15 12:00:29 CET ---
(In reply to comment #3)
> Created attachment 663
> fixes this bug
>
> An anonymous namespace sneaked in while porting the ocl header to the RTT
> namespace.
>
> This patch fixes it, I've also pushed the fix to the toolchain-2.3 branch.
>
> Peter

Fixed as reported.

[Bug 840] linker errors with ORO_LIST_COMPONENT_TYPE macro

http://bugs.orocos.org/show_bug.cgi?id=840

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|orocos-dev [..] ... |peter [..] ...
|ven.be |

--- Comment #3 from Peter Soetens <peter [..] ...> 2011-03-08 22:55:07 CET ---
Created attachment 663
--> http://bugs.orocos.org/attachment.cgi?id=663
fixes this bug

An anonymous namespace sneaked in while porting the ocl header to the RTT
namespace.

This patch fixes it, I've also pushed the fix to the toolchain-2.3 branch.

Peter

[Bug 840] linker errors with ORO_LIST_COMPONENT_TYPE macro

http://bugs.orocos.org/show_bug.cgi?id=840

--- Comment #2 from Johannes Meyer <meyer [..] ...> 2011-03-08 22:27:42 CET ---
Created attachment 662
--> http://bugs.orocos.org/attachment.cgi?id=662
testcase for Bug #840

All source files include the new rtt/Component.hpp header file. I attached a
simple test case with two components that are compiled in a single library.
This example fails with the same error on my Ubuntu system.

Johannes

[Bug 840] linker errors with ORO_LIST_COMPONENT_TYPE macro

http://bugs.orocos.org/show_bug.cgi?id=840

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |peter [..] ...

--- Comment #1 from Peter Soetens <peter [..] ...> 2011-03-08 21:55:29 CET ---
(In reply to comment #0)
> Using the ORO_LIST_COMPONENT_TYPE macro in multiple source files and linking
> them to a single Orocos component results in the following linker error:
>
> CMakeLists.txt:
> orocos_component(navigation Navigation.cpp GPS.cpp Compass.cpp)
>
> Linker output:
> Linking CXX shared library
> /opt/uxvcos/demo/lib/orocos/gnulinux/libnavigation-gnulinux.so
> CMakeFiles/navigation.dir/GPS.o: In function `Instance':
> /usr/include/rtt/Component.hpp:72: undefined reference to `RTT::(anonymous
> namespace)::ComponentFactories::Factories'
> /usr/bin/ld: CMakeFiles/navigation.dir/GPS.o: relocation R_386_GOTOFF against
> undefined symbol `RTT::(anonymous namespace)::ComponentFactories::Factories'
> can not be used when making a shared object
> /usr/bin/ld: final link failed: Bad value
>
> Only one of the source files contains the ORO_CREATE_COMPONENT_LIBRARY macro.
> When all macro calls are in the same source file, everything works fine.
>
> gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5gcc

The bug is that one of your files includes rtt/Component.hpp and the other
ocl/Component.hpp.

We're thinking of a solution to fix this. Probably the most easy/reliable one
is to let ocl/Component.hpp include rtt/Component.hpp

Peter