有很多线程有类似的问题,但很多线程处理c ++代码并且有c ++解决方案。但是,根据我在各种线程上收集的内容,当gcc尝试链接库时,我可能会错过一个库。
我不知道我需要包含哪个库,因为JSON1可以成功构建。
要加载SQLite扩展程序,其official instructions on the Mac为:
gcc -g -fPIC -dynamiclib YourCode.c -o YourCode.dylib
所以我做了:
$ gcc -g -fPIC -dynamiclib sqlite-src-3180000/ext/misc/json1.c -o json1
sqlite-src-3180000/ext/misc/json1.c:344:11: warning: implicit declaration of function
'sqlite3_value_subtype' is invalid in C99 [-Wimplicit-function-declaration]
if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){
^
sqlite-src-3180000/ext/misc/json1.c:501:3: warning: implicit declaration of function
'sqlite3_result_subtype' is invalid in C99 [-Wimplicit-function-declaration]
sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
^
2 warnings generated.
Undefined symbols for architecture x86_64:
"_sqlite3_result_subtype", referenced from:
_jsonArrayFunc in json1-5de683.o
_jsonExtractFunc in json1-5de683.o
_jsonObjectFunc in json1-5de683.o
_jsonQuoteFunc in json1-5de683.o
_jsonArrayFinal in json1-5de683.o
_jsonObjectFinal in json1-5de683.o
_jsonReturnJson in json1-5de683.o
...
"_sqlite3_value_subtype", referenced from:
_jsonAppendValue in json1-5de683.o
"_sqlite3_vsnprintf", referenced from:
_jsonPrintf in json1-5de683.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我错过了什么?
这是我的gcc详细信息,如果它有帮助:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin