crtmpserver在linux下默认
编译构建方式为二进制+动态库的,这就导致了在gdb跟踪的时候,如果刚好要观察的函数在.so动态库中,不方便进行单步调试,因此编译为静态二进制更方便调试。
构建如下:
1.在当前终端设置环境变量export COMPILE_STATIC=1
2.在当前终端
执行cmake . -DCMAKE_BUILD_TYPE=Debug 前
ps: crtmpserver的静态编译方式可以从CMakeLists.txt 中看到
-
IF($ENV{COMPILE_STATIC} MATCHES "1")
-
MESSAGE(STATUS "Compile static")
-
ADD_DEFINITIONS(-DCOMPILE_STATIC)
-
SET(LIB_TYPE STATIC)
-
SET(LUA_LIBRARY_PATH "lua")
-
SET(LUA_INCLUDE_PATH "${CRTMPSERVER_3RDPARTY_ROOT}/lua-dev")
-
SET(TINYXML_LIBRARY_PATH "tinyxml")
-
SET(TINYXML_INCLUDE_PATH "${CRTMPSERVER_3RDPARTY_ROOT}/tinyxml")
-
ELSE($ENV{COMPILE_STATIC} MATCHES "1")
-
MESSAGE(STATUS "Compile dynamic")
-
SET(LIB_TYPE SHARED)
-
│
-
INCLUDE(cmake_find_modules/Find_lua.cmake)
-
IF(NOT LUA_FOUND) │
-
ADD_SUBDIRECTORY(lua lua)
-
ENDIF(NOT LUA_FOUND)
-
│
-
INCLUDE(cmake_find_modules/Find_tinyxml.cmake)
-
IF(NOT TINYXML_FOUND)
-
ADD_SUBDIRECTORY(tinyxml tinyxml)
-
ENDIF(NOT TINYXML_FOUND)
-
ENDIF($ENV{COMPILE_STATIC} MATCHES "1")
静态编译后二进制文件体积明显增大
-
-rwxr-xr-x 1 root root 16M 9月 3 17:40 crtmpserver #静态编译
-
-rwxr-xr-x 1 root root 98K 9月 3 17:22 crtmpserver #默认动态编译
阅读(158304) | 评论(0) | 转发(0) |