Problems building dlls for use with winelib (was: spec file syntax and automated generation)

Martin Tröster troymcclure at
Fri Aug 22 06:19:58 CDT 2003

Hi Jon,

On Thu, 21 Aug 2003 02:34:00 -0700 (PDT)
Jon Griffiths <jon_p_griffiths at> wrote:

> wine-devel is the place for any development issues, including
> problems with Winelib. Since someone may have the same
> problem(s) in the future, I'm also sending this to wine-devel
> (it serves as an issues archive for common problems).

Allright, I thought wine-devel was more concerned with internal
development, not the development of winelib-applications as well.
Perhaps you could put that on the description of the wine-devel mailing
list on WineHQ? Suggesting issues regarding, I would
like you to add datestamps and/or version numbers to any documentation.

Since I did not get any responses to my questions on wine-users, I post
the problems of building winelib-dlls again here. Hopefully someone of
you can give me a hint what exactly I'm doing wrong. I suppose it's
something basic, but I'm currently stuck with this problem.

So here we go:

Begin forwarded message:

Date: Tue, 19 Aug 2003 11:41:36 +0200
From: Martin Troester <TroyMcClure at>
To: wine-users at
Subject: Problems building dlls for use with winelib


I am currently having trouble building the DLLs of an application ported
from Win32 to Winelib - compiling, thanks to some hints from Dimi O.
Paun, now works fine, only(?) the final linking step fails. Since
Winelib-documentation is unfortunately pretty outdated, I tried to
orientate myself on the makefiles of the Winelib dlls in the cvs
/wine/dlls/ directory. I tried the following build-steps:

1. Build all object files with winegcc/wineg++ and the following flags:
> -W -g -O0 -I/ -I/usr/include/wine -D_DEBUG -DWIN32 -D_WINDOWS

2. relocate symbols (took this one from the makefile of advapi32.dll):
> ld -r $(OBJS) -o && strip --strip-unneeded

3. build spec file with the previously generated temporary library, the
imported libraries from winelib and with a spec-file containing the
functions to be exported from the dll and compile it (omitted here)
with the same flags as used above for the original source files:
> winebuild -fPIC -L/usr/local/lib/wine -lntdll -lkernel32 -luser32
> -lgdi32-lcomdlg32 -lcrtdll  -o libdll.spec.c --spec libdll.spec
> libdll.temp.o

Finally, I (at least try to) tie everything together in a single

> winegcc -shared -Wl,-soname, -DSTRICT -D_REENTRANT
> -L/usr/local/lib/wine -lntdll -lkernel32 -luser32 -lgdi32 -lcomdlg32
> -lstdc++ -lcrtdll -lgcc_s -lm $(OBJS)

The result is the following warnings and errors:

> (1) libdll.spec.o(.rodata+0x0): multiple definition of `dllname'
>     /tmp/wappX6tcsm.spec.o(.rodata+0x0): first defined here

> (2) /usr/bin/ld: Warning: size of symbol `dllname' changed from 10 in
>     /tmp/wappX6tcsm.spec.o to 12 in

> (3) /tmp/wappX6tcsm.spec.o(.text+0x1004a): In function
>     `__wine_exe_main':: undefined reference to `main'

Regarding (1) and (2): I cannot make a sense on why I should have made a
mistake here - it seems as if we have two spec-files here, one generated
by myself, and one automatically (the one in /tmp/wapp*.spec.o). Why's
this happening? And why are we coping with a __wine_exe_main in (3)? I
am trying to build a dll, so something's going totally wrong here...

Thinking about problems with the spec-file, I replaced my self-written
file with functions to be exported with an entirely empty one. However,
the errors stay the same.

Furthermore, I thought I had to use --entry as an option to specify my
special entry point (do I still have to change it from dllmain on Win32
to a unique name for Linux/Unix to avoid duplicate names in libraries,
or does winebuild handle this somehow?). Using or not using it does not
make any difference...

You see, I am a little bit desperate about this thing, having come
pretty far, but now seeming to fail on the last meters. So any help (on
this list or if you think it's too specific to my private mail) would be
really, really appreciated. If I find some time, I will volunteer to
write a short step-by-step guide based on my observations, if this is
any help for you to avoid dumb questions like these ;-)


Begin forwarded message:

Date: Tue, 19 Aug 2003 12:47:11 +0200
From: Martin Troester <TroyMcClure at>
To: wine-users at
Subject: Re: Problems building dlls for use with winelib

To simplify the problem, I just created a really simple DLL, just
exporting one function:

============ testlib.c ==============
void tstfunc (void);

void tstfunc (void)
  int a=7;
  //printf ("Hello\n");

The testlib.spec file exports this function the following way:

========== testlib.spec =============
@ stdcall tstfunc() tstfunc

Compiling it like explained before, this is what happens (in this case
no .exe is assumed, but it still fails, and I do not know why...)

(1) winegcc -W -g -O0 -I/usr/include/wine -fPIC  -o testlib.o -c
(2) ld -r testlib.o  -o libtest.dll.temp.o
(3) strip --strip-unneeded libtest.dll.temp.o
(4) winebuild -fPIC -o testlib.spec.c --spec testlib.spec
	libtest.dll.temp.o winegcc -W -g -O0 -I/usr/include/wine
	-o testlib.spec.o -c testlib.spec.c 
(5) gcc -shared  -Wl,-Bsymbolic,-z,defs
	testlib.o  testlib.spec.o -o

(OUTPUT) testlib.spec.o(.text+0x1002d): In function
	 undefined reference to `__wine_dll_register' 
	 collect2: ld returned 1
	 exit status make: *** [] Error 1

Once again, neither changing the spec-file (removing the function from
being exported) nor adding tstfunc as an entry-point changes anything...

Thus, I assume I am getting something very basic wrong here. Since this
may be of some help in the actual dll building, I would again appreciate
any hints on solving these errors...


Die sicherste Form der Kommunikation: E-Mails verschluesseln, Spam-Filter,
Adressverifizierung, digitale Unterschrift:

More information about the wine-devel mailing list