Im using ctypes following this example with cmake and gcc -fPIC.
#include <iostream>
class Foo {
public:
    void bar() {
        std::cout << "fooo" << std::endl;
    }
};
extern "C" {
    Foo* Foo_new() {
        return new Foo();
    }
    void Foo_bar(Foo* foo) {
        foo->bar();
    }
}
This compiles with the following cmake script:
set(CMAKE_CXX_STANDARD 11)
SET(SOURCES
        foo.cpp)
add_library(foo SHARED ${SOURCES})
However, if I add another static library from my project (target_link_libraries(foo otherlib)) I get errors from ctypes:
from ctypes import cdll
lib = cdll.LoadLibrary("./libfood.so")
lib.Foo_new()
>> AttributeError: ./libfood.so: undefined symbol: Foo_new
However I am only linking the other library, im not actually using it. Also nm says the symbol is defined:
$ nm libfood.so | grep Foo_new
000000000002650a T Foo_new
Also I noticed that with other static libraries this works fine, so my guess is that there is a problem with my static library. How do find out whats wrong with it?
