undefined reference to `ceres::Problem::Problem()'

2,137 views
Skip to first unread message

yjz...@mail.ustc.edu.cn

unread,
Sep 11, 2018, 9:14:08 PM9/11/18
to Ceres Solver


hello,when i'm learning ceres,I have encountered some problems.something like this.there is my source file and CMakeLists.txt below,and i also attached them. thank you!!!

the source file is:
#include <ceres/ceres.h>

int main(int argc, char **argv)
{

  ceres::Problem problem;
 return 0;
}


 
the CMakeLists.txt is:
cmake_minimum_required(VERSION 2.8.0)
set(CMAKE_CXX_FLAGS -std=c++11)
project(ceres_curve_fitting)
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries(main ${CERES_LIBS})



the error is:
CMakeFiles/main.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x18): undefined reference to `ceres::Problem::Problem()'
main.cpp:(.text+0x29): undefined reference to `ceres::Problem::~Problem()'
collect2: error: ld returned 1 exit status
make[2]: *** [main] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2


CMakeLists.txt
main.cpp

Alex Stewart

unread,
Sep 12, 2018, 4:00:34 AM9/12/18
to ceres-...@googlegroups.com
You need CERES_LIBRARIES not CERES_LIBS in your target_link_libraries() call.

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/5d091412-8a6a-418d-9d76-54f11a80d7fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

杨记周

unread,
Sep 12, 2018, 4:09:36 AM9/12/18
to ceres-...@googlegroups.com

Thank you very much,it solved my problem.

 

发送自 Windows 10 邮件应用

 

发件人: Alex Stewart
发送时间: 2018912 16:00
收件人: ceres-...@googlegroups.com
主题: Re: [ceres-solver] undefined reference to `ceres::Problem::Problem()'

Reply all
Reply to author
Forward
0 new messages