I am having some problems with this: I need to write a C wrapper for a C++ library. Say I have 3 files:
- wrapper.h - typedef struct Foo Foo; Foo* create_foo();
- wrapper.cpp - extern "C" { #include "wrapper.h" } #include "foo.h" Foo* create_foo() { return new Foo; }
- foo.h - class Foo { public: Foo(); };
This compiles fine:
clang++ -std=c++14 wrapper.cpp foo.h wrapper.h -shared -fPIC
clang++ -shared -o libbindings.so a.out
but when compiling the program that uses the C wrapper (it is compiler and linked by the programming language that uses the wrapper - Crystal), I get an undefined reference to create_foo() and a linker error collect2: error: ld returned 1 exit status. How can I debug this (and what am I doing wrong)?
 
     
     
    