프로그램 사용/gcc

g++ 은 정적 빌드가 안되나?

구차니 2021. 1. 19. 11:00

 

tensorflow lite 빌드해서 static libaray 로 libtensorflow-lite.a는 얻어냈는데

얘를 링크해서 빌드하니 dynamic link가 된다.

 

궁금해서 hello.cpp 이런거 하나 구해서 g++로 빌드하니

무조건 끌어가는 것 같긴한데

$ cat hello.cpp
// hello.cpp file
#include <iostream>
int main()
{
    std::cout << "Hello Geek\n";
    return 0;
}

$ g++ hello.cpp
$ ldd a.out
        linux-vdso.so.1 (0x7efa4000)
        /usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76f7e000)
        libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76e19000)
        libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76d97000)
        libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76d6a000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c1c000)
        /lib/ld-linux-armhf.so.3 (0x76f93000)

 

혹시나 해서 g++ -static 옵션을 주니 되긴 되네..

$ g++ hello.cpp -o b.out -static
$ ldd b.out
        not a dynamic executable