Static link libstdc++ using clang

前端 未结 2 1296
离开以前
离开以前 2020-12-31 07:38

When I use GCC, I can build program on my Ubuntu 15.04 using this:

-static-libgcc -static-libstdc++

And compiled binary can run on \"stock\

2条回答
  •  清酒与你
    2020-12-31 08:20

    Instead of using -static-libstdc++ or -static-libgcc, just use clang's -static flag. It will produce a non dynamic executable, with everything it needs linked in statically.

    On my test program, it produces:

    [root@interserver ogrerobot.com]# ldd ./CppUtilsSpikes  
    not a dynamic executable
    

提交回复
热议问题