If you are using g++
, you can use g++
option -nostdlib
to avoid linking to both standard libraries AND start files automatically; and use option -nodefaultlibs
to only avoid linking to standard libraries automatically, it still will link to start files automatically.
Is it possible to avoid standard library linking in c++
-
17-07-2023 - |
Frage
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.
Lösung 2
Andere Tipps
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
.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow