Sign in to follow this  
proanim

compile windows code on unix

Recommended Posts

Is it possible to compile windows code through unix system? I have a project that uses windows specific stuff like winapi, directx and some others, and now I am looking to find a solution to compile it remotely so other people working on it can access the build server (unix based server) and compile it from there. I am looking into this http://www.mono-project.com/Cross-compiling_Mono_for_Windows but I am not exactly sure if that will actually work. Is it viable solution for this?

Share this post


Link to post
Share on other sites

Specific windows stuff will not work natively on unix system, no matter what compiler you'll going to use. To be cross platform you first have to choose cross platform technologies, like OpenGL instead of DirectX, and then write cross platform code (without, for example, use of the conio.h lib, or windows.h, or frameworks like MFC)

Share this post


Link to post
Share on other sites

Specific windows stuff will not work natively on unix system, no matter what compiler you'll going to use. To be cross platform you first have to choose cross platform technologies, like OpenGL instead of DirectX, and then write cross platform code (without, for example, use of the conio.h lib, or windows.h, or frameworks like MFC)


Unless I understood proanim's question wrong, he's not looking to compile a windows program that works on unix, he's looking to build windows executables with a unix machine as build server.

Is that correct, proanim?

Share this post


Link to post
Share on other sites

As wack says, mingw is definitely the way to go. You don't need to learn to cross-compile the mingw toolchain though. To compile helloWorld.c into helloWorld.exe assuming you don't have mingw yet, hopefully this works:

 

sudo apt-get install mingw32

i586-mingw32msvc-gcc -o helloWorld.exe helloWorld.c

 

Sorry I can't double-check that easily check right now, but it should be that simple. You just install mingw, then use the compiler. Mingw always outputs Windows executables, even on Linux.

Share this post


Link to post
Share on other sites

 

 

Unless I understood proanim's question wrong, he's not looking to compile a windows program that works on unix, he's looking to build windows executables with a unix machine as build server.

Is that correct, proanim? 

 

The idea was to compile program remotely from unix build server, which will run on windows, but later be ported to linux and mac. And, program is supposed to have both directx and opengl included not just one (for windows version).

Share this post


Link to post
Share on other sites

I haven't tried using mingw to develop something without library support available on linux, so this is kind of a guess. If some step doesn't work and you tell me the problem you're seeing, I might or might not know how to resolve it.

 

So here's my guess of what you'll need to do:

1. You need headers. I think mingw added DX header files, but if not you'll need to copy them from windows.

2. You need a list of functions that the DX dlls provide, which means generating a .def. http://sourceforge.net/apps/trac/mingw-w64/wiki/gendef or http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/pexports-0.44-1/ can generate the .def. As you can even see from the URLs, those tools should work with mingw =)

3. You need to be able to link to those functions, so you'll need a .a file. If gendef/pexports can't generate the .a file directly, just use dlltool (part of binutils). Name it directx11.a or whatever.

4. Now link to your stub library (the .a file) by using -l directx11.a.

5. Pray that actually worked.

 

Alternatively, you could link against Wine versions of the libraries. That would ensure your game runs under Wine if that's a goal of yours. I personally would try not to do this since I feel like it's asking for trouble, but it's available as a last resort or if you're more daring than I am. To do that, you'd just install the wine dev sdk on linux.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this