This is my first post here, please excuse any incorrect terms etc. I have tried
to follow chapter 5 of winelib-guild.pdf, but found winemaker does not
correspond to the pdf.
I am using wine version 1.0-rc1. I am trying to call a Linux shared library from
an unmodified windows C++ program using a ?C? interface to a DLL. I have built
very simple test case that I would like help to compile. Sorry for long post.
File 1. header file to define the interface between the windows program and
windows DLL
#ifndef WINFUNC_H_
#define WINFUNC_H_
extern "C"
{
char * winFunc(bool select);
}
#endif /*WINFUNC_H_*/
File 2 ? the windows program
#include <stdio.h>
#include "WinFunc.h"
int main(int argc, char * argv[])
{
char * str = winFunc(false);
printf("main: got %s\n", str);
}
File 3 ? the windows DLL
#include "WinFunc.h"
#include <stdio.h>
__declspec(dllexport) char * winFunc(bool select)
{
if (select)
return "winString1";
else
return "winString2";
}
These have been compiled using MinGW on linux and produced files that work on
windows, and with wine.
File 4. ? Linux Shared library header
#ifndef LINUXFUNC_H_
#define LINUXFUNC_H_
extern "C"
{
char * linuxFunc(bool select);
}
#endif /*LINUXFUNC_H_*/
File 6 ? Linux Shared library cpp
#include "LinuxFunc.h"
#include <stdio.h>
char * linuxFunc(bool select)
{
if (select)
return "linuxString1";
else
return "linuxString2";
}
File 5 and 6 compiled using gcc on linux.
File 7 ? spec file for wine dll
@ stdcall winFunc (long)
File 8 ? Library code#include "WinFunc.h"
#include "LinuxFunc.h"
#include <windef.h> /* Part of the Wine header files */
char * WINAPI winFunc(bool select)
{
return linuxFunc(select);
}
The spec file was processed with command
winebuild --dll --export=../WinToLinux.spec --external-symbols
--subsystem=native --library-path=../../WinLib/Debug --output=Wrapper.o
The C++ code was compiled with command
wineg++ -I"/Work/work/workspace/Wine/WinLib"
-I"/Work/work/workspace/Wine/LinuxLib" -O0 -g3 -Wall -c
-fmessage-length=0 -MMD -MP -MF"WinToLinux.d"
-MT"WinToLinux.d" -o"WinToLinux.o"
"../WinToLinux.cpp"
And linked with
wineg++ -L"/Work/work/workspace/Wine/LinuxLib/Debug" -specs
../WinToLinux.spec -shared -o"WinToLinux.dll.so" ./WinToLinux.o
./Wrapper.o -lLinuxLib
But get the following error
./Wrapper.o(.data+0x0): In function `__wine_spec_nt_header':
: multiple definition of `__wine_spec_nt_header'
WinToLinux.dll-b7fdrU.spec.o(.data+0x0): first defined here
./Wrapper.o(.rodata+0x0): In function `__wine_spec_file_name':
: multiple definition of `__wine_spec_file_name'
WinToLinux.dll-b7fdrU.spec.o(.rodata+0x0): first defined here
./Wrapper.o(.data+0x28): In function `__wine_spec_nt_header':
: undefined reference to `null'
collect2: ld returned 1 exit status
winegcc: g++ failed
make: *** [WinToLinux.dll.so] Error 2
Question are.
1. What am I doing wrong or not doing?
2. Where can I find a how to?
3. Is this the correct approach?
The bigger picture is I need to share memory and other services between linux
application and windows application, running at the same time.
Hopefully someone will be able to answer my questions or direct me to where I
can find answers. I have tried Google but have had no luck.
If I would be better serviced by CodeWeaver, I am happy to go that way, But my
view was that for this forum was the most suitable for this type of question.
Nev