From: Timothy M. <ter...@gm...> - 2008-11-22 21:28:29
|
Hello I have this problem I do not know the order libraries and object files should be specified on the linker/gcc command line. The gcc man page says symbols are searched in the files in the order given on the command line, so an object file that cames before a library can override symbols from the library. So I reach the conclusion that if an object uses a library the library should come first, and if libzip uses libz, than libz should come first. But I find that the proper order is the opposite, as I get undefined references if I use the libraries first. g++ -o prog /mingw/lib/libz.a /mingw/lib/libzip.a prog.cc prog_module.cc would give undefined references for symbols from libz and libzip, but g++ -o prog prog.cc prog_module.cc /mingw/lib/libzip.a /ming/lib/libz.a would compile and link successfully. I also tried g++ -o prog -static -static-libgcc prog.cc prog-module.cc -lzip -lz And then I get undefined references to snprintf and strtol from libstdc++.a. Do you know how can I get libzip and lz linked with -l switch to g++ ? And how do I know the correct order of libraries on the command line if I want to explicitly list the library files on the command line ? How can I see all symbols exported from an object file ? And how do I use functions in a .dll with MinGW and g++ ? For example I want to use gtk+. I do not know if it compiles with MinGW, but even if it does it looks like a complicated task with little chances of success for me, so I would like to use a pre-compiled .dll and call functions in it. How do I do this ? Thank you, Timothy Madden |