# Are SDL games trivially portable from Linux to Windows?

I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of #ifdefs to port it or will the very same code work on Windows and Linux? Or is it more complicated?

Sorry if these are silly questions. I couldn't find existing resources on porting SDL games between desktop systems and I've never done this before!

## 2 Answers

SDL is a cross-platform library, so as long as your code is cross-platform(i.e. no OS specific calls, use '/' in directories instead of '\', etc.), yes you should be able to copy and paste without too many issues. If you end up using a different compiler, it might be more or less lenient about certain things, but they are probably minor.

• thanks man. But, what exactly is platforms specific? fopen and fclose? malloc? or just specific libraries for each platform? – twkmz Apr 9 '15 at 10:04
• Looking at those two on cplusplus.com, neither seem to be specific. When in doubt, just Google it and see if the reference mentions anything about it. – Moother Apr 9 '15 at 17:44

SDL can build in many Platform. If you are ussing C++, all STL library work on g++ and windows compilers. fopen, and others is the same.

EDIT: You can see this: https://wiki.libsdl.org/CategoryIO and others SDL Functions.