clad
clad copied to clipboard
Unable to Load Plugin on Compilation
I am trying to compile my code with clad but am running into issues.
Any help would be appreciated!
Hi @ishaanamahajan
Can you please make sure that you are using the same standard C++ library (-lstdc++
, -lc++
) for building clad plugin (clad.so
) and your example, main.cpp
.
Hi @parth-07 ,
I built my clad.so
using conda following commands on here - https://github.com/vgvassilev/clad.
I am also using the flags in my compilation statement (shown in the screenshot), that you mentioned. Am I missing something?
Hi @ishaanamahajan
I think there's some issue in -fplugin
option. Can you please try the below command to run clad?
clang++ -o main.elf main.cpp -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang /path/to/clad.so -I/path/to/clad/include -xc++
I get the same error message, just one of them this time though -
When can I expect another follow-up on the above?
What does clang -version say?
this is the output I get -
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
You seem to be using clang 15 and clad 1.0. Clad 1.0 is incompatible with clang 15 as it appeared later. Could you try with clad 1.2? Or get earlier version of clang?
Hi @ishaanamahajan
The Clad plugin has a strict dependency on the runtime Clang version. If the Clad plugin is built for Clang 10, then it can only be used with Clang 10, and so on. Based on the path clad-1.0-clang5_hbd05ba3_0/lib/clad.so
, it seems like the version of Clad downloaded from Conda was built for Clang 5. This also explains the error that you are seeing. Can you please try building Clad from the source for the Clang version installed on your system?
the clad readme says 15.0.7 is supported.. which llvm/clang versions are supported currently?
ah - nevermind - the readme is for 1.2... maybe we need a small table of supported versions..
I built clad from source, reinstalled clang, and this is what I get now.
I also wanted to make sure I am using clad right -
double integrate(VehStates& v_st, const VehParam& v_params, const std::vector <double>& controls){
v_st._x = v_st._x + cos(v_st._theta)*v_st._v*v_params._step; // x update
v_st._y = v_st._y + sin(v_st._theta)*v_st._v*v_params._step; // y update
v_st._theta = v_st._theta + (tan(controls[1]) / v_params._l) * v_st._v *v_params._step; // theta update
double rGamma = v_params._R * v_params._gamma;
double f1 = v_params._tau0 * controls[2] - (v_params._tau0 * v_st._v / (v_params._omega0 * rGamma));
double f0 = v_st._v * v_params._c1 / rGamma + v_params._c0;
v_st._v = v_st._v + ((rGamma / v_params._I) * (f1 - f0))*v_params._step; // V update
return v_st._x;
}
void solve(VehStates& v_st, const VehParam& v_params, const std::vector <double>& controls){
// compute jacobian anlytically
clad::differentiate(integrate, v_st);
}
Also, side note but clad is 1.2 and clang is 14.0 now
We have released Clad v1.2 recently and we have updated the documentation how we could use it with recent clang compilers: clang++ -std=c++11 -I /full/path/to/include/ -fplugin=/full/path/to/lib/clad.so Sourcefile.cpp
. Could you re-try and let us know if that still does not work for you?
Let's close this. We have a separate issue tracking the example that failed. The current issue seems to be resolved by passing the right flags as demonstrated in the documentation.