우분투에서 개발하다 보면 자주 등장하는 에러인데 이게 뭐지?? 하다가 찾아보니 빌드할 때 발생하는 이전 에러 때문에 나타나는 에러 메시지다. 결론적으로 collect2: error: ld returned 1 exit status 로그 앞단의 문제를 해결해야 해결되는 문제..
아래는 검색한 결과 StackOverflow 페이지이다.
What does "collect2: error: ld returned 1 exit status" mean?
I see the error collect2: error: ld returned 1 exit status very often. For example, I was trying to build the following snippet of code: void main() { char i; printf("ENTER i"); sc...
stackoverflow.com
DBoW3 라이브러리를 사용하는 프로그램을 작성중이었는데, Linking 도중에 collect2 에러가 나타났다. 아래는 에러 메세지이다.
[100%] Linking CXX executable /home/kbk/2023_catkin/catkin_pr_ws/devel/lib/pr
CMakeFiles/pr.dir/src/pr.cpp.o: In function `pr::loadDB(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/kbk/2023_catkin/catkin_pr_ws/src/pr/src/pr.cpp:128: undefined reference to `DBoW3::operator<<(std::ostream&, DBoW3::Database const&)'
CMakeFiles/pr.dir/src/pr.cpp.o: In function `std::_MakeUniq<DBoW3::Database>::__single_object std::make_unique<DBoW3::Database, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
/usr/include/c++/7/bits/unique_ptr.h:821: undefined reference to `DBoW3::Database::Database(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
라이브러리 링크 문제를 어디에서 해결해야하나 한참 찾아보다가 아래와 같이 DBoW3 라이브러리 링크를 CMakeLists.txt 파일에 추가 했더니 정상적으로 빌드가 된다.
add_executable(placeRecognition src/pr.cpp)
target_link_libraries(pr ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${DBoW3_LIBRARIES})
역시 개발 환경이 바뀌다 보니 실제 개발과는 관련없는 셋팅 문제로 인한 trouble-shooting 문제가 골치아프다. :-(
반응형
'IT 스터디 > C, C++' 카테고리의 다른 글
error C2065: 'M_PI': 선언되지 않은 식별자입니다. (feat. openMVG) (1) | 2023.10.19 |
---|---|
VS Code C++ Debugging on Ubuntu (2) - feat. "launch.json" (0) | 2023.09.08 |
CMake 간단 사용법 (1) (0) | 2023.08.01 |
atan2() 함수의 의미와 사용 (0) | 2023.06.22 |
Ubuntu 에서 VS Code 설치 및 C++ 디버깅 하기 (0) | 2023.06.13 |