A linux for programming

I never used a linux OS, I am open to the idea of using it lately, what is the best linux for programming you advice?

thanks
I don't think it really matters. Use whatever Linux distribution you like and feel comfortable using.

Some distributions like Debian try to be very stable so the official packages might not contain the latest version of compilers, etc. Other Linux distributions like Arch Linux are quite the opposite and often contain the latest versions.

While I do like Arch Linux (their package manager "pacman" is great), and I learned a lot using it, I didn't like when things stopped working after doing a system update (happened a few times for me, especially after waiting too long between updates).

Nowadays I use Debain on all my computers. It just works. If I need to upgrade to a later version of the compiler I will just have to compile and install it myself. From time to time I might want to upgrade to a later version of Debian but at least it's up to me to decide when I want to spend my time doing that.
Last edited on
Can WINDOWS executable runs in linux OS?
Last edited on
The simple answer is "no". It can even be difficult to get executable files to work across different Linux distributions so having it work across Windows and Linux is quite a leap.

That said, you might be able to use WINE to run some Windows applications on Linux. I remember StarCraft 1 worked quite well but that was not the case with all programs. It was ages since I used it so I have no idea how well it works nowadays with modern Windows applications.

Another alternative is to install a virtual machine (e.g. VirtualBox) on Linux and use it to run Windows. This essentially means you install Windows inside the VM and it runs inside a window while using Linux.
Last edited on
Can WINDOWS executable runs in linux OS?
See my updated answer above.
Mint Linux is supposed to be easy for Linux beginners
Zorin Linux is for those moving from Windows

https://linuxmint.com/
https://en.wikipedia.org/wiki/Linux_Mint

https://zorin.com/os/
https://en.wikipedia.org/wiki/Zorin_OS

To run Windows programs under Linus, there's also Crossover
https://www.zdnet.com/article/how-to-run-windows-programs-on-linux-with-crossover/
Oh that's just great(

@Salem c, said in one of his replies
If you care about portable code, then always compile with the strict flags the compiler offers.
I guess windows applications do not run on Mac, it seems the same case with linux, I am wondering what's portability then?

If I am a programmer, then why should I care about portability if my application wont be executed in other OS
Last edited on
Well-written generic code that doesn't call Win specific functionality can compile and run on Linux. Or MacOS. And vice versa.

That is the key: SOURCE CODE. Source has to be compiled for each platform.

That is "portability" when it comes to writing programs.

1
2
3
4
5
6
#include <iostream>

int main()
{
   std::cout << "Hello World!\n";
}

With a compiler that is compliant to the C++ standard that source should work on any OS. When compiled for that OS.
Can WINDOWS executable runs in linux OS?

No, not directly as an already compiled executable without using a emulator or virtual machine setup.

Even source code that uses Win functionality won't compile using a compiler created for Linux or MacOS, the compiler doesn't "understand" the function(s).

1
2
3
4
5
6
7
8
#include <windows.h>

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int iCmdShow)
{
   MessageBoxW(NULL, L"Hello World!", L"Hello Message", MB_OK);

   return 0;
}

This code is a close approximation as a GUI app for the C++ console mode code shown earlier, using WinAPI functions. The above code should work with MinGW (GCC modification for Windows) or Visual Studio.

why should I care about portability if my application wont be executed in other OS

There are 3rd party libraries available to get around that problem. GUI libraries, for example. WxWidgets or FLTK or Qt.

https://www.slant.co/topics/12868/~cross-platform-c-gui-toolkits
Another issue that can cause problems when creating cross-platform compliant code. Does a particular compiler have the feature used?
Visual Studio on Windows can compile (and run) this C++20 code:
1
2
3
4
5
6
7
import <iostream>;
import <format>;

int main()
{
   std::cout << std::format("The answer is {}\n", 42);
}

GCC/MinGW has partial module support and ZERO support for <format>. The header simply doesn't exist. Change the imports to #includes, still no joy.

From what I understand there is a version of Visual Studio created for MacOS. Linux doesn't.
https://visualstudio.microsoft.com/vs/mac/
Notice the MacOS version doesn't have 100% crossover WinAPI functionality, including no ability to compile C++ code.
Last edited on
the tools for unix coding are not as full featured as visual studio. VS is in a class by itself, and if that is what you have been using, nothing else really gets close. Of course that is bundled with stuff you may hate, too: there are a lot of oddities that it supports or even encourages to interface to its OS.

A couple of things you most likely will have to deal with if you decide to code on unix include makefiles (which windows can have but you don't have to) and some oddities with the console (for example you have to type ./program to run it instead of just program as the current folder isn't defaulted into the OS path on unix). End of lines may be different in text files, so code you wrote on windows may bother some tools in unix if you copy the source over. Little things, but just be prepared for a bit of aggravation until you get used to it.

you can run windows programs on unix via a virtual machine but if possible its better to recompile them. Gamer forums have a lot of hard core users who figure out how to make stuff run that really should not, and are a good source for help on the area if you can get them to talk.

my advice is, if you decide to use it, put it on an old computer if you have one, something you don't use at all and don't care if you format the hard drive, or boot it from a USB disk or something. Give it a good try on a setup like this that has no commitment involved, you can drop it at any time. Then if you like it, you can look into setting up your primary machine with it. Yes, you can dual boot your primary machine and all that, but its a fair time and energy investment to do it with at least a small risk of screwing it up and losing your windows partition.
Not what you asked, but there is also the ability to run Linux under Windows.

The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

I installed this since I needed a Bash shell for something. It came with Ubuntu, although I understand you can run other distros.

Thank you everyone, I am choose mint as a beginner choice...

This is a summary of what I learned, so correct me if I am wrong.

In the 3 OSs, linux, windows and mac, there is the same c++ language, but the executables are different from each other.

If I want to build a game for example that will run on the 3 OSs, I need to build one cpp source code, then compile it in each OS.

Note: here I am not taking from a user point of view, of someone who want to runs windows apps in other OSs, instead I am talking from a programmer point of view, of someone who want to deliver programs for different OSs.
Last edited on
yes, those are correct.

Note that for games specifically some libraries won't work on all 3 platforms, so you have to choose libraries that are portable if you want that kind of portability.

note that with virtual machines you can still run it on the other platform, or docker as well. The executable is still not compatible, really, it has a translation program that understands what to do.
Note that for games specifically some libraries won't work on all 3 platforms
Yes that why I said
I need to build one cpp source code
I am talking here only about cpp, or do you mean STL won't be recognized in other platforms?
Note that for games specifically some libraries won't work on all 3 platforms

That depends on the type of game, and how much work you want to devote to getting it to work.

There are graphics/sound/music libraries/engines that will work cross-platform on Linux, MacOS and Windows.

Unity is a very common cross-platform game engine. Visual Studio has support for it with a manually installed workload. Same for Unreal or Cocos2D.

I've never used anything other than the most basic usage of DirectX, at the "how to get it to work" tutorial stage.
STL is part of c++; it works on all modern compilers on all OS etc.
I meant third party libraries, eg the above mentioned directx may not work on say a mac, since its a windows thing (I don't know, maybe they ported that too, but say they didn't for a quick example).

I am way out of the loop on game engines. Maybe any worth using are fine on any OS now. But anything you use, for anything in the code, has to be portable if you want it on all the OS. Some stuff, usually small but free work, will be windows or unix specific.
Last edited on
Got it, thank you everyone) always honored.
Topic archived. No new replies allowed.