- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Can't find external C library
Can't find external C library
Can't find external C library
Hi,
I am trying to call a library ext_lib.o written in C with the following:
function ext_funcname
input Integer n;
output Integer result;
external "C" result = funcname(n);
annotation(Library = "ext_lib");
end ext_funcname;
While trying to compuile to simulate, I get the following error:
L"/usr/lib/omc" -L"/usr/lib" -Wl,-rpath,"/usr/lib/omc" -Wl,-rpath,"/usr/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -lSimulationRuntimeC -llapack -lblas -lm -lgc -lpthread -rdynamic
/usr/bin/ld: cannot find -lext_lib
collect2: error: ld returned 1 exit status
make: *** [omc_main_target] Fehler 1
Compilation process exited with code 2
The ext_lib.o and the .mo where the function is called are in the same folder, why can't the compiler find the external C function?
Thank you!
Re: Can't find external C library
An o-file is not a library. You need to make it an a-file called libext_lib.a and put it in the Resources/Library folder of the package. The alternative is to use the Include annotation and write the C-code directly in the mo-file.
- sjoelund.se
- 1700 Posts
Re: Can't find external C library
You can use "ar" to archive .o files inside a library:
Code:
ar -ru libext_lib.a ext_lib.o
- adrpo
- 885 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Can't find external C library