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

missing .so file #3733

Open
gelatinouscube42 opened this issue Jun 19, 2024 · 5 comments
Open

missing .so file #3733

gelatinouscube42 opened this issue Jun 19, 2024 · 5 comments

Comments

@gelatinouscube42
Copy link

gelatinouscube42 commented Jun 19, 2024

When attempting to use the Importer class from Python by, e.g.

_f_imp = cas.Importer('solver.c', 'clang')

I am getting the error:

Error code: ./libcasadi_importer_clang.so: cannot open shared object file: No such file or directory

Checking my site-packages installation of casadi, and sure enough, there is no libcasadi_importer_clang.so

There is the "shell" version, but then there are missing dependencies...that can't seem to find <coin-or/IpStdCInterface.h>

@tmmsartor
Copy link
Collaborator

tmmsartor commented Jun 19, 2024

Regarding the missing clang plugin, I guess it is not supported anymore, see #3372

Regarding the missing header you can make it work specifying the headers file shipped with casadi explicitly,
in case of python with something like:

from pathlib import Path
opts = {"compiler_flags": f"-I{Path(cas.__file__).parent / 'include/'}"}
f_imp = Importer('solver.c','shell',opts)

NB1: Also installing ipopt on your system will likely solve that, in that case you will have the header the compiler is looking for on system default paths.

NB2: If you are code-generating the call to ipopt nlpsol plugin you may also need:

opts = {"compiler_flags": f"-I{Path(cas.__file__).parent / 'include/'}"
              "linker_flags":      f"-L{Path(cas.__file__).parent} -lcasadi_nlpsol_ipopt"}

@gelatinouscube42
Copy link
Author

It seems the opts you provided in the code block have at least compiled the solver for me, will have to wait till the evening till I get around to testing to verify this is a fix on my system. Seems likely though.

Re: installing ipopt on my system. Pretty sure it is installed already, but in any case trying to make a package with minimal dependencies for ease of distribution, so trying to avoid manual installs to the extent possible.

Thanks for the help!

@gelatinouscube42
Copy link
Author

Now getting around to testing more thoroughly...it seems there is a problem constructing the Ipopt problem in the compiled code:

symbol lookup error: ./tmp_casadi_compiler_shelliUE4wi.so: undefined symbol: CreateIpoptProblem

@tmmsartor
Copy link
Collaborator

tmmsartor commented Jun 26, 2024

I get the error if I leave out the option entry about linker flag, in that way when casadi is trying to compile the source code you provided source.c is not linking against libipopt.so where that symbol is defined.
This should solve:

from pathlib import Path
import casadi
CASADI_DIR = Path(casadi.__file__).parent
opts = {"compiler_flags": f"-I{CASADI_DIR / 'include/'}",
             "linker_flags": f"-L{CASADI_DIR} -lipopt"}
f_imp = casadi.Importer('solver.c','shell',opts)

NB: If you compiled casadi from source and your iptop library is installed in a non-standard path you need to add that in order for the linker to find it

@gelatinouscube42
Copy link
Author

I also needed to add the nlpsol linked library:

{"compiler_flags": f"-I{Path(cas.__file__).parent / 'include/'}",
                "linker_flags": f"-L{Path(cas.__file__).parent} -lcasadi_nlpsol_ipopt -lipopt"}

Thanks for giving me guidance!

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

2 participants