From: Mark J. <mj...@gm...> - 2005-07-08 18:25:52
|
"ernesto basc��������������������������������" schrieb: >I wrote this post several days ago but I did not get any reply. I hope to >get some tips about my problem now. Thanks! > >I created this very small program: > > [..] >I compiled it using: > >g++ -c main.cpp -DDLL >ar -r main.a main.o >g++ -shared -o main.dll main.a -Wl,-output-def,main.def > >and it does not export any symbols, but doing a: > >g++ -shared -o main.dll main.o -Wl,-output-def,main.def > >publishes everything perfectly. > >Any ideas? > > I guess it's a problem similar to another one I've found. My assumption is that every module stored in a library will only become part of the output when it's accessed directly from an object. The problem I had seems to be similar: Every static constructor at global scope stored in an archive will not be linked into the output. Example: a.cpp: #include <stdio.h> class PrintMeBeforeMain { public: PrintMeBeforeMain(void) { printf("This comes from 'PrintMeBeforeMain'\n"); } }; static PrintMeBeforeMain print_me_before_main; main.cpp #include <stdio.h> int main(int argc, char **argv) { printf("This output comes from the 'main' function\n"); return 0; } g++ -o a.o a.cpp ar ru libtest.a a.o g++ -o test_app.exe main.cpp -L. -ltest ./test_app Output: This output comes from the 'main' function This is really annoying. It doesn't help if you specify the libtest.a directly after main.cpp. Maybe s/o knows a work-around? Regards, Mark |