From: ernesto b. p. <eba...@gm...> - 2005-07-08 18:14:42
|
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: main.h ------ #ifdef DLL #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT __declspec(dllimport) #endif class DLLEXPORT A { public: A(); virtual ~A(); virtual const char* GetMessage(); }; class DLLEXPORT B : public A { public: B(); virtual ~B(); virtual const char* GetMessage(); }; main.cpp ---------- #include <stdio.h> #include "main.h" A::A() { printf("A constructor\n"); } A::~A() { printf("A destructor\n"); } const char* A::GetMessage() { return "Hello A world"; } B::B() { printf("B constructor\n"); } B::~B() { printf("B destructor\n"); } const char* B::GetMessage() { return "B sides are better"; } 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? ernesto |
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 |
From: Michael G. <mg...@te...> - 2005-07-08 19:34:49
|
> I wrote this post several days ago but I did not get any reply. I hope to= =20 > get some tips about my problem now. Thanks! Maybe you got no answer because noone knows it ?!? Anyway, there recently had been a thread "Linking with dlls", which started 25.06.2005 which dealt with a possibly similar problem. At least it also had to do with differences between *.o and a *.a containing all *.o -- apparently there is a "shortcoming" (lack of better word) in the way archives are handled. There have been suggestions as to how that might be solved automatically but AFAICT so far nobody has ventured to actually implement something to that end. =46or details check out said thread. Best, Michael =2D-=20 Vote against SPAM - see http://www.politik-digital.de/spam/ Michael Gerdau email: mg...@te... GPG-keys available on request or at public keyserver |
From: Danny S. <dan...@cl...> - 2005-07-08 23:49:20
|
----- Original Message ----- =46rom: "ernesto basc=F3n pantoja" > I wrote this post several days ago but I did not get any reply. I h= ope to > get some tips about my problem now. Thanks! > g++ -shared -o main.dll main.a -Wl,-output-def,main.def Look up ld.info for --whole-archive g++ -shared -o main.dll -Wl, -whole-archive ain.a -Wl, --no-whole-archive -Wl,-output-def,main.def Danny > > and it does not export any symbols, but doing a: > |
From: ernesto b. p. <eba...@gm...> - 2005-07-09 00:51:36
|
It works perfectly!!! Thanks a lot! :) ernesto "Danny Smith" <dan...@cl...> wrote in message news:002601c58417$4c74bb80$b46d65da@DANNY... ----- Original Message ----- From: "ernesto bascón pantoja" > 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! > g++ -shared -o main.dll main.a -Wl,-output-def,main.def Look up ld.info for --whole-archive g++ -shared -o main.dll -Wl, -whole-archive ain.a -Wl, --no-whole-archive -Wl,-output-def,main.def Danny > > and it does not export any symbols, but doing a: > ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ MinGW-users mailing list Min...@li... You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users |
From: Mark J. <mj...@gm...> - 2005-07-09 02:47:37
|
Danny Smith schrieb: >Look up ld.info for --whole-archive > >g++ -shared -o main.dll -Wl, -whole-archive >ain.a -Wl, --no-whole-archive -Wl,-output-def,main.def > > Great! Thank you very much for your help. Regards, Mark |