Setting up a Linux and Windows-based development environment for Linux

For a university course, I have to write an http server that should work on both Linux and Windows. I have a modest Linux machine, which, I think, can not cope with any difficult virtual environment, and I do not want to go on about it when installing it.

This is the first project of my complex (I estimate ~ 1.5 months for development) to require that the environment be convenient enough to quickly switch between short coding and testing cycles (the latter on both platforms, of course).

So, I was wondering what could be best configured for this situation. I think that testing it on Wine would be good (after all, this is not the real thing), and I installed MinGW for the Windows-oriented part.

Basically, a simple well-written make file can solve my problem ... It should collect both Linux and Windows executables and put them in the appropriate folders (Windows in the Wine basement), and I'm done! But I feel very inexperienced in this thing, and I really don't know where to start. Maybe an instruction manual, ahah! :)

Thoughts, suggestions, everything that I did not think / did not know! Thanks!

(PS. I plan to use emacs as an editor, or perhaps find out vim. If eclipse does not provide some kind of skynet-like plugin that completely solves this problem ... :)

+4
source share
1 answer

You are on the right way. It's not that hard, really, thanks to MinGW. You basically need two things:

  • The code must be portable across all operating systems. MinGW has POSIX support, but you will probably need to use Cygwin to be able to use the POSIX interface or have your own compatibility level for interacting with the OS. I would probably go for Cygwin, since then you can only code against POSIX and you won’t have to test and debug your compatibility level. Also, make sure that you will not use external libraries specific to the OS. Non-portable code often leads to a compilation error, but make sure you test the application anyway.

  • Tools for targeting Linux and Windows. You already have them, you just need to use them correctly. Normally, you should use a variable like $ (CROSS_COMPILE) as a prefix when you call the tool chain during cross-compilation. Therefore, when compiling for Linux, you call gcc, ld, etc. (With variable CROSS_COMPILE empty), and when compiling for Windows you call, for example. i486-mingw32-gcc, i486-mingw32-ld, etc., i.e. CROSS_COMPILE = i486-mingw32-. Or just define CC, LD, etc. Depending on the purpose.

I wrote a little game on Linux and ran it on Windows. If you are looking at the code , you can see that the code has C # ifdef jungle near it (basically, only some additional debugging functions allowed for Linux), and the Makefile is also simple, without complicated processing for cross-compiling, just the ability to override CC and etc., as it should be. Since many important open source programs are written here (especially the software used by desktop and embedded devices), you can also find many other examples of how to properly configure the build environment.

As for testing the application on Windows, I think the best option is that you can somehow find a real Windows machine. If you do everything right, it should work just like it did on Linux, and you won’t need to constantly test your application on both OSs. If testing on a Windows computer is not possible, the virtual machine will be the next best choice, although it would probably be more difficult to configure it. Wine is a good backup plan, but I don’t think you can be sure that your application works well on Windows if you only tested it on Wine.

+1
source

Source: https://habr.com/ru/post/1393451/


All Articles