I compile the executable file under Linux. It depends on a large number of so-libraries. Can I compile all of them into one large executable file?
2 answers
In most cases, you will have enough of such a line in the CMakeLists.txt file.
set_target_properties(your_target_name PROPERTIES LINK_FLAGS "-static" ) But just be prepared for the fact that for many you have to look for their static versions. And this may not be a trivial exercise.
Read more about other ways on SO .
- Almost all main libraries have static versions of linux distributions. They just need to be installed. Well, if they do not have it, then no one bothers to collect them on their own from the sources, which are again present in distributions. - Bwana The Master
|
First see how many dynamic libraries are loaded in the executable file.
> ldd filename Next is the compilation option when building the executable file.
> g++ -static-libstdc++ ... See the difference ... The file size will be very large, but the libraries will not decrease.
- you can get extra weight - eri
- The specified key does not connect all the libraries statically, but only one that stores runtime with ++. - KoVadim
|