Julia call c++, could not load symbol

The C++ compiler will mangle that name. When I run nm debug.so, I see something like:

0000000000003f30 T __Z4showPi
0000000000003f80 T __Z5hellov
                 U _printf

You need to use extern "C" to have C++ create a symbol that is C compatible. Just add this:

extern "C" {
void show(int*);
}

See: What is the effect of extern "C" in C++? - Stack Overflow

4 Likes