Linking acados with external libs

Hi,
I’m trying to move my OC problems from Casadi/Ipopt to Acados.
So far, so good !
But I stumbled upon the following issue :
my ode function is given by an external .so lib which I load thanks to :
f_ext = casadi.external("my_ext_func", "my_ext_func.so", {"enable_fd"=True})
f_expl = f_est(x,u)
model.f_expl_expr = f_expl
When compiling, I get the following error :
OSError: c_generated_code/libacados_ocp_solver_eocar_ode.so: undefined symbol: my_ext_func
Which I understand, but since the makefile is automatically generated, how should I specify Acados to link with external libs, if this is possible ?!
Thank you,
Fb

Hi,
I have to admit, that I never linked additional external libraries for the model functions and there is no workflow for this in the template yet.
But, I think I can point out how it should work.

To be clear, you only have to link this external function my_ext_func.so to the shared library containing your ocp solver libacados_ocp_solver_eocar_ode.so, not the acados shared library.

The Makefile is generated from this template:

I think you just have to modify this command by adding the linker flag to your external function.

You could add something like:

	{%- if not model_external_shared_lib == "" %}
	-I {{ model_external_shared_lib }}
	{% endif %}

You could first try to edit the rendered Makefile by adding such a line.
If it works, it would be great if you make a pull request with that.
Note, you always have to reinstall the Python interface if you change the templates or the Python code.

Let me know if this somehow works for you.

Best,
Jonathan

Hey @byfra,

I realized it might be a bit much to ask you to make these changes, so I just did it myself.
Could you try to check out this version and let me know if that works for you?

Best,
Jonathan

Hi FreyJo !

I actually did the mods yesterday and it works just fine. I can push them on my fork and request a pull so you can inspect it or I can test your version. Let me know what you prefer.

François

Hi François,

awesome! :ok_hand:
For me both options work.
Just either comment on my PR or do another one with your change and I will review it.

Best,
Jonathan

I’ll let you review mine :slight_smile:
Thanks !

Merged, thanks for collaborating :slightly_smiling_face: