Question

More out of interest than anything else, but can you compile a DirectX app under linux?

Obviously there's no official SDK, but I was thinking it might be possible with wine.

Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edit: This is called winelib)

Failing that, maybe a mingw cross compiler with the app running under wine.

Half answered my own question here, but wondered if anyone had heard of anything like this being done?

Was it helpful?

Solution

I've had some luck with this. I've managed to compile this simple Direct3D example.

I used winelib for this (wine-dev package on Ubuntu). Thanks to alastair for pointing me to winelib.

I modified the source slightly to convert the wchars to chars (1 on line 52, 2 on line 55, by removing the L before the string literals). There may be a way around this, but this got it up and running.

I then compiled the source with the following:

wineg++ -ld3d9 -ld3dx9 triangle.cpp

This generates an a.out.exe.so binary, as well as an a.out script to run it under wine.

OTHER TIPS

If this is not about porting but creating, you should really consider OpenGL as this API is as powerful as DirectX and much easier to port to Mac or Linux.

I don't know your requirements so better mention it.

You can't link against wine as it's essentially a call interdictor/translator rather than a set of libraries you can hook into. If linux is important go OpenGL/SDL/OpenAL.

I believe(I've never tried this) you can can compile Linux binarys against winelib. So it works just like a Linux executable, but with the windows libraries.

http://www.winehq.org/site/docs/winelib-guide/index

go to the directory with the source and type in:

winemaker --lower-uppercase -icomdlg32 -ishell32 -ishlwapi -iuser32 -igdi32 -iadvapi32 -ld3d9 .
make
wine yourexecutable.exe.so

If you get this Error:

main.c:95:5: error: ‘struct IDirect3D9’ has no member named ‘CreateDevice’

make sure you have named your file main.cpp and not main.c.

There is currently no way to compile DirectX code to directly target Linux. You would build your application like you normally would, then run it using a compatibility layer like Wine/Cedega.

Wine is the the only way to run DirectX in Linux

you can compile a directx apps in linux, but not launching it straight away. if you use a crosscompilator that makes windows exe and point to the windows sdk and directx sdk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top