top of page

Final linking and getting .exe file

  • Фото автора: Алексей Захаров
    Алексей Захаров
  • 4 янв. 2016 г.
  • 3 мин. чтения

I completed compiling of Wine, and now I started linking. As you may predict, it don't work lol.

Many, many unresolved imports. In the end of console output we can see imports from if1632.o.

So it is nesessary to link if1632.o correctly.

1. First of all, we need to create files callfrom16.s, callfrom32.s, callto16.s, callto32.s (first and second renamed to callfr16.s and callfr32.s to fil 8.3 model).

The most correct way of doing this is to build wine-960811 in real Linux. Damn Small Linux was good enough for it (it has GCC 2.95). Install it somewhere in VirtualBox and take files callfrom16.s, callto16.s, callfrom32.s, callto32.s when they will be ready.

2. Next, we need to deal with external symbols from file except.s. There are some #define constants, which may not be correctly preprocessed. So move these constants into separare *.c file (for example, constexc.c). Next, transform them from #define to const int. For example, string "#define foo 1" should be "const int foo = 1;". Compile constecx.c: "gcc -c -o constecx.o constexc.c".

3. In file except.s we need to declare all variables from point #2 as externals. Don't forget to add leading underscore (example string, there should be much more of similar):

.extern _CONTEXT_SegSs

Also, add leading _ to every place where this symbol is using.

4. Finally, link if1632.o with this batch file:

@ld -r dummy.o relay.o thunk.o advapi32.o comctl32.o comdlg32.o commdlg.o compobj.o crtdll.o ddeml.o -o if1632a.o @ld -r gdi.o gdi32.o kernel.o kernel32.o keyboard.o lz32.o -o if1632b.o @ld -r lzexpand.o mmsystem.o mouse.o ntdll.o ole2.o -o if1632c.o @ld -r ole2conv.o ole2disp.o ole2nls.o ole2prox.o ole32.o olecli.o olesvr.o shell.o shell32.o sound.o -o if1632d.o @ld -r storage.o stress.o system.o toolhelp.o user.o user32.o ver.o version.o w32sys.o win87em.o -o if1632e.o @ld -r winmm.o winsock.o winspool.o wprocs.o wsock32.o except.o -o if1632f.o @ld -r callfr32.o callto16.o callto32.o callfr16.o contextr.o -o if1632g.o @ld -r if1632a.o if1632b.o if1632c.o if1632d.o if1632e.o if1632f.o if1632g.o -o if1632.o @del if1632a.o if1632b.o if1632c.o if1632d.o if1632e.o if1632f.o if1632g.o

Linking of if1632.o should be done. So it is possible to do final linking now. And now we again meet with problems.

__IOR and __IOW undefined (module debugger.o). Solution: #include <emx_add.h> in /debugger/editline.c.

Only many errors connected with X* functions remained. I think, it is possible to implement them as a stubs, because to test Wine it will be enough to run console apps in beginning. So look for Xlib stub library here: http://likhach-umnik.wix.com/winedos#!Downloadable-files-and-useful-links/cgla/56881f9b0cf23a10fe3d085b (copy it to *EMXROOT*/lib directory).

Other problems are functions ntohs, htons, msgget, msgsnd and some other. They are required by misc.o. To correct this error, you need to include file sys/params.h: #include <sys/param.h> to misc/winsock.c. But this corrects not all errors.

Functions msgrcv, msgget, msgsnd, msgctl are not implemented in EMX, DJGPP or emx_add.a library. Because they are required only by winsock, it is possible to stub them. So find their prototypes somewhere, add into emx_add.h, make a file with their stubs as in example:

int msgget(key_t key, int msgflg) { return 0; }

For types key_t and structs msgbuf, msqid_ds you should include two files in emx_add.h:

#include <sys/ipc.h> #include <sys/msg.h>

Write prototypes of functions msgrcv, msgget, msgsnd, msgctl inside /* NETWORK */ block in file emx_add.h (just for readable structure of file). Run "gmake" (or "make") and copy file emx_add.h to *EMXROOT*\include, emx_add.a - to *EMXROOT*\lib.

And so we have only two unresolved imports remaining: XGetSubImage and XConfigureWindow. Add these functions to Xlib stub library, run build.bat, copy just xlib.a to *EMXROOT*/lib (no need to copy any header files, they already present).

For me, symbol XGetSubImage remained unresolved. This happened because of name mangling. There are no way disable it. To remove it from certain function (this applies to any function, not only to this), find its prototype and correct head of your functions right as in prototype. Words like "const" are important! Functions int foo(const char *s) and int foo(char *s) are different and will have name mangling!

After correcting all errors, wine compiled successfully! I could see help strings (see screenshot). Let's try!

 
 
 

Comments


Subscribe to news

Yeah :) You are with me now!

  • Black Facebook Icon
  • Black Twitter Icon
  • Black Pinterest Icon
  • Black Flickr Icon
  • Black Instagram Icon

© 2015-2016 by Alexey Zakharov (Napoleon80386). Proudly created with Wix.com

bottom of page