Problems building dlls for use with winelib (was: spec file syntax and automated generation)
Dimitrie O. Paun
dpaun at rogers.com
Fri Aug 22 07:12:40 CDT 2003
On August 22, 2003 07:19 am, Martin Tröster wrote:
> 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
> > -DNOARRAYMACROS -DBUILD_DLL -fPIC
It's a nit, but you don't need -I/usr/include/wine and -DWIN32, these
are added automatically by winegcc.
Also, what's up with -I/ ???
> 2. relocate symbols (took this one from the makefile of advapi32.dll):
> > ld -r $(OBJS) -o libdll.tmp.so && strip --strip-unneeded libdll.tmp.so
Good. From the ld man page (about -r):
"... When linking C++ programs, this option will not
resolve references to constructors; to do that, use -Ur."
Is your app C++?
> 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
Looks fine.
> Finally, I (at least try to) tie everything together in a single
>
> library:
> > winegcc -shared -Wl,-soname,libdll.so -DSTRICT -D_REENTRANT
> > -L/usr/local/lib/wine -lntdll -lkernel32 -luser32 -lgdi32 -lcomdlg32
> > -lstdc++ -lcrtdll -lgcc_s -lm $(OBJS)
Hey, winegcc does not support -shared just yet. Just simulate this
line using just gcc, as we do in the tree.
> 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 ;-)
Yes, that will be very helpful, if only to show where we need to fix our
tools :)
> (1) winegcc -W -g -O0 -I/usr/include/wine -fPIC -o testlib.o -c
> testlib.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 libtest.dll.so
(5) is missing the libs, no? The rule from the tree is:
$(MODULE).so: $(MAINSPEC).o $(ALL_OBJS) Makefile.in
$(LDSHARED) $(LDDLLFLAGS) $(MAINSPEC).o $(ALL_OBJS) -o $@ -L$(DLLDIR) $(LDIMPORTS:%=-l%) $(ALL_LIBS) -lc
where ALL_LIBS is:
ALL_LIBS = $(LIBWINE) $(EXTRALIBS) $(LIBPORT) $(LDFLAGS) $(LIBS)
So I guess at a minimum you need to add:
-L/usr/local/lib -lwine -lm -lc
But to be on the safe side, add:
-lwine -lwine_port -lwine_unicode -lwine_uuid -lm -lc
plus all the imports!
--
Dimi.
More information about the wine-devel
mailing list