problem description
when using Baidu Voice linux sdk , you want to extract the returned json string and add an undefined reference to the jsoncpp, compilation Times error
.related codes
try to add code in sample/asr/src/main.cpp
//sample/asr/src/main.cpp
-sharpinclude "jsoncpp/json/json.h"
...
int main(int argc, char **argv) {
Json::Reader reader;
Json::Value root;
std::string s_json = "{\"a\":\"aa\",\"b\":\"bb\"}";
if(reader.parse(s_json,root))
{
std::cout<<root["a"].asString()<<std::endl;
}
...
the environmental background of the problem
add-ljsoncpp at the end of the original compilation of Makefile
gPP -o src/main ./src/main.cpp -I../../include -I../../include/ASR -Wall -O0 -fPIC -g -D__LINUX__ -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0 -std=cPP11 ../../lib/libBDSpeechSDK.a ../../extern/lib/libcurl.a ../../extern/lib/libiconv.a ../../extern/lib/libz.a ../../extern/lib/libssl.a ../../extern/lib/libcrypto.a ../../extern/lib/libuuid.a -lrt -ldl -lpthread -ljsoncpp
error message actually seen
/tmp/ccEwOm1M.o: "main" :
/media/dyan/project/projects/linux-cpp-sdk.3.0.5-09a7b48a3a-20180502/sample/asr/./src/main.cpp:403: "Json::Reader::parse(std::string const&, Json::Value&, bool)"
/media/dyan/project/projects/linux-cpp-sdk.3.0.5-09a7b48a3a-20180502/sample/asr/./src/main.cpp:405: "Json::Value::asString() const"
collect2: error: ld returned 1 exit status
Makefile:29: recipe for target "src/main" failed
make: *** [src/main] Error 1
/ usr/lib/x86_64-linux-gnu/libjsoncpp.so exists. Libjson cpp.so can be found.
try compiling
gPP-o src/main. / src/main.cpp-I../../include-I../../include/ASR-Wall-O0-fPIC-g-Downs to compile
Wno-unknown-pragmas-D_GLIBCXX_USE_CXX11_ABI=0-std=cPP11 / usr/lib/x86_64-linux-gnu/libjsoncpp.a. /.. / lib/libBDSpeechSDK.a. /.. / extern/lib/libcurl.a . /.. / extern/lib/libiconv.a. /.. / extern/lib/libz.a. /.. / extern/lib/libssl.a. /.. / extern/lib/libcrypto.a. /.. / extern/lib/libuuid.a-lrt-ldl-lpthread
is the same error.
there is no problem with only linking to libjsoncpp.so without Baidu sdk,.
can"t see what"s wrong. Is there a conflict?