I want to build a c++ executable such that all the libraries also get attached to the executable. What is the method of building such an executable? So, that whenever I compile my code using g++ on some other PC (running Ubuntu), it does not need the libraries needed for the running of that executable.
Asked
Active
Viewed 149 times
0
-
sounds like you would need to use static linking http://stackoverflow.com/questions/6578484/telling-gcc-directly-to-link-a-library-statically – gda2004 Apr 09 '14 at 11:31
-
1Under which environnment ? Windows, Linux, Mac, ... ? – Jabberwocky Apr 09 '14 at 11:34
-
You still have to make sure that the target OS ABI is compatible. – Mike DeSimone Apr 09 '14 at 11:35
-
1You do not "run [your] executable using g++". You *compile* and *link* using `g++` to *get* an executable that you run. – Some programmer dude Apr 09 '14 at 11:48
1 Answers
3
What you mean is called static linking. Please have a look at this tutorial:
https://sites.google.com/site/malvanos/tutorials/static-linking-with-gcc

Rob
- 11,492
- 14
- 59
- 94