coin-or / CppAD

A C++ Algorithmic Differentiation Package: Home Page
https://cppad.readthedocs.io
Other
446 stars 94 forks source link

Linking error "undefined reference to `CppAD::local::temp_file()'" #169

Closed hichamhendy closed 1 year ago

hichamhendy commented 1 year ago

By Making my project, I keep getting the following error In functionvoid CppAD::put_check_for_nan(CppAD::vector const&, std::string&)': MPC.cpp:(.text._ZN5CppAD17put_check_for_nanIdEEvRKNS_6vectorIT_EERSs[_ZN5CppAD17put_check_for_nanIdEEvRKNS_6vectorIT_EERSs]+0x64): undefined reference to CppAD::local::temp_file()'

My CMakeList file looks like that: project(ipopt_test)

cmake_minimum_required (VERSION 3.5)

add_definitions(-std=c++11)

set(CXX_FLAGS "-Wall") set(CMAKE_CXX_FLAGS "${CXX_FLAGS}")

set(sources src/test.cpp src/main.cpp)

include_directories(src/Eigen-3.3) include_directories(/usr/local/include) link_directories(/usr/local/lib)

add_executable(ipopt_test ${sources})

target_link_libraries(ipopt_test ipopt python2.7)

Can anyone help?

bradbell commented 1 year ago

From the description above it does not seem like you are including cppad_lib in the linking.

hichamhendy commented 1 year ago

The solution was in reinstalling but tu in the right order CPPAD after ipopt

fengt2113 commented 1 year ago

The solution was in reinstalling but tu in the right order CPPAD after ipopt

Is there a reliable installation tutorial for cppad?

bradbell commented 1 year ago

The optional dependencies should be installed before installing CppAD (if you are going to use them with CppAD). See https://cppad.readthedocs.io/en/latest/cmake.html#cmake-title

Especially the discussion of the following options:

  -D include_adolc = true_or_false \
  -D include_eigen = true_or_false \
  -D include_ipopt = true_or_false \
  -D include_cppadcg = true_or_false \
  \
  -D eigen_prefix = eigen_prefix
  -D colpack_prefix = colpack_prefix \
  -D fadbad_prefix = fadbad_prefix \
  -D sacado_prefix = sacado_prefix \