Is it possible to develop DirectX apps in Linux?
Asked Answered
P

9

13

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?

Prosecutor answered 7/9, 2008 at 0:30 Comment(0)
P
11

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.

Prosecutor answered 16/9, 2008 at 9:24 Comment(1)
The package is called libwine-dev on a more modern Ubuntu 22.04Pollitt
A
3

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.

Aubree answered 7/9, 2008 at 1:32 Comment(0)
E
2

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

Encomiast answered 15/9, 2008 at 20:16 Comment(1)
Yes, this was what I was thinking of when I asked the question. I'll investigate further.Prosecutor
D
1

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.

Disquisition answered 7/9, 2008 at 5:32 Comment(0)
J
1

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.

Jigging answered 23/3, 2013 at 12:5 Comment(0)
B
1

Although this question is dated, I decided to updated on it, because it keeps popping up for me as the first suggestion for this particular problem.

As the previous answers already suggested you can compile against winelib. However, there are yet another two solutions.

The first solution would be either to use the MinGW provided for your distributions. MinGW is a 'cross-compiler', that compiles either from macOS or linux to windows and has support for DirectX. Note, that C++ libraries compiled with MinGW are not compatible with the MSVC compiler's ABI, thus cannot be consumed. However, the resulting binaries can be executed using Wine.

The second solution would be to use clang as a cross compiler. Clang usually includes the Compiler and Linker needed for Windows out of the box. However, it'll require you to include provide the headers and libraries yourself. On the other hand, libraries compiled this way are compatible with MSVC and, thus, can be consumed by it.

Side note: Latter allows you to setup an CI server using linux (I did so on a raspberry pi), which creates compatible binaries for end users.

Barbarese answered 8/3, 2020 at 20:6 Comment(0)
K
0

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.

Knucklehead answered 7/9, 2008 at 0:33 Comment(0)
P
0

Wine is the only way to run DirectX in Linux

Plaintiff answered 7/9, 2008 at 4:50 Comment(0)
U
0

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.

Undershirt answered 7/9, 2008 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.