Winelib compilation problem

Questions about Wine on Linux
Locked
bburk
Level 2
Level 2
Posts: 11
Joined: Tue Mar 31, 2020 9:36 am

Winelib compilation problem

Post by bburk »

I'm trying to convert our windows application into a Linux one, and my work with Winelib was going pretty smoothly, though once I got the base Makefile down I started adding files one at a time. Most went smoothly, but hit a couple of files that I found that I needed to compile with different flags to get access to certain defines related to low-level IO.

Everything is now compiling, and we're at the linking stage... but it's missing some functions... functions that I'm not calling, but seem to be called by wine itself. Any ideas how to fix this?

Code: Select all

/opt/wine-devel/bin/../lib64/wine/libmsvcrt.a(msvcrt.hihglh.o): In function `fputs':
(.text+0x0): undefined reference to `__wine$func$msvcrt$914$fputs'
/opt/wine-devel/bin/../lib64/wine/libmsvcrt.a(msvcrt.PTNJnp.o): In function `putchar':
(.text+0x0): undefined reference to `__wine$func$msvcrt$1002$putchar'
collect2: error: ld returned 1 exit status
winegcc: gcc failed
Makefile:445: recipe for target 'xerase' failed
make: *** [xerase] Error 2
I'm thinking this may be due to the different compilation flags. Below is a truncated chunk of the build flags, makefile. Main difference is the object files I compile as .ol type, it's using CLEXTRA instead of CEXTRA (ie. no -mno-cygwin flag)


Code: Select all

proj_LDFLAGS       = -mwindows \
                     -mno-cygwin
                     
 DLL_IMPORTS           = comctl32 \
			newdev \
			netapi32 \
			ws2_32 \
			cfgmgr32 \
                        iphlpapi \
                        psapi \
                        dl \
                        pthread \
                        mysqlclient \
                        z \
                        ssl \
                        crypto \
                        atomic                    
                     
                     
CEXTRA                = -mno-cygwin
CLEXTRA               = -DRAWLINUX
CXXEXTRA              =
RCEXTRA               =


# Implicit rules

.SUFFIXES: .cpp .cxx .RC .WMC .C
DEFINCL = $(INCLUDE_PATH) $(DEFINES) $(WARNINGS) $(OPTIONS) 


# LINUX-SPECIFIC-COMPILATION get at base linux
$(OUTDIR)/%.ol: %.c
	$(CC) -c $(CFLAGS) $(CLEXTRA) $(DEFINCL) -o $@ $<
	printf '\n\n'


$(OUTDIR)/%.o: %.c
	$(CC) -c $(CFLAGS) $(CEXTRA) $(DEFINCL) -o $@ $<
	printf '\n\n'

.C.o:
	$(CC) -c $(CFLAGS) $(CEXTRA) $(DEFINCL) -o $@ $<
	printf '\n\n'

$(OUTDIR)/.WMC.o: %.WMC
	$(CC) -c $(CFLAGS) $(CEXTRA) $(DEFINCL) -o $@ $<
	printf '\n\n'

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(CXXEXTRA) $(DEFINCL) -o $@ $<
	printf '\n\n'

.cxx.o:
	$(CXX) -c $(CXXFLAGS) $(CXXEXTRA) $(DEFINCL) -o @ $<
	printf '\n\n'

$(OUTDIR)/%.res: %.RC
	$(RC) $(RCFLAGS) $(RCEXTRA)  -fo$@ $<
	printf '\n\n'

# Rules for cleaning

