Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libvkit_common Undefined Reference #21

Open
bvibhav opened this issue Jun 20, 2014 · 15 comments
Open

libvkit_common Undefined Reference #21

bvibhav opened this issue Jun 20, 2014 · 15 comments

Comments

@bvibhav
Copy link

bvibhav commented Jun 20, 2014

I am having these errors during the compilation process, any ideas?

/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::operator=(Sophus::SE3 const&)'
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::SE3()' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::SE3(Sophus::SE3 const&)'
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::operator*(Sophus::SE3 const&) const' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SO3::matrix() const'
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::SE3(Eigen::Matrix<double, 3, 3, 0, 3, 3> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::operator_(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) const'
collect2: ld returned 1 exit status
make[2]: ** [/home/bvibhav/catkin_ws/devel/lib/vikit_common/test_vk_common_camera] Error 1
make[1]: *** [rpg_vikit/vikit_common/CMakeFiles/test_vk_common_camera.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::operator=(Sophus::SE3 const&)'
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::SE3()' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::SE3(Sophus::SE3 const&)'
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::operator*(Sophus::SE3 const&) const' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SO3::matrix() const'
/home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::SE3(Eigen::Matrix<double, 3, 3, 0, 3, 3> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)' /home/bvibhav/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::operator
(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) const'
collect2: ld returned 1 exit status
make[2]: *_* [/home/bvibhav/catkin_ws/devel/lib/vikit_common/test_vk_common_triangulation] Error 1
make[1]: *** [rpg_vikit/vikit_common/CMakeFiles/test_vk_common_triangulation.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

@cfo
Copy link
Collaborator

cfo commented Jun 20, 2014

did you checkout the right version of sophus?

git checkout a621ff

@bvibhav
Copy link
Author

bvibhav commented Jun 20, 2014

Yes, Its that version. Just to make sure, I rebuild it. It still gives the same error

@zeadope-zz
Copy link

Just encountered the exact same problem. Can't seem to figure out a solution. Any help would be appreciated.

@hanl09
Copy link

hanl09 commented Nov 21, 2014

I was trying to compile rpg_svo on my Laptop in the environment of Ubuntu 14.04 with the support of ROS. I also meet such a problem and fixed it luckily by modifying the CMakeLists.txt under vikit_common.

Here is how I treat this problem:
In CMakeLists.txt under vikit_common, there is a command as listed below:
cmakelists

which indicates that Sophus_LIBRARIES should be added as a linked lib, but it was null when I tried to
print it by using: message("sophus_lib: ${Sophus_LIBRARIES}").

I know that when compiling Sophus, a lib file libSophus.so will be built and it should be added in Sophus_LIBRARIES, so I added one command above the TARGET_LINK_LIBRARIES command as:
set{Sophus_LIBRARIES libSophus.so} and succeed by recompile rpg_svo using the catkin_make command.

modified

The problem was caused by missing to add the link to libSophus.so when compile the vikit_common problem. I don't know why it happens.

@zeadope-zz
Copy link

I tried to add the suggested line set{Sophus_LIBRARIES libSophus.so} to ~/catkin_ws/src/rgp_vikit/vikit_common/CMakeLists.txt. But that did not work and got an error instantly "set{{Sophus_LIBRARIES".

Then I changed the line to SET(Sophus_LIBRARIES libSophus.so). That error was gone.
Now I end up with the error: /usr/bin/ld: cannot find -lSophus

So I went to ~/catkin_ws/Sophus/build/ directory and did a "sudo make install" and catkin_make again.
Success! vikit_common and the rest of rpg_vikit and rpg_svo compiled without a hitch.

@hanl09
Copy link

hanl09 commented Nov 22, 2014

yes, that should be set(Sophus_LIBRARIES libSophus.so) rather than set{Sophus_LIBRARIES libSophus.so}
my mistake

@tmagcaya
Copy link

Thanks!

@wang-chen
Copy link

thanks

@cehberlin
Copy link

I had the same problem. Adding SET(Sophus_LIBRARIES libSophus.so) and using make install worked for me as well. May add this line as a fix?

@binary42
Copy link

Please fix this. Otherwise I will create a pull request with the correct and modified CMakeLists.txt to handle this error.

@binary42
Copy link

FYI this issue exists for both vikit and svo compile

@binary42
Copy link

Unfortunately, adding SET ... for sophus for the svo compile, though works, when svo is run, one gets:
symbol lookup error: ./lib/libsvo.so: undefined symbol: _ZN6Sophus3SE3C1Ev. Very frustrating

@qiangw89
Copy link

@binary42 Did you figure out one way to solve the issue? I got the same error as well. Just like you said, "very frustrating". Thanks very much!

@Sbenai
Copy link

Sbenai commented Apr 5, 2016

[ 88%] Built target vikit_common
Linking CXX executable /home/benaissa/catkin_ws/devel/lib/vikit_common/test_vk_common_camera
/home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::SE3(Eigen::Matrix<double, 3, 3, 0, 3, 3> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)' /home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::operator_(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) const'
/home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)' /home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::operator_(Sophus::SE3 const&) const'
/home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SE3::operator=(Sophus::SE3 const&)' /home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::SE3()'
/home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference to Sophus::SO3::matrix() const' /home/benaissa/catkin_ws/devel/lib/libvikit_common.so: undefined reference toSophus::SE3::SE3(Sophus::SE3 const&)'
collect2: ld a retourné 1 code d'état d'exécution
make[2]: *** [/home/benaissa/catkin_ws/devel/lib/vikit_common/test_vk_common_camera] Erreur 1
make[1]: *** [svo_slam/rpg_vikit/vikit_common/CMakeFiles/test_vk_common_camera.dir/all] Erreur 2
make: *** [all] Erreur 2
Invoking "make" failed
root@ubuntu:~/catkin_ws#

__
how to fixe this problem ?

@Sbenai
Copy link

Sbenai commented Apr 5, 2016

Go to vikit_common directory:

cd ~/catkin_ws/src/svo_slam/rpg_vikit/vikit_common
geany CMakeLists.txt

#######################################
SET(PROJECT_NAME vikit_common)
PROJECT(${PROJECT_NAME})
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.3)
SET(CMAKE_BUILD_TYPE Release) # Release, RelWithDebInfo
SET(CMAKE_VERBOSE_MAKEFILE OFF)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMakeModules/")
SET(USE_ROS TRUE) # Set False if you want to build this package without Catkin

Set build flags. Set IS_ARM on odroid board as environment variable

SET(CMAKE_CXX_FLAGS "-Wall -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas")
IF(DEFINED ENV{ARM_ARCHITECTURE})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=armv7-a")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx -msse -msse -msse2 -msse3 -mssse3")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF()
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -fsee -fomit-frame-pointer -fno-signed-zeros -fno-math-errno -funroll-loops")

