ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

catkin: build debendencies library of two other libraries

asked 2015-06-29 07:32:00 -0500

Kersm gravatar image

updated 2015-06-30 02:24:22 -0500

Dear Community,

i have some troubles with a Library which is dependend on two others. I have added them all to CMakeLists.txt of my Package, it compiles correct but linking doesn't work.

Here the relevant parts of my CMakeLists.txt:

    link_directories(src/vPoint/ src/lsd/)

    add_library(MSAC
        src/vPoint/MSAC.h
        src/vPoint/MSAC.cpp
        src/vPoint/lmmin.h
        src/vPoint/lmmin.c
        src/vPoint/errorNIETO.h
        src/vPoint/errorNIETO.cpp
    )

    add_library(LSDLIB
        src/lsd/lsd.h
        src/lsd/lsd.c
    )

    add_library(FEATURES
        src/feature.cpp
        src/featureConstants.cpp
        include/open_cv_testing/feature.h
    )

add_executable(lsdnode src/lsd_node.cpp)

target_link_libraries(FEATURES LSDLIB MSAC ${catkin_LIBRARIES})

target_link_libraries(lsdnode FEATURES ${catkin_LIBRARIES})

With the Features Library only dependent from MSAC everything worked, but now also with LSDLIB library. It says while Linking it undefined resource lsd(...) but it's well defined with lsd.h and lsd.c.

Any Help what I'm missing appreciated...

The acutall error output is:

/home/martin/catkin_ws/devel/lib/libFEATURES.so: undefined reference to `lsd(int*, double*, int, int)'
collect2: ld returned 1 exit status
make[2]: *** [/home/martin/catkin_ws/devel/lib/open_cv_testing/lsdnode] Error 1
make[1]: *** [open_cv_testing/CMakeFiles/lsdnode.dir/all] Error 2
make: *** [all] Error 2

I'm using ROS Groovy in Ubuntu 12.04 LTS

LSD Library from here: http://www.ipol.im/pub/art/2012/gjmr-... Invoking in my Features Source code as in their call example, which runs without troubles...

edit retag flag offensive close merge delete

Comments

can you please post the actual error output? Furthermore: OS, ROS-Distro, ...

mgruhler gravatar image mgruhler  ( 2015-06-30 01:51:23 -0500 )edit

hi, thanks for your answer, hope i have added enough information now

Kersm gravatar image Kersm  ( 2015-06-30 02:25:56 -0500 )edit

Just found out that the problem, is not the Library which uses two Librarys. I made a test node, which uses the LSD Lib directly (without the FEATURES Lib) and there is the same problem with the undefined reference: target_link_libraries(lsdtest LSDLIB {catkin_LIBRARIES})

Kersm gravatar image Kersm  ( 2015-06-30 04:45:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-06-30 05:49:16 -0500

mgruhler gravatar image

Wow, that was a wild one ;-)

The LSD library is ANSI C. So when you compile this you have to tell the linker to link in a C library. I did a bit of googling and here is what worked for me (actually, pretty simple). But whether this is the best or correct way, I cannot say. Wrap the include statement of the lsd header in an extern "C" call.

extern "C" {
#include <lsd.h>
}

Hope this works.

edit flag offensive delete link more

Comments

Thank you so much! Obviously i googled wrong, this problem kept me going for 3days before i asked here...

Kersm gravatar image Kersm  ( 2015-06-30 06:09:48 -0500 )edit

glad to help.

mgruhler gravatar image mgruhler  ( 2015-06-30 06:15:15 -0500 )edit

Question Tools

Stats

Asked: 2015-06-29 07:32:00 -0500

Seen: 214 times

Last updated: Jun 30 '15