Cross compiling Direct3D on Linux with mingw

让人想犯罪 __ 提交于 2019-12-05 11:59:05

Ok! I've finally succeeded!

Unfortunately, I needed to download Microsoft DirectX SDK (April 2007) (I couldn't install newer ones with wine).

Then I had to install MinGW using wine and also install mingw-utils 0.3 (I had to obtain reimp.exe file).

Then I set up PATH in wine's register to C:\windows;C:\windows\system;C:\MinGW\bin

Then I made wine reimp.exe "C:\Program Files\Microsoft DirectX SDK (April 2007)/Lib/x86/d3dx9.lib". This command generated d3dx9_33.a file, I've changed it to d3dx9.a and put it in /usr/i586-mingw32msvc/lib/.

I have also copied all lacking header files from DirectX SDK to /usr/i586-mingw32msvc/include.

And then... I compiled the program, linking it to libd3d9.a and libd3dx9.a, and it compiled, linked, and it WORKS!

So the good news is: one can compile Windows DirectX programs under Linux using Linux version of MinGW.

The bad news: one need to install a few MinGW utilities and whole MS DX SDK using wine.

EDIT

And one more thing: I needed to make all WCHAR*-related castings manually - mingw shouts with errors if it isn't done. Goz was helpful here.

If you change your strings to

(const WCHAR*)L"blah blah"

Then it should compile its not ideal but it seems that wchar_t and WCHAR are not compatible under mingw. I'm not entirely sure why it doesn't compile though as windows.h defines WCHAR as a typedef of wchar_t ...

You can also you the plain mingw crosscompiler in for instance Debian or Ubuntu, and the code for DirectX only using LoadLibrary() and GetProcAddress(). (But the tutorials on DirectX can't be used as-is then.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!