As is well-known, when we compile and link c++ programs, the standard library is linked in automatically. Is it possible to avoid this? I've written my own native library and I want to link it only.
2 Answers
Yes, it is possible, at least if you are using Visual Studio C++ or g++.
Compiler Options
If you use Visual Studio C++, lookup the option /X
If you use g++, lookup the option -nostdinc++.
Linker Options
If you use Visual Studio C++, lookup the option /NODEFAULTLIB.
If you use g++, lookup the option -nostdlib.
2 Comments
ManuelAtWork
For the compiler, it is
-nostdinc++ for g++ and /X in MSVC.R Sahu
@ManuelAtWork, thanks for the additional info.
-nostdlibto the C++ compiler.-nostdlibis what you're looking for. To make sure that you're not bringing in any dependency without knowing, you may also want to use-nostdinc, which will tell the compiler to not look for stdlib headers.