- Index
- » Programming
- » Modelica Language
- » Linking C code that calls external...
Linking C code that calls external library with OpenModelica
Linking C code that calls external library with OpenModelica
Hi Modelica Gurus around the earth,
I am trying to linking my C code that calls external library, namely GLPK (GNU Linear Programming Kit) with my Modelica model.
The C code works just fine, I have tested it in a stand alone condition.
gcc standalonecode.c -lglpk -o standalonecode
When I plugged in the external C function with my Modelica models, I started to get this error:
Code:
/usr/bin/../lib/x86_64-linux-gnu/omc/libModelicaExternalC.a(ModelicaInternal.o): In function `ModelicaInternal_temporaryFileName':
(.text+0x571): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/bin/../lib/x86_64-linux-gnu/omc/libModelicaMatIO.a(ModelicaMatIO.o): In function `Mat_VarDelete':
(.text+0x1e14): warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp'
examples.SimpleSystemOptimalDispatch_functions.o: In function `st_linprog':
examples.SimpleSystemOptimalDispatch_functions.c:(.text+0x8b1): undefined reference to `glp_create_prob'
examples.SimpleSystemOptimalDispatch_functions.c:(.text+0x8c1): undefined reference to `glp_set_obj_dir'
....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I believe that it comes from the linking process. Do you guys know how to solve this linking problem? Thanks!
Cheers,
Phil
Re: Linking C code that calls external library with OpenModelica
How does your Modelica function that calls the C looks like?
Did you give the library name via the external annotation?
- adrpo
- 885 Posts
Re: Linking C code that calls external library with OpenModelica
Hi Philgun,
I saw your PM.
as adrpo said, we have to see your Modelica code that call the C function, especially the annotation, otherwise very little can be said.
Also please check the section 12.9.4 Annotations for External Libraries and Include Files of Modelica Specifications Modelica Documents.
You will find useful hints.
- DarioMangoni
- 45 Posts
Re: Linking C code that calls external library with OpenModelica
- adrpo
- 885 Posts
Re: Linking C code that calls external library with OpenModelica
Hi guys,
Thanks for your reply. I do appreciate it. I managed to overcome the problem. The solution is in
https://stackoverflow.com/questions/626 … al-library
Thanks a lot!
- Index
- » Programming
- » Modelica Language
- » Linking C code that calls external...