undefined reference to `cJSON_AddStringToObject‘
学习 cJSON 时按教程引入 #include "cJSON.h"
运行报错
undefined reference to `cJSON_AddStringToObject'
D:/PATH/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/test/c++/struct.cpp:7:(.text+0x2f): undefined reference to `cJSON_AddStringToObject'
原因是测试文件是 .cpp,没有 .h 文件
所以是引入方式不对引入 cJSON.c 就好使了。
#include "cJSON.c"
