Mail Archives: cygwin/1997/01/22/03:57:10
Fabrice Beauvir[SMTP:fabeau AT hexale DOT fdn DOT fr] wrote:
>hi all,
>
> I am looking for some info about building dll with dlltool.
There is a file called "building-dlls.txt" explaining how to build
DLLs with GNU-Win32 both at:
http://www.fu.is.saga-u.ac.jp/~colin/building-dlls.txt
and:
http://www.cygnus.com/misc/gnu-win32/building-dlls.txt
>-----------------------------------------------------
>LDLIB = -lc -lcygwin -luser32 -lgdi32
>all:: foo.o foo2.o foo.exp foo.dll main.exe
>foo.o:
> gcc -c foo.c
>foo2.o:
> gcc -c foo2.c
>foo.exp:
> dlltool --def foo.def --output-exp foo.exp --dllname foo.dll --output-lib foo.a
You output library name should really be something like 'libfoo.a', not 'foo.a'.
And to make things easier to see foo.exp should probably be 'foomain.o' or
something like that.
>main.exe:
> gcc main.c -o main.exe
You should be linking libfoo.a with the executable. The library libfoo.a contains a
set of automatically generated "thunk" functions which have the names of the functions
you exported from your dll. These thunk functions in turn call the real DLL functions
dynamically linked in at run-time.
gcc main.c -o main.exe -lfoo
>foo.dll:
> ld -o foo.dll foo.exp foo.a $(LDLIB)
You should not be linking foo.a to your DLL. I think
what you need is something like this:
ld -o foo.dll foomain.o foo.o foo1.o $(LDLIB)
>-----------------------------------------------------
>
>A main.exe is generated but when I execute it , it cause a segmentation fault. Where is my fault ?
>(gdb) run main
>Starting program: /home/kerSv4/fabeau/kerSs1/pKernel/src/tmp/main.exe main
>warning: LDR: LdrpMapDll Relocating: Base Name foo.dll
>
>240000:/home/kerSv4/fabeau/kerSs1/pKernel/src/tmp/foo.dll
>10000000:/bin/cygwin.dll
It puzzles me that your main (as generated by the above makefile) would contain
any reference to foo.dll at all. I cannot see where the compilation of main
could have determined that it needed foo.dll from. On the other hand, it also
puzzles me that it would link without an import library containing the
necessary functions to be imported from the DLL.
In any case you should probably figure out how to relocate the base of foo.dll
or you will take a performance hit. This is not a top priority of course.
>gdb: unknown target exception 0xc0000135 at 0x77fa0309
>
>Program received signal SIGSEGV, Segmentation fault.
>0x40b4 in ?? ()
>(gdb)
>-----------------------------------------------------------------------
>I've got pop-up window : "Unable to locate dll ;"
This resembles a possibly corrupted import list error... but I really don't
know. Try fixing the basic problems with your make process above and see
what happens.
Good luck,
Colin.
-- Colin Peters - colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp
-- Saga University Dept. of Information Science
-- Fundamentals of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin/home.html
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -