Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <37DFE70A.AE6EBA2C@stest.ch> Date: Wed, 15 Sep 1999 20:35:55 +0200 From: Thomas Kowatsch Organization: Switching Test Solutions AG X-Mailer: Mozilla 4.04 [en] (X11; U; SunOS 5.5.1 sun4u) MIME-Version: 1.0 To: Cygwin List Subject: problem with 3rd party lib Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a 3rd party product which I have to use in my application. It is Sybase Open Client lib. I created the .a from .lib: ---------------------- #!/bin/sh if [ $# -ne 2 ]; then echo "usage: mkimplib " exit 1 fi if [ \! -r $1 ]; then echo "cannot read $1" exit 1 fi if [ \! -r $2 ]; then echo "cannot read $1" exit 1 fi prep=`expr "$1" : '\(...\).*'` libname=`expr "$1" : '\(.*\)\.lib'` if [ "$prep" != "lib" ]; then libname="lib"$libname fi libfile=$1 deffile=$libname.def echo "EXPORTS" > $deffile for s in `nm $libfile | grep '^........ T _' | sed 's/^........ . _//'`; do case $s in DllMain*) ;; *) echo $s ;; esac done >> $deffile dlltool -k --add-stdcall-alias --def $deffile --dllname $2 --output-lib $libname.a ------------------------ When I use the library in a program and link it to that it works ok. An example: ------------------------- ----- testit.c #include #include #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN #include #include #include main() { int ret; if ((ret = dbinit()) == FAIL) fprintf(stderr, "ERROR dbinit() failed\n"); printf("dbinit() returned %d\n", ret); return 0; } ----- % gcc -g -O2 -o testit.exe -I/c/Sybase/include testit.c -L/c/Sybase/lib -lsybdb % testit dbinit() returned 1 --------------------------- The result is as expected. If I create a shared library which is doing the stuff in main() above it fails in the dbinit() func. --------------------------- ----- xx.c #include #include int WINAPI DllEntryPoint(HANDLE h, DWORD reason, void *x) { return TRUE; } #include #include #include int Xx_Init() { int ret; printf("in Xx_Init()\n"); ret = dbinit(); printf("dbinit() returned %d\n", ret); return ret; } ----- testit3.c #include #include #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN #include #include #include #include main() { HINSTANCE handle; int (*func)(void); if ((handle = LoadLibraryA("libxx.dll")) == NULL) { fprintf(stderr, "ERROR loading lib\n"); return -1; } if ((func = (int(*)(void))GetProcAddress(handle, "Xx_Init")) == NULL) { fprintf(stderr, "ERROR finding Xx_Init()\n"); return -1; } if ((*func)() == TCL_ERROR) { fprintf(stderr, "ERROR calling dbinit()\n"); return -1; } printf("success\n"); return 0; } ----- % gcc -g -O2 -I/c/Sybase/include -c xx.c % dllwrap --export-all --output-def libxx.def --entry _DllEntryPoint AT 12 --implib libxx.a -o libxx.dll xx.o -L/c/Sybase/lib -lsybdb Warning: no export definition file provided dllwrap will create one, but may not be what you want % gcc -g -O2 -o testit3.exe -I/c/Sybase/include testit3.c -L. -lxx -L/c/Sybase/lib -lsybdb % testit3 in Xx_Init() 0 0 [main] c:\TEMP\sybtest\x\testit3.exe 2592 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION 0 15271 [main] testit3 2592 handle_exceptions: Dumping stack trace to testit3.exe.core ---------------------------- Am I'm doing something obviously wrong? Please help. Regards Tommy -- ------------------------------------------------------------------------ Thomas Kowatsch | - Senior Software Engineer - Switching Test Solutions AG | mailto: thomas DOT kowatsch AT stest DOT ch Wavetek Wandel & Goltermann Divison5 | web : http://www.stest.com Friesenbergstr. 75 | Phone : +41 1 454-6731 CH-8055 Zuerich | FAX : +41 1 454-6612 -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com