Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com From: Venkat Iyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14819.48654.198000.271875@gargle.gargle.HOWL> Date: Tue, 10 Oct 2000 18:10:38 -0700 (Pacific Daylight Time) To: cygwin AT sourceware DOT cygnus DOT com Subject: Exporting symbols from an executable Greetings, I've read everything I could (including libtool, dlltool, gcc, ld documentation, cygwin archives, and google and alltheweb searches), and still haven't managed to make this work. I want to export symbols from an executable, so that they can be used to resolve symbols at run time from dlopen'ed libraries. a.c : defines main and f1() b.c : defines f2() which uses f1(). I want to end up with a.exe and b.dll. So that when a.c dlopens b.dll, f1 is resolved. Here's all the stuff I tried. I have tried RTLD_GLOBAL, RTLD_LAZY and RTLD_NOw options. 1. Generate a library (liba.a) so that b.dll can be built using dlltool with the exe name as the dll name. 2. Link b.c with -shared liba.a so that it resolves completely. b.c does have a valid entry point. 3. Link a.c with -Wl,--export-dynamic so that all functions are exported. 4. Run a.c, but dlopen() always fails. I am using plain vanilla latest net install of cygwin. The only change being the incorrect _cygwin_dll_entry prototype fix in cygwin_dll.h If f2 (in b.c below) is defined so: int f2(){return 1;}, then the dlopen succeeds, so my build process seems to be mostly OK. Any help would be much appreciated. The commands I use are: bash$ dlltool --dllname a.exe --input-def a.def --output-lib liba.a bash$ gcc -Wl,--export-dynamic a.c -o a bash$ gcc --shared b.c -o b.dll liba.a bash$ ./a Failed Function not implemented The files are : ---a.c---- #include #include int f1(void) { return 1; } main() { void *p = dlopen(".\\b.dll", RTLD_NOW); if (p == 0) { printf("Failed\n"); printf("%s\n", strerror(errno)); } else { printf("Succeeded\n"); } } ----b.c---- #include extern int f1(void); int f2 (void) { return f1(); } DECLARE_CYGWIN_DLL(DllMain); ----a.def---- EXPORTS f1 ---------------- -- Regards _______________________________________________________________________ Venkat Iyer venkat AT comit DOT com Phone: 1-408-988-2988 x 136 Comit Systems, Inc. The Contract Engineering Company www.comit.com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com