rootWIN-K3C9KG85CB8homeSmartHomeServer# gcc mainc -o mainexecusrbinld tmpccow0tYno in function handleClientRequestmainctext+0x73 undefined reference to json_tokener_parseusrbinld mainctext+0xbd undefi
这个错误是由于链接器找不到对应的函数定义引起的。在编译时,需要链接到相应的库文件才能解决这个问题。
对于json_tokener_parse、json_object_object_get_ex、json_object_get_int和json_object_put函数,需要链接到json-c库。你可以使用以下命令安装json-c库:
sudo apt-get install libjson-c-dev
对于sqlite3_open、sqlite3_prepare_v2、sqlite3_column_int、sqlite3_column_text、sqlite3_step、sqlite3_finalize和sqlite3_close函数,需要链接到sqlite3库。你可以使用以下命令安装sqlite3库:
sudo apt-get install libsqlite3-dev
安装完这两个库后,再次编译你的代码:
gcc main.c -o main.exec -ljson-c -lsqlite3
这样就可以解决链接错误了。
原文地址: https://www.cveoy.top/t/topic/iAzq 著作权归作者所有。请勿转载和采集!