compile library -D_GLIBCXX_USE_CXX11_ABI = 1

295 views
Skip to first unread message

to still

unread,
Oct 20, 2022, 12:24:19 PM10/20/22
to CasADi

When I first encoutered the following problem, I add "add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)" in the my project cmake file. The problem is solved.
" undefined reference to `casadi::Function::Function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::initializer_list<casadi::MX>, std::initializer_list<casadi::MX>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, casadi::GenericType, std::less<std::__cxx11::b... "

However, when I want to link CASADI with other libraries , like HIGHS, an optimization solver,  The setting of  -D_GLIBCXX_USE_CXX11_ABI=0 conflicts with the setting of other packages.

My questions is can I compile casadi library with -D_GLIBCXX_USE_CXX11_ABI=1 ?

I tried add  add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1) in the CASADi CMakeLists.txt file, but this does not work.
for example 
"
....
set(PACKAGE_MAINTAINER "Joel Andersson and Joris Gillis")
set(PACKAGE_URL "http://casadi.org")

add_definitions(-D_GLIBCXX_USE_CXX11_AB=1)

############################################################
####################### Policies ###########################
############################################################
# Enforce cmake2.4+ style behaviour for
# mixed filename/full path linker directives
cmake_policy(SET CMP0003 NEW)

...
"

to still

unread,
Oct 20, 2022, 5:39:17 PM10/20/22
to CasADi
I found the solution.

The problem:
    My compile environment is centos 7 + gcc 7.3 (upgrade from gcc 4.85). I compile the CASADi with Cmake in command window and generate casadi.so, then I link the library into a new example, encountering the  error mentioned above.

 My  solution:
    Since I use vscode IDE, I compile the CASADi in the vscode and generate casadi.so library with gcc 7.3 option. After this I link the casadi.so again, it works.

The reason maybe the compilation still use some library of gcc 4.85 even my gcc is 7.3.

Hopefully this can help others having the same problem. 
Reply all
Reply to author
Forward
0 new messages