|
From: Mikael A. <mik...@te...> - 2003-09-24 13:11:41
|
Hi ! That's correct, an exe file is almost the same thing as a dll, you can use LoadLibrary to open an exe file and get symbols from it just as you would with a dll. Mikael ----- Original Message ----- From: "Gisle Vanem" <gv...@br...> To: <min...@li...> Sent: Wednesday, September 24, 2003 2:22 PM Subject: Re: [Mingw-users] DLL symbols and bloat > "Nick Craig-Wood" <nc...@ax...> said: > > > However where I am having trouble is that the drivers need to import > > functions and data from the main executable. > > > > I came to the conclusion that the main code would have to be built as > > a DLL in order to be able to export things to the drivers - is this > > correct? > > I'm not sure that's needed. An EXE can export symbols nearly as > easy as a DLL can. I used the following method in my plugin dlls: > > 1) Mark all exportable symbols in the main-exe using __declspec. > E.g. put this in some common header: > #if defined(BUILDING_PLUGIN) > #define EC_API __declspec (dllimport) > #else > #define EC_API __declspec (dllexport) > #endif > extern EC_API int foo; > extern EC_API int bar (void); > > 2) Make a .def-file of all these exportables. If they are C++ > symbols it might be more work (use a script). > > 3) Make a import library for the plugins/drivers to link with: > EC_IMPORT = ettercap.a > $(MAIN_APP) $(EC_IMPORT): $(MAIN_OBJECTS) > $(CC) -o $(MAIN_APP) $(MAIN_OBJECTS) $(LFLAGS) $(LIBS) > dlltool -l $(EC_IMPORT) -D $(MAIN_APP) -d src/ec_base.def > > 4) Compile and link the plugin/driver: > plugins/%.dll: %.c > $(CC) -o $@ $< $(CFLAGS) -DBUILDING_PLUGIN -shared $(EC_IMPORT) > > Check the .dll with the depends program if LoadLibrary() fails. > > > Another problem I'm having is that the drivers (which are C++) seem to > > import 50k of the C++ runtime library each! > > No wonder. The C++ runtime code is not in msvcrt.dll, but statically > linked from libstdc++.a. You can reduce some space by using > -fconserve-space -fno-rtti -fno-exceptions in CXXFLAGS. > > --gv > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users |