RE: [gambit-list] Linking to C++ problems
Hi Marc, I've done more investigation in the DLL problem and I've tried a lot of things, different compilation switches but I cannot make it work. I would really appreciate any suggestion you might have. It goes like this: Using the g++ (mingw) compiler I compiled both the program and Gambit runtime. If I replace the Scheme call with the equivalent C implementation (without going through the Gambit runtime) in all scenarios (console or graphical interface) works fine when loading the DLL. If I call a Scheme method in a small console program it works fine. I assume that happens because the DLL is loaded at a lower memory address and the pointers in the scheme method are valid. If however I use a graphical interface test program, the DLL gets loaded at a higher memory location and I get "Segmentation fault" inside the scheme code. It seems that some pointers inside Gambit runtime are invalid but I don't know why this happens. This is the error: Program received signal SIGSEGV, Segmentation fault. 0x6abc123a in pluginEntry () from c:\compile\fox-1.4.2\tests\test.dll (gdb) bt #0 0x6abc123a in pluginEntry () from c:\compile\fox-1.4.2\tests\test.dll #1 0x6abc11b5 in entryPoint@4 () from c:\compile\fox-1.4.2\tests\test.dll #2 0x004013fc in main () And this is the code I use: extern void pluginEntry(EXNOTE*); #define ___VERSION 40062 #include "gambit.h" #define SCHEME_LIBRARY_LINKER ____20_testscm__ ___BEGIN_C_LINKAGE extern ___mod_or_lnk SCHEME_LIBRARY_LINKER (___global_state_struct*); ___END_C_LINKAGE CALLBACK void entryPoint(EXNOTE* note1) { ___setup_params_struct setup_params; ___setup_params_reset (&setup_params); setup_params.version = ___VERSION; setup_params.linker = SCHEME_LIBRARY_LINKER; ___setup (&setup_params); pluginEntry(note1); ___cleanup (); } (c-define-type EXNOTE* (pointer "EXNOTE")) (c-define (pluginEntry x) (EXNOTE*) void "pluginEntry" "" (write x)) Thank you, Dan. -----Original Message----- From: Marc Feeley [mailto:feeley@IRO.UMontreal.CA] Sent: Monday, February 21, 2005 5:55 PM To: dhristodorescu@borderfree.com Cc: gambit-list@IRO.UMontreal.CA Subject: Re: [gambit-list] Linking to C++ problems
Sorry to replay to my own message but I figure out what was the = problem. It was just the mangling of DLL exported symbols (I was referring a = wrong name); it works fine now.
Great.
The only relevant part of the message that remains is the one about the extern "C" generation.
I don't understand your point here. You should either compile the whole Gambit runtime system and your program with a C compiler, or with a C++ compiler, and then the names will be mangled appropriately. Are you mixing C and C++ code? (this is a bad idea in general because of the way exceptions are handled....) Marc
Afficher les réponses par date
participants (1)
-
Dan Hristodorescu