clean:: 
	$(RM) $(OUTDIR)/*.*


### Target specific build rules
DEFLIB = $(LIBRARY_PATH) $(LIBRARIES) $(DLL_PATH) $(DLL_IMPORTS:%=-l%)

$(proj_MODULE): $(proj_OBJS)
	$(CC) $(proj_LDFLAGS) -o $@ $(proj_OBJS) $(proj_LIBRARY_PATH) $(proj_DLL_PATH) $(DEFLIB) $(proj_DLLS:%=-l%) $(proj_LIBRARIES:%=-l%)



Ideas?
bburk
Level 2
Level 2
Posts: 11
Joined: Tue Mar 31, 2020 9:36 am

Re: Winelib compilation problem

Post by bburk »

I short circuited the problem by adding my own functions for fputs and putchar using fprintf. No idea why they weren't linking by default, but it compiles now. Now I have other problems...

The makefile is generating xerase.exe and xerase.exe.so. If I move those to the working directory and execute xerase.exe it seems to do nothing, but if I hit enter again it prints

Code: Select all

tiago@megatron:~/.wine/dosdevices/c:/XERASwin$ ./xerase.exe

[b]Not a JPEG file[/b]
tiago@megatron:~/.wine/dosdevices/c:/XERASwin$ 
The not a JPEG file message seems pretty non-sensical, but I renamed a folder in the working directory with jog files so that it couldn't load anything, and it didn't impact anything.



if I use winedbg (I THINK i'm doing this right? If there's another way to debug this, let me know) I get this:

Code: Select all

tiago@megatron:~/.wine/dosdevices/c:/XERASwin$ winedbg --gdb ./xerase.exe.so
0085:0086: create process 'C:\XERASwin\xerase.exe'/0x109a0 @0x7fc6438b8650 (0<0>)
0085:0086: create thread I @0x7fc6438b8650
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
0085:0086: loads DLL C:\windows\system32\ntdll.dll @0x7bc20000 (0<0>)
0085:0086: loads DLL C:\windows\system32\kernelbase.dll @0x7b000000 (3047424<7411>)
0085:0086: loads DLL C:\windows\system32\kernel32.dll @0x7b410000 (0<0>)
0085:0086: loads DLL C:\windows\system32\advapi32.dll @0x7fc6421f0000 (0<0>)
0085:0086: loads DLL C:\windows\system32\gdi32.dll @0x7fc642050000 (0<0>)
0085:0086: loads DLL C:\windows\system32\msvcrt.dll @0x7fc641f80000 (0<0>)
0085:0086: loads DLL C:\windows\system32\version.dll @0x65780000 (69120<778>)
0085:0086: loads DLL C:\windows\system32\user32.dll @0x7fc641d00000 (0<0>)
0085:0086: loads DLL C:\windows\system32\imm32.dll @0x6bec0000 (262656<1270>)
0085:0086: loads DLL C:\windows\system32\usp10.dll @0x62600000 (923136<1690>)
0085:0086: loads DLL C:\windows\system32\comctl32.dll @0x6e6c0000 (4756480<9165>)
0085:0086: loads DLL C:\windows\system32\rpcrt4.dll @0x6fbc0000 (2288640<5954>)
0085:0086: loads DLL C:\windows\system32\setupapi.dll @0x6a700000 (1874432<5461>)
0085:0086: loads DLL C:\windows\system32\newdev.dll @0x63100000 (59904<689>)
0085:0086: loads DLL C:\windows\system32\iphlpapi.dll @0x7fc641c70000 (0<0>)
0085:0086: loads DLL C:\windows\system32\ws2_32.dll @0x7fc641c30000 (0<0>)
0085:0086: loads DLL C:\windows\system32\netapi32.dll @0x7fc641ca0000 (0<0>)
0085:0086: loads DLL C:\windows\system32\psapi.dll @0x6acc0000 (14848<419>)
0085:0086: loads DLL C:\windows\system32\winspool.drv @0x7fc641bd0000 (0<0>)
0085:0086: loads DLL C:\windows\system32\mpr.dll @0x6d9c0000 (318976<1341>)
0085:0086: loads DLL C:\windows\system32\shlwapi.dll @0x68a40000 (1208320<7728>)
0085:0086: loads DLL C:\windows\system32\ole32.dll @0x65000000 (5959680<11058>)
0085:0086: loads DLL C:\windows\system32\shcore.dll @0x64940000 (250880<1655>)
0085:0086: loads DLL C:\windows\system32\shell32.dll @0x7fc6411a0000 (0<0>)
0085:0086: loads DLL C:\windows\system32\wininet.dll @0x6b2c0000 (2077696<3906>)
0085:0086: loads DLL C:\windows\system32\comdlg32.dll @0x6b6c0000 (2395136<5966>)
0085:0086: loads DLL C:\windows\system32\winex11.drv @0x7fc640610000 (0<0>)
0085:0086: loads DLL C:\windows\system32\uxtheme.dll @0x62140000 (587264<2133>)
warning: remote target does not support file transfer, attempting to access files from local filesystem.
0x000000007bcb2789 in DbgBreakPoint () from /opt/wine-devel/bin/../lib64/wine/ntdll.dll.so
Wine-gdb> cont
Continuing.
00000085:00000086: exit process (4294967295)
[Inferior 1 (Remote target) exited normally]
Wine-gdb> 
The program is not being run.

I'm not sure how to move forward on this.
bburk
Level 2
Level 2
Posts: 11
Joined: Tue Mar 31, 2020 9:36 am

Re: Winelib compilation problem

Post by bburk »

More insight with some different parameters after finding a debugging page:

WINEDEBUG=warn+all,-debug wine xerase.exe.so

Code: Select all

002c:warn:ntdll:FILE_CreateFile L"\\??\\C:\\windows\\system32\\c_28604.nls" not found (c0000034)
002c:warn:ntdll:FILE_CreateFile L"\\??\\Z:\\opt\\wine-devel\\bin\\..\\share\\wine\\nls\\c_28604.nls" not found (c0000034)
002c:warn:ntdll:FILE_CreateFile L"\\??\\C:\\windows\\system32\\c_28604.nls" not found (c0000034)
002c:warn:ntdll:FILE_CreateFile L"\\??\\Z:\\opt\\wine-devel\\bin\\..\\share\\wine\\nls\\c_28604.nls" not found (c0000034)
000d:warn:ver:find_version_resource Can't handle 0000 files.
000d:warn:ver:find_version_resource Can't handle 0000 files.
002c:warn:ntdll:FILE_CreateFile L"\\??\\Z:\\opt\\wine-devel\\bin\\..\\lib64\\wine\\winex11.drv" not found (c0000034)
002c:warn:keyboard:X11DRV_KEYBOARD_DetectLayout 7 keysyms per keycode not supported, set to 4
002c:warn:keyboard:X11DRV_KEYBOARD_DetectLayout Using closest match (United States keyboard layout (phantom key version)) for scan/virtual codes mapping.
002c:warn:keyboard:X11DRV_InitKeyboard vkey 010D is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0124 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0126 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0121 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0125 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0127 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0123 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0128 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0122 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 012D is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 012E is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 01B3 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 01B3 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 012C is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 01B4 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard vkey 0003 is being used by more than one keycode
002c:warn:keyboard:X11DRV_InitKeyboard No more vkeys available!
002c:warn:class:CLASS_RegisterClass Win extra bytes 80 is > 40
[b]002c:warn:ntdll:FILE_CreateFile L"\\??\\Z:\\mnt\\release\\EPS_Linux\\xerase\\uxtheme.dll" not found (c0000034)
 
Not a JPEG file[/b]
002c:warn:ntdll:FILE_CreateFile L"\\??\\Z:\\mnt\\release\\EPS_Linux\\xerase\\mscoree.dll" not found (c0000034)
root@megatron:/mnt/release/EPS_Linux/xerase# 0013:warn:rpc:RPCRT4_default_receive_fragment Short read of header, -1 bytes
0013:warn:rpc:RPCRT4_io_thread receive failed with error 6be
0032:warn:rpc:RPCRT4_default_receive_fragment Short read of header, -1 bytes
0032:warn:rpc:RPCRT4_io_thread receive failed with error 6be
0024:warn:rpc:RPCRT4_default_receive_fragment Short read of header, -1 bytes
0031:warn:rpc:RPCRT4_default_receive_fragment Short read of header, -1 bytes
0024:warn:rpc:RPCRT4_io_thread receive failed with error 6be
0031:warn:rpc:RPCRT4_io_thread receive failed with error 6be

So, it looks like it's trying to load uxtheme.dll from my compile directory, instead of using a built-in winelib library?? (none of that should be on Z at all anyway) The goal here is to release an executable that isn't tied to this particular system.
Locked