Sorry if my question very nooby, but I couldn't find answer in others posts. I'm trying to compile QT project which using some functions from kernel32.dll (SetEvent, Sleep, ExitThread etc.). I include Wine lib in my QT project file:
Winelib isn't a simple library against which you can link. All our libraries are a sort of hybrid win32/linux libraries. You need to use winegcc/wineg++ to compile your program. The program will depend on wine (e.g. the wine binary, wineserver ..) because Wine needs to do a lot of magic behind your back to work (it needs a windows kernel, registry, file system ....)
I've compile my project with wineg++, but I have the same result: undefined reference to WINAPI functions. Any suggestion?
One more question: there is the different between including -lkernel32 and /usr/lib/wine/kernel32.dll.so in project file? When I'm trying to include -lkernel32 library I've got the error: "Cannot find -lkernel32", when I compile with /usr/lib/wine/kernel32.dll.so I've succeded, but have undefined reference errors.
You need to compile all of your source using winegcc/wineg++ and it also needs to perform the linking. Winegcc/g++ should link with kernel32 by default but for non-standard win32 dlls you need to add -ldllname.
E.g.
#include <windows.h>
int maint(int argc, char **argv)
{
printf("Hello world winelib\n");
Sleep(1);
return 0;
}
I compile your example and succeeded. But when I'm trying to compile my project which contains many files I have undefined reference errors. I compile my project with following parameters:
You mean still unresolved symbols for the kernel32 functions? Are your prototypes using the right calling convention? Windows uses STDCALL by default which linux use ccedl this can matter. At least on Windows the names of the symbols are different for different calling conventions.