undefined reference to `CopyFileA'

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
apekar
Newbie
Newbie
Posts: 1
Joined: Tue Dec 02, 2014 5:07 am

undefined reference to `CopyFileA'

Post by apekar »

Hi. It's my first topic here. So, sorry if I'm noob. And sorry for my English.

I'm working on a big project written for Windows. I have ported all it's code to Linux (Ubuntu 14.04 LTS) with wine. Code compiles successful (I was trying to compile .a static library). But when I've tried to create shared library, I was getting many-many undefined references to WinAPI functions, most from winbase.h.

So, I'm trying to create "test" shared library with only one .cpp file:

Code: Select all

#include <windows.h>

#include <iostream>

using namespace std;

int main(void) {
    CopyFileA(NULL, NULL, 0);

	cout << "Hello World" << endl;
	return 0;
}
And I was trying to compile and link it with kernel32.dll.so like:

Code: Select all

g++-4.7 -c wine_test1.cpp -I /usr/include/wine/windows/
g++-4.7 -o wt.so wine_test1.o -L /usr/lib/i386-linux-gnu/wine/ -lkernel32
Output:

Code: Select all

wine_test1.o: In function `main':
wine_test1.cpp:(.text+0x29): undefined reference to `CopyFileA'
/usr/bin/ld: wt.so: hidden symbol `CopyFileA' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Also, I'm trying:

Code: Select all

wineg++ -c wine_test1.cpp -I /usr/include/wine/windows -lkernel32
wineg++ -o wt.so wine_test1.o -L /usr/lib/i386-linux-gnu/wine/ -lkernel32
Output:

Code: Select all

wine_test1.o: In function `main':
wine_test1.cpp:(.text+0x35): undefined reference to `CopyFileA'
/usr/lib/i386-linux-gnu/wine//libwinecrt0.a(exe_entry.o): In function `__wine_spec_exe_entry':
(.text+0x48): undefined reference to `ExitProcess'
/usr/bin/ld: wt.exe.so: hidden symbol `CopyFileA' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
winegcc: g++ failed
I have no idea what is wrong. Maybe someone have any suggestion?
Locked