Add plain cmake packages

FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(Eigen REQUIRED)
FIND_PACKAGE(Sophus REQUIRED)

Include dirs

INCLUDE_DIRECTORIES(
include
${Eigen_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${Sophus_INCLUDE_DIRS}
)

IF(USE_ROS)
FIND_PACKAGE(catkin REQUIRED COMPONENTS roscpp cmake_modules)
LIST(APPEND INCLUDE_DIRECTORIES ${catkin_INCLUDE_DIRS})
catkin_package(
DEPENDS Eigen OpenCV Sophus
CATKIN_DEPENDS roscpp
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
)
ELSE()
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
ENDIF()

Set Sourcefiles

LIST(APPEND SOURCEFILES src/atan_camera.cpp
src/omni_camera.cpp
src/math_utils.cpp
src/vision.cpp
src/performance_monitor.cpp
src/robust_cost.cpp
src/user_input_thread.cpp
src/pinhole_camera.cpp
src/homography.cpp
src/img_align.cpp)

Create vikit library

set(Sophus_LIBRARIES libSophus.so)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCEFILES})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}
${OpenCV_LIBS}
${Sophus_LIBRARIES}
${catkin_LIBRARIES})

IF(USE_ROS)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${catkin_LIBRARIES})
ENDIF()

##Tests
ADD_EXECUTABLE(test_vk_common_camera test/test_camera.cpp)
TARGET_LINK_LIBRARIES(test_vk_common_camera ${PROJECT_NAME})

ADD_EXECUTABLE(test_vk_common_triangulation test/test_triangulation.cpp)
TARGET_LINK_LIBRARIES(test_vk_common_triangulation ${PROJECT_NAME})

ADD_EXECUTABLE(test_vk_common_patch_score test/test_patch_score.cpp)
TARGET_LINK_LIBRARIES(test_vk_common_patch_score ${PROJECT_NAME})

################################################################################

Create the vikit_commonConfig.cmake file for other cmake projects.

IF(NOT USE_ROS)
GET_TARGET_PROPERTY( FULL_LIBRARY_NAME ${PROJECT_NAME} LOCATION )
SET(vikit_common_LIBRARIES ${FULL_LIBRARY_NAME} )
SET(vikit_common_LIBRARY_DIR ${PROJECT_BINARY_DIR} )
SET(vikit_common_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/vikit_commonConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/vikit_commonConfig.cmake @only IMMEDIATE )
export( PACKAGE vikit_common )

INSTALL(DIRECTORY include/vikit DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h" )
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
ENDIF()

###########################################

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants