I'm having problems compiling and linking a simple DirectX program with Wine. The problem is: a global variable c_dfDIMouse should be declared in dinput.h and defined in library dinput. c_dfDIMouse really is declared in dinput.h, but it seems that c_dfDIMouse is not declared in library dinput. During linking I get the error: undefined reference to `c_dfDIMouse'. Anyone got a clue? Thanks in advance, Rein Kadijk The Netherlands
On Thu, 26 Apr 2001, R Kadijk wrote:> I'm having problems compiling and linking a simple DirectX program with Wine. > The problem is: a global variable c_dfDIMouse should be declared in dinput.h > and defined in library dinput. > c_dfDIMouse really is declared in dinput.h, but it seems that c_dfDIMouse is > not declared in library dinput. > During linking I get the error: undefined reference to `c_dfDIMouse'. > Anyone got a clue?This variable cannot (and in Windows isn't either) be exported from the shared library (aka DLL), so it's not defined there. Rather, it's supposed to be in a static library (in Windows it's something like dinput.lib, I think). I suppose it could be put into Wine's libuuid.a or something, whenever anyone feels like adding it there (i.e. when they need it, which I don't right now, since I don't compile DirectX apps with Winelib yet).
R Kadijk wrote:> > I'm having problems compiling and linking a simple DirectX program with Wine. > The problem is: a global variable c_dfDIMouse should be declared in dinput.h > and defined in library dinput. > c_dfDIMouse really is declared in dinput.h, but it seems that c_dfDIMouse is > not declared in library dinput. > During linking I get the error: undefined reference to `c_dfDIMouse'. > Anyone got a clue?Well, there seems to be a couple of problems: * First the variable is not defined in the dinput library. So you will probably need to add something like this in one of the dinput files: const DIDATAFORMAT c_dfDIMouse; But then it will need to be initialized somehow. How is one supposed to get/set its value in DirectX (I don't know DirectX)? Where does its value come from? * then this variable should be declared in 'dlls/dinput/dinput.spec' so that Windows applications can use it. A line like the following should do it: @ extern c_dfDIMouse c_dfDIMouse * but the above will not help you for your Winelib application. Winelib apps cannot import variables from a 'dll'. So what you must do is either modify your code to invoke a standard DirectX API that would return the information you need. Or define a couple of macros so that using c_dfDIMouse invokes a function returning the address of that variable and then dereferences it. The whole thing would then look like that: include/dinput.h: extern const DIDATAFORMAT* c_dfDIMouse(); #define c_dfDIMouse (*__dinput_c_dfDIMouse()) dlls/dinput/xxx.c DIDATAFORMAT dinput_c_dfDIMouse; /* Plus some code to initialize it */ const DIDATAFORMAT* __dinput_c_dfDIMouse() { return &dinput_c_dfDIMouse; } dlls/dinput/dinput.spec: @ extern c_dfDIMouse dinput_c_dfDIMouse -- Fran?ois Gouget fgouget@codeweavers.com