views:

906

answers:

8

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?

A: 

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.

Nicholas
+3  A: 

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.

Vincent Robert
A: 

Wine is the the only way to run DirectX in Linux

Nick Stinemates
+2  A: 

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.

AzraelNewtype
A: 

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.

CiNN
+1  A: 

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

UK-AL
Yes, this was what I was thinking of when I asked the question. I'll investigate further.
Nick
+6  A: 

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.

Nick
A: 

Thanks so much. I am forced to take courses that cover d3d and do homework with it in school and this bit of advice has saved me from having to clog my computer with win-blows.