I have a python extension written in c which compiles fine however barfs
ImportError: /path/to/cmongo.so: undefined symbol: json_tokener_parse
When I try to import the module (import cmongo
) in python.
What makes this strange is the the c compiles AND RUNS fine using gcc directly:
gcc --std=c99 cmongo.h json2bson.c cmongo.c -lmongoc -ljson -o mong_test
./mong_test
# test main function prints stuff as required.
The extension worked find before adding the json2bson.c
file and calls.
Both libraries (mongoc
and json
) and the extra compiler arg --std=c99
are included in setup.py, so I'm assuming the problem is either the plethora of other arguments python passes to gcc or a need to somehow reference json-c when importing the shared libary. However this is beyond my understanding of such things.
I know external links are frowned up, but to avoid a massive question while still providing a full explanation of the problem I've put all the relevant files in a gist.