Re: problem when use dll.so from wine app

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you very much,

I had try the same way that you say but still not work the same error

Following is my windows dll

1. Simple.h:

Code:
__declspec(dllexport) void ShowText()



2. Simple.c

Code:
#include "Simple.h"
#include <stdio.h>
void ShowText()
{
	printf("Hello world\n");
}



i build and generate Simple.dll

3. install wine and copy Simple.dll to my folder on linux system

4. use winedump to general .spec, .c, .h

> winedump spec Simple.dll -f Simple -I "*.h"

=>Simple.spec, Simple_main.c, Simple_dll.h

- Simple.spec content:

Code:
# Generated from Simple.dll by winedump

1 cdecl ?ShowText@@YAXXZ() SIMPLE_global_ShowText_1
#import Simple.dll



- Simple_dll.h content:

Code:
/*
 * Simple.dll
 *
 * Generated from Simple.dll by winedump.
 *
 * DO NOT SEND GENERATED DLLS FOR INCLUSION INTO WINE !
 * 
 */
#ifndef __WINE_SIMPLE_DLL_H
#define __WINE_SIMPLE_DLL_H

#include "windef.h"
#include "wine/debug.h"
#include "winbase.h"
#include "winnt.h"


void __cdecl SIMPLE_global_ShowText_1(void);



#endif	/* __WINE_SIMPLE_DLL_H */




- Simple_main.c content:

Code:
/*
 * Simple.dll
 *
 * Generated from Simple.dll by winedump.
 *
 * DO NOT SUBMIT GENERATED DLLS FOR INCLUSION INTO WINE!
 *
 */

//#include "config.h"

#define __WINESRC__

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "Simple_dll.h"
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(Simple);


HMODULE hDLL=0;	/* DLL to call */

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);

	switch (fdwReason)
	{
		case DLL_WINE_PREATTACH:
			return FALSE;    /* prefer native version */
		case DLL_PROCESS_ATTACH:
			hDLL = LoadLibraryA("Simple");
			TRACE("Forwarding DLL (Simple) loaded (%p)\n", hDLL);
			break;
		case DLL_PROCESS_DETACH:
			FreeLibrary(hDLL);
			TRACE("Forwarding DLL (Simple) freed\n");
			break;
		default:
			break;
	}

	return TRUE;
}


/******************************************************************
 *		?ShowText@@YAXXZ (SIMPLE.1)
 *
 *
 */
void __cdecl SIMPLE_global_ShowText_1(void)
{
	void (__cdecl *pFunc)(void);
	pFunc=(void*)GetProcAddress(hDLL,"?ShowText@@YAXXZ");
	TRACE("(void): forward\n");
	pFunc();
	TRACE("Returned (void)\n");
}
/******************************************************************
 *		?ShowTextA@@YAXXZ (SIMPLE.2)
 *
 *
 */
void __cdecl SIMPLE_global_ShowTextA_2(void)
{
	void (__cdecl *pFunc)(void);
	pFunc=(void*)GetProcAddress(hDLL,"?ShowTextA@@YAXXZ");
	TRACE("(void): forward\n");
	pFunc();
	TRACE("Returned (void)\n");
}



5. use winegcc to build libSimple.dll.so

> winegcc Simple_main.c Simple.spec -o libSimple -shared -fPIC

=> libSimple.dll.so

6. write test program main.c:

Code:
#include "Simple_dll.h"

int main(int argc, char **argv) {
	SIMPLE_global_ShowText_1();
   	return 0;
} 



7. use winegcc to build it by command line such as you say but still not work:

> winegcc -Bwinebuild -I/usr/include/wine -I/usr/lib/wine -mwindows main.c -o main -lSimple.dll -luser32 -lkernel32


My process is correct?

Thank you very much






[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux