2

I'm trying to utilize a C++ library in Modelica. Modelica compilers generate c from Modelica source and then invokes a c compiler to create an executable. Modelica provides a mechanism to call c functions. I've created a wrapper:

//myWrapper.cpp
#include "headers_of_cpp_library.h"

extern "C" double call_a_cpp_fn(double a, double b){
    return cpp_fn(a,b);
}

External C code is either linked dynamically to the Modelica executable or if the code is pure c, it can be compiled right with the generated c. The only option I have here is to go the dynamic link route. Here's the Makefile for building the C++ library

all: myWrapper.cpp
        clang++ -fPIC -shared -LaCppLib -o libmywrappedcpp.so myWrapper.cpp

When I run the Modelica compiler I get some link errors that due to the fact that there are c++ libraries that need to be dynamically linked.

undefined reference to symbol '__cxa_free_exception@@CXXABI_1.3'

Is there a way to build libmywrappedcpp.so so that the c compiler invoked by the Modelica system won't have to try to link c++?

4

0 に答える 0