(Cross-posting the answer to rock-users, in the future please ask these kind of questions there)
The undefined symbols happen because you did not link to the library. Instead of calling rock_find_cmake and include_directories explicitely, simply add DEPS_CMAKE modbus to the rock_library call. Moreover, unless the orogen component and/or the other packages are actually using the linux-modbus library directly, the pkg-config file should contain the information needed for them. If you've been using the Rock library templates, the generated pkg-config file should already be fine. In other words: drivers/base_modbus: use custom cmake Find script and DEPS_CMAKE drivers/irdh_bender: just use DEPS_PKGCONFIG base_modbus drivers/orogen/irdh_bender: add "using_library 'irdh_bender'" in the orogen file Sylvain On Mon, Apr 27, 2015 at 11:17 AM, fahrlich <[email protected]> wrote: > Hi > > i wrote a modbus driver that depends on linux-modbus library . > > The driver is called base_modbus and i added a FindModbus.cmake file > to the project > and following lines to the CMakeList.txt in the src folder: > > set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} > "${CMAKE_SOURCE_DIR}/cmake/Modules/") > rock_find_cmake(modbus) > include_directories(${modbus}) > > So far , this works fine . > > Then i wrote another driver, called irdh_bender, that inherits from > base_modbus. > I did the same stuff as described above: put the findModbus.cmake > script into the the project folder and > adapted the CMakeLists.txt > > This works fine, too > > Then i wrote a task, to run the irdh_bender lib. Again, i put the > findmodbus.cmake file into project folder. > Into CmakeLists.txt i added: > > > list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") > message(STATUS " cmake module path : ${CMAKE_MODULE_PATH}") > > FIND_PACKAGE(Modbus REQUIRED) > list(APPEND EXTRA_LIBS modbus) > > include_directories(${MODBUS_INCLUDE_DIR}) > message(STATUS "cmake module path : ${MODBUS_INCLUDE_DIR}") > > > > But if i run amake i get following linking error > > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_new_tcp_pi' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_read_input_registers' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_flush' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_close' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_set_debug' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_free' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_connect' > /home/fahrlich/code/rock/install/lib/libbase_modbus.so: Nicht > definierter Verweis auf `modbus_strerror' > > > > But in rock/install/log/drivers/orogen/irdh_bender-configure.log ui can > see that the lib was found : > > > cmake module path : > /home/fahrlich/code/rock/drivers/orogen/irdh_bender/.orogen/config;/home/fahrlich/code/rock/drivers/orogen/irdh_bender > -- Found libmodbus: /usr/lib/x86_64-linux-gnu/libmodbus.so > -- Found modbus include Dir: /usr/include/modbus > > > How can i fix this ? > > thanks > Frauke > _______________________________________________ > Rock-dev mailing list > [email protected] > http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev _______________________________________________ Rock-dev mailing list [email protected] http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev
