Where in the build system to add library paths for external libs?

Hi,

I'm an IT student in Hamburg using MRPT to implement a custom laserscanner driver for my thesis.

The problem is that we have to use a closed source API to communicate with this laserscanner and thus our MRPT driver needs a couple libraries (which are not in my systems libpath) for the linker to work properly, but I have no idea as to where the intended place for adding these is in the makefiles. Can you hint me to the right place?

Also I'd be interested in more in-depth developer documentation than provided by this webpage.
Thank you
Jan

My linker error messages:

Linking CXX executable swissranger_cam_demo
CMakeFiles/swissranger_cam_demo.dir/test.cpp.o: In function `global constructors keyed to _Z16Test_SwissRangerv':
test.cpp:(.text+0x2f): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x39): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x43): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x4d): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x57): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x61): undefined reference to `boost::system::get_system_category()'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::sleep(boost::posix_time::time_duration const&)'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::Manager::~Manager()'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::DataTypeFilter::addRange(ibeo::DataType, ibeo::DataType)'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `typeinfo for ibeo::Serializable'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::Manager::initSystem(std::basic_istream >&)'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::intern::registerFactory(ibeo::Manager&)'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::Serializer::registerMessageHandler(boost::function, ibeo::DataTypeFilter const&)'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::Manager::runDevices()'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `typeinfo for ibeo::Laserscanner'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `typeinfo for ibeo::Scan'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `typeinfo for ibeo::Device'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `ibeo::Manager::Manager(unsigned short)'
../../lib/libmrpt-hwdrivers.so.0.9.0: undefined reference to `mrpt::hwdrivers::ibeoHandler(ibeo::Serializable const&, unsigned char)'
collect2: ld returned 1 exit status
make[2]: *** [samples/swissranger_cam_demo/swissranger_cam_demo] Fehler 1
make[1]: *** [samples/swissranger_cam_demo/CMakeFiles/swissranger_cam_demo.dir/all] Fehler 2
make: *** [all] Fehler 2

jlblanco's picture

Hi Jan, >The problem is that

Hi Jan,

>The problem is that we have to use a closed source API to communicate with this laserscanner and thus our MRPT driver needs
> a couple libraries (which are not in my systems libpath) for the linker to work properly, but I have no idea as to where the
>intended place for adding these is in the makefiles. Can you hint me to the right place?

I assume you are modifying the lib mrpt-hwdrivers to add your new driver/class, right? Then, take a look at the file MRPT/libs/hwdrivers/CMakeLists.txt.
That's where you should add the required extra libs to link against. There're already examples, like in the part of that file dealing with ARIA, you can see:

TARGET_LINK_LIBRARIES(mrpt-hwdrivers dl)

Instead of dl (libdl.so), just add other TARGET_LINK_LIBRARIES statements for your dependencies. The same applies to INCLUDE_DIRS, etc... The key is to modify just that CMakeLists.txt file, so the changes only apply to mrpt-hwdrivers and not the rest of MRPT.

>Also I'd be interested in more in-depth developer documentation than provided by this webpage.

Unfortunately, this web + Doxygen refs + the incipient mrpt-book are all the existing documentation... Someday I'll keep on completing the mrpt-book, if someday I'll find the free time needed for it!! :-)

Best,
JL

vollkorn's picture

one down, but still linking problems

>>The problem is that we have to use a closed source API to communicate with this laserscanner and thus our MRPT driver needs
>> a couple libraries (which are not in my systems libpath) for the linker to work properly, but I have no idea as to where the
>>intended place for adding these is in the makefiles. Can you hint me to the right place?
>
>I assume you are modifying the lib mrpt-hwdrivers to add your new driver/class, right? Then, take a look at the file MRPT/libs/hwdrivers/CMakeLists.txt.

Correct.

>TARGET_LINK_LIBRARIES(mrpt-hwdrivers dl)

This works, but is only half the solution. I also had to copy the libs to /usr/lib/ because I couldn't figure out how to add a library path (-L for gcc).

Unfortunately now the linking fails at a different component. Can you tell me why it fails here but works fine earlier in the process?

Linking CXX executable ../../bin/simul-gridmap
[ 92%] Built target simul-gridmap
[ 92%] Building CXX object apps/GridmapNavSimul/CMakeFiles/GridmapNavSimul.dir/gridmapSimulMain.cpp.o
In file included from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Configurable.hpp:17,
from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Device.hpp:14,
from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Laserscanner.hpp:14,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/libs/hwdrivers/include/mrpt/hwdrivers/CIbeo3D.h:31,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/libs/hwdrivers/include/mrpt/hwdrivers.h:44,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/apps/GridmapNavSimul/gridmapSimulMain.cpp:105:
/home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Param.hpp:168: error: expected identifier before ‘int’
/home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Param.hpp:168: error: expected ‘}’ before ‘int’
/home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Param.hpp:168: error: expected unqualified-id before ‘,’ token
In file included from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Configurable.hpp:17,
from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Device.hpp:14,
from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Laserscanner.hpp:14,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/libs/hwdrivers/include/mrpt/hwdrivers/CIbeo3D.h:31,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/libs/hwdrivers/include/mrpt/hwdrivers.h:44,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/apps/GridmapNavSimul/gridmapSimulMain.cpp:105:

vollkorn's picture

Compilet problems, caused by double definition of 'ParmType'?

Hi,

as I said earlier my partner and me are using external closed source libs we can't change and probably are not allowed to hand out, so we need to make the framework work with them.

Right now compiling fails in the middle of a definition of 'ParamType' in the header of the closed source API:

[ 91%] Building CXX object apps/GridmapNavSimul/CMakeFiles/GridmapNavSimul.dir/gridmapSimulMain.cpp.o
In file included from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Configurable.hpp:17,
from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Device.hpp:14,
from /home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Laserscanner.hpp:14,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/libs/hwdrivers/include/mrpt/hwdrivers/CIbeo3D.h:31,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/libs/hwdrivers/include/mrpt/hwdrivers.h:44,
from /home/jan/Dokumente/uni/TAMS DA/svn_neu/trunk/mrpt-0.9.0/apps/GridmapNavSimul/gridmapSimulMain.cpp:105:
/home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Param.hpp:168: error: expected identifier before ‘int’
/home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Param.hpp:168: error: expected ‘}’ before ‘int’
/home/jan/Dokumente/uni/TAMS DA/Ibeo API/MerkurAPI-2.9.0-r26055-Linux/include/IbeoAPI/Param.hpp:168: error: expected unqualified-id before ‘,’ token

The code where it fails:

44 namespace ibeo
[…]
141 class IBEOAPIDECL Param
142 {
143 public:
[…]
165 enum ParamType
166 {
167 NotSet, ///< Parameter type has not been set yet
168 Bool, ///< Parameter type Boolean
169 String, ///< Parameter type string, enclosed in double-quotes
[…]
194 };

I checked the source of MRPT and found the same name used in the gtest module. Right now I assume the compiling problem to be in this double definition here. But I don't know how and where to change the framework to get around this.

otherlibs/gtest-1.5.0/fused-src/gtest/gtest.h: typedef T ParamType;
otherlibs/gtest-1.5.0/fused-src/gtest/gtest.h: typedef typename TestClass::ParamType ParamType;
otherlibs/gtest-1.5.0/fused-src/gtest/gtest.h: explicit ParameterizedTestFactory(ParamType parameter) :
otherlibs/gtest-1.5.0/fused-src/gtest/gtest.h: const ParamType parameter_;
otherlibs/gtest-1.5.0/fused-src/gtest/gtest.h:template

Any help in separating the external dependencies from the framework and to make our driver work would be appreciated.

Thanks
Jan

jlblanco's picture

Hi Jan, That declaration in

Hi Jan,

That declaration in gtest can't affect the source file where your error appear (gridmapSimulMain.cpp I think)...

It seems however that in your new class "CIbeo3D.h" there are direct "#includes" to the vendor library... and this is another example of how problematic is to include different APIs (OpenCV, Windows/Linux headers, wxWidgets, ....).

To avoid that problem, I always move those #includes (in your case, the #include <IbeoAPI/*>) from the .h to the .cpp... This causes a few problems to the programmer (you :-) ), but makes things easier to users of the library (in this case, you too!) since avoids a lot of problems.

Please read my solution in a previous post here, and let me know if you need more help to do the integration:

http://www.mrpt.org/node/189#comment-66

vollkorn's picture

compiles now

I put the vendor includes in my .cpp file and changed my code a little und now it works.

Thanks
Jan

Syndicate content

The Mobile Robot Programming Toolkit (MRPT) initiative (C) 2012