ROS项目解析JSON的问题

  • Post author:
  • Post category:其他

fatal error: json/json.h: No such file or directory

sudo apt-get install libjsoncpp-dev 
sudo ln -s /usr/include/jsoncpp/json/ /usr/include/json

unsigned char*转化为string

int main(int argc,char **argv){
    //unsigned char * 转化为string
    //参考链接 https://www.itdaan.com/tw/4ff531a5e6651468a5b7c6d95927ba3d
    unsigned char *foo;
    unsigned char str[] = "Hello world";
    string strHH;
    foo = str;
    strHH.append(reinterpret_cast<const char*>(foo));
    cout << strHH << endl;
 
}

catkin_make编译不通过也不报错

解决方法:

在CMakeList.txt文件 target_link_libraries(jsoncpp ${catkin_LIBRARIES}) 加入jsoncpp 。


版权声明:本文为MCotoneaster原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。