如需使用window静态库编译,需修改CMakeList以及build.bat,具体可以参考下面的方法。
修改CMakeList
Sample_AVAPIs project(AVAPIs_Sample) cmake_minimum_required(VERSION 2.8) add_definitions( -DIOTC_STATIC_LIB ) #set(ROOT_DIR "${CMAKE_SOURCE_DIR}/../../../") include_directories(${ROOT_DIR}/Include) include_directories(${CMAKE_SOURCE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/extension) find_library(AVAPIs_sT AVAPIs_sT HINTS ${LIB_DIR}) find_library(IOTCAPIs_sT IOTCAPIs_sT HINTS ${LIB_DIR}) find_library(json-c json-c HINTS ${LIB_DIR}) find_library(libcurl libcurl HINTS ${LIB_DIR}) find_library(libcrypto libcrypto HINTS ${LIB_DIR}) find_library(zlibstatic zlibstatic HINTS ${LIB_DIR}) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIR}") SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIR}") SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIR}") SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIR}") add_executable(AVAPIs_Client AVAPIs_Client.c extension/demoOption/demoOption.c) target_link_libraries(AVAPIs_Client AVAPIs_sT IOTCAPIs_sT json-c libcurl libcrypto libssl Crypt32 legacy_stdio_definitions Ws2_32 winmm wldap32) Sample_IOTCAPIs project(IOTCAPIs_Sample) cmake_minimum_required(VERSION 2.8) add_definitions( -DIOTC_STATIC_LIB ) #set(ROOT_DIR "${CMAKE_SOURCE_DIR}/../../../") include_directories(${ROOT_DIR}/Include) include_directories(${CMAKE_SOURCE_DIR}) find_library(IOTCAPIs_sT IOTCAPIs_sT HINTS ${LIB_DIR}) find_library(json-c json-c HINTS ${LIB_DIR}) find_library(libcurl libcurl HINTS ${LIB_DIR}) find_library(libcrypto libcrypto HINTS ${LIB_DIR}) find_library(zlibstatic zlibstatic HINTS ${LIB_DIR}) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIR}") SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIR}") SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIR}") SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIR}") add_executable(IOTCAPIs_Device IOTCAPIs_Device.c) target_link_libraries(IOTCAPIs_Device IOTCAPIs_sT json-c libcurl libcrypto libssl Crypt32 legacy_stdio_definitions Ws2_32 winmm wldap32) add_executable(IOTCAPIs_Client IOTCAPIs_Client.c) target_link_libraries(IOTCAPIs_Client IOTCAPIs_sT json-c libcurl libcrypto libssl Crypt32 legacy_stdio_definitions Ws2_32 winmm wldap32)
修改build.bat
需将
set LibDir=%RootDir%\Lib\Windows\x64\Release\
修改为:
set LibDir=%RootDir%\Lib\Windows\x64\Release_Static\
完整的脚本: