前提

  • VC++(改用其他编译器,下面的Makefile需要改成对应的)
  • cmake

编译

  • 下载官网

  • 解压,在根目录新建build目录

  • [可选]debug库添加d后缀

    编辑根目录下CMakelists.txt,添加一行

    SET(CMAKE_DEBUG_POSTFIX d)
    
  • cd build

  • 生成makefile

    • shared-debug

      cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=ON -DCMAKE_INSTALL_PREFIX=./jsoncpp-0.7.0-shared-debug -G "NMake Makefiles" ..
      
    • shared-release

      cmake -DCMAKE_BUILD_TYPE=release -DJSONCPP_LIB_BUILD_SHARED=ON -DCMAKE_INSTALL_PREFIX=./jsoncpp-0.7.0-shared-release -G "NMake Makefiles" ..
      
    • static-debug

      cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=./jsoncpp-0.7.0-static-debug -G "NMake Makefiles" ..
      
    • static-release

      cmake -DCMAKE_BUILD_TYPE=release -DJSONCPP_LIB_BUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=./jsoncpp-0.7.0-static-release -G "NMake Makefiles" ..
      
  • 编译

    nmake
    
  • 安装

    nmake install
    
  • 生成doxygen文档

    python doxybuild.py --doxygen="d:\Program Files\doxygen\bin\doxygen.EXE" --open
    

问题

  • 为什么使用nmake(/MT)和vs2010(/MD)编译链接的C运行库版本不一致?

参考

  1. https://github.com/open-source-parsers/jsoncpp

留言