C++, linking against python installation #3113
Replies: 2 comments 1 reply
-
You may get lucky by using -D |
Beta Was this translation helpful? Give feedback.
-
It looks like the linker is not able to find the symbols in the casadi library even though you have specified the -L option to point to the directory containing the library. One possible reason for this is that the linker is not able to find the correct version of the library to link against. Here are a few things you can try to resolve the issue: Make sure that the casadi library you are linking against is the correct version and architecture for your system. You can check the architecture of the library using the "file" command in the terminal. For example, run "file libcasadi.so" to check the architecture of the library. Check if the library you are linking against has any dependencies that are not installed on your system. You can use the "ldd" command to check the dependencies of the library. For example, run "ldd libcasadi.so" to check the dependencies of the library. Try adding the "-Wl,-rpath=/lib/python3.11/site-packages/casadi/" option to the linker command. This tells the linker to add the specified directory to the runtime library search path. If the above steps do not work, you can try using the "nm" command to check if the symbols are present in the casadi library. For example, run "nm -D libcasadi.so | grep Opti" to check if the "Opti" symbol is present in the library. If the symbol is not present, it could indicate that the library was not built with the correct options. If you are still unable to resolve the issue, you can try building casadi from source on your Ubuntu system and linking against the locally built library. This will ensure that the library is built with the correct options and architecture for your system. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm making some C++ experiments and I have a linking problem under Linux (Ubuntu 22.04). My problem is that when I try to link against the libraries installed when I do
pip install casadi
and then specifying -I and -L options to the c++ compiler. I get linker errors of the type: `undefined reference to casadi::Opti::Opti'.If I compile casadi from sources, this all works exactly as I expected. Also, on my Mac I can link against the pip-installed libraries without any issues.
Any ideas what I'm missing here?
My minimal example is the source file:
#include <casadi/casadi.hpp> int main() { auto opti = casari::Opti(); }
and the build command:
g++ -I<venv>/lib/python3.11/site-packages/casadi/include -L<venv>/lib/python3.11/site-packages/casadi/ -o debug debug.cc -lcasadi
Beta Was this translation helpful? Give feedback.
All reactions