cmake源码静态编译

cmake源码静态编译


如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033

环境:
OS : centos 7
编译器: gcc/g++ 4.8.5

前言

cmake的源码编译速度很慢,在x86_64架构下cmake有cmake-3.17.3-Linux-x86_64.sh的通用可执行程序。那么这个程序是如何通过源码编译的呢?

1.cmake直接编译

git clone https://github.com/Kitware/CMake.git

cd CMake
./bootstrap
 make
 sudo make install
$ ldd bin/cmake
        linux-vdso.so.1 =>  (0x00007ffde6cfc000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f972a6a5000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f972a49d000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f972a281000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f9729f7a000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f9729c78000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f9729a62000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f9729695000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f972a8a9000)

2.cmake静态编译

git clone https://github.com/Kitware/CMake.git

cd CMake

vi CMakeLists.txt

增加静态设置

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

安装glibc和libstdc++的静态库

yum install glibc-static libstdc++-static

进行静态编译

./bootstrap
 make
 sudo make install

查看链接库,已经没有libstdc++.so.6和libgcc_s.so.1

$ ldd bin/cmake
        linux-vdso.so.1 =>  (0x00007ffd61da5000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f76a406c000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f76a3e64000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f76a3c48000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f76a3946000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f76a3579000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f76a4270000)

License

License under CC BY-NC-ND 4.0: 署名-非商业使用-禁止演绎

如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033


Reference:
NULL

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章