www.delorie.com/djgpp/v2faq/faq059.html | search |
| Previous | Next | Up | Top |
-lgpp -lstdcxx -lmE.g., to link files main.o and sub.o into a C++ library, use the following command line:
gcc -o main.exe main.o sub.o -lgpp -lstdcxxor, if you compile and link in one command:
gcc -o main.exe main.cc sub.cc -lgpp -lstdcxx -lmIf you have any libraries of your own, put them before the above system libraries, like this:
gcc -o main.exe main.cc sub.cc -lmylib -lgpp -lstdcxx -lmWhen you use the gxx, the gpp or g++ compilation drivers to compile a C++ program, it automatically names the C++ libraries in the correct order. (gpp and gxx are the alternative names for g++ on DOS, which doesn't allow the + character in file names.)
You can also force the linker to repeatedly scan a group of libraries until all externals are resolved. To this end, put the names of these libraries between the -( and the -) options (if you invoke GCC to link, use the -Wl or -Xlinker options to pass switches to the linker). Check out the linker docs for more info about -( ... -) groups.
If your installation tree is different from the default, i.e., if you keep the libraries not in the default lib/ subdirectory, then you should add that directory to the
line in the [gcc] section of your DJGPP.ENV file which starts with LIBRARY_PATH, or put into your environment a variable called LIBRARY_PATH
and
point it to the directory where you keep the libraries. Note that if you invoke the linker by itself (not through the gcc driver), then LIBRARY_PATH
will have no effect, because this
variable is only known to the gcc driver. So if you must call ld directly, use the -L option to tell it where to look for the libraries.
webmaster donations bookstore | delorie software privacy |
Copyright ⌐ 1998 by Eli Zaretskii | Updated Sep 1998 |
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)