Hi Jon,
On Thu, 21 Aug 2003 02:34:00 -0700 (PDT) Jon Griffiths jon_p_griffiths@yahoo.com 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 WineHQ.com, 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@web.de To: wine-users@winehq.com Subject: Problems building dlls for use with winelib
Hi,
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 -DNOARRAYMACROS -DBUILD_DLL -fPIC
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
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 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)
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@web.de To: wine-users@winehq.com 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 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
(OUTPUT) testlib.spec.o(.text+0x1002d): In function `__wine_spec_testlib_dll_init':/home/mt/testlib/testlib.spec.c:156: undefined reference to `__wine_dll_register' collect2: ld returned 1 exit status make: *** [libtest.dll.so] 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...
=======================================================
Cheers, Martin __________________________________________________________________________ Die sicherste Form der Kommunikation: E-Mails verschluesseln, Spam-Filter, Adressverifizierung, digitale Unterschrift: http://freemail.web.de
On August 22, 2003 07:19 am, Martin Tröster wrote:
- 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/ ???
- 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++?
- 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!