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

undefined reference to `nlopt_get_errmsg' #487

Open
Griset opened this issue Dec 27, 2022 · 0 comments
Open

undefined reference to `nlopt_get_errmsg' #487

Griset opened this issue Dec 27, 2022 · 0 comments

Comments

@Griset
Copy link

Griset commented Dec 27, 2022

Hi,

I'm getting the following linker error message :

in function nlopt::opt::get_errmsg() const': Hamiltonian.cpp:(.text._ZNK5nlopt3opt10get_errmsgEv[_ZNK5nlopt3opt10get_errmsgEv]+0x5b): undefined reference to nlopt_get_errmsg'
collect2: error: ld returned 1 exit status

when trying to compile a code which call nlopt.

I compiled the nlopt 2.7.1 using the make install command and got :

Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/pkgconfig/nlopt.pc
-- Installing: /usr/local/include/nlopt.h
-- Installing: /usr/local/include/nlopt.hpp
-- Installing: /usr/local/include/nlopt.f
-- Installing: /usr/local/lib/libnlopt.so.0.11.1
-- Installing: /usr/local/lib/libnlopt.so.0
-- Set runtime path of "/usr/local/lib/libnlopt.so.0.11.1" to "/usr/local/lib"
-- Installing: /usr/local/lib/libnlopt.so
-- Installing: /usr/local/lib/cmake/nlopt/NLoptLibraryDepends.cmake
-- Installing: /usr/local/lib/cmake/nlopt/NLoptLibraryDepends-release.cmake
-- Installing: /usr/local/lib/cmake/nlopt/NLoptConfig.cmake
-- Installing: /usr/local/lib/cmake/nlopt/NLoptConfigVersion.cmake
-- Installing: /usr/local/share/man/man3/nlopt.3
-- Installing: /usr/local/share/man/man3/nlopt_minimize.3

and my cmakeList look like

cmake_minimum_required(VERSION` 3.13.4)
project(myProject)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 20)

add_executable(myProject main.cpp)
target_link_libraries(myProject PUBLIC nlopt ${CPLEX_LIBRARIES} `${CMAKE_DL_LIBS})

I found that someone already got a similar issue but the proposed fixing does not seem to apply to my settings

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

1 participant