2021年4月10日星期六

How to compile a C++ file with the -static flag?

I am trying to compile my C++ file like this:

g++ -g -O2 -std=gnu++17 -static sol.cpp

But, I get the following error:

ld: library not found for -lcrt0.o  clang: error: linker command failed with exit code 1 (use -v to see invocation)  

If I remove the -static flag the error goes away, but I can't find the error source. My operating system is macOS.

https://stackoverflow.com/questions/67041080/how-to-compile-a-c-file-with-the-static-flag April 11, 2021 at 11:04AM

没有评论:

发表评论