Using wine to compile windows source code running as Linux

Questions about Wine on Linux
Locked
clemens1509
Newbie
Newbie
Posts: 1
Joined: Sat Jan 13, 2018 10:59 am

Using wine to compile windows source code running as Linux

Post by clemens1509 »

Hi,
I would like to compile a Windows source code on Linux. Can wine help me for that ?

I've tried to link agains kernel32.dll.so, but something in the stack is wrong.

Code: Select all

int main()
{
  HANDLE hFile = CreateFile("tt_win_src_on_linux.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

  printf("File created successfully\n");
  return 0;
}
Example:
I can step into CreateFileA(), but a further calling function of GetVersion() crashes with a SIGSEGV before first C-line is executed. Maybe something bad on the stack - maybe calling convention ?

Assembly Code of GetVersion():

Code: Select all

0x7b496630	push   rbp
0x7b496631	mov    rax,QWORD PTR gs:0x30
Compile log:

Code: Select all

gcc -Wall -nostdinc -fno-builtin -H -fasynchronous-unwind-tables -DRC_INVOKED=1 -D_REENTRANT -g -I../wine/install/include/wine/windows -I../wine/install/include/wine/msvcrt -c /home/cvmann/dev/tt_win_src_on_linux/tt_win_src_on_linux.c -o obj/Debug/tt_win_src_on_linux.o
[100.0%] g++ -L../wine/install/lib64/wine -L../wine/install/lib64 -o bin/Debug/tt_win_src_on_linux obj/Debug/tt_win_src_on_linux.o  -l:kernel32.dll.so -Wl,-rpath-link=/home/cvmann/dev/wine/install/lib64 -l:msvcrt.dll.so
Thanks,
Clemens
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: Using wine to compile windows source code running as Lin

Post by DarkShadow44 »

This should work, also see the wiki on winelib.

How did you set up your project?
Locked