PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 11, 2022

[FIXED] What C++ compiler to target both Linux and Windows?

 September 11, 2022     c++, cross-platform     No comments   

Issue

I would like to make a simple database-like software. It will work like MySQL/PostgreSQL but it will be very, very simple and different. It should work on both Windows and Linux (just like MySQL/PostgreSQL do). I want to do that in C++.

Is there a compiler I can use to write one code, and then compile that code to both platforms? Of course these could be two different compilers, each compiling for one platform.

To answer one of the questions below - yes it's clear to me that I can't have one binary for both platforms. I want to use one code and get two different binaries as a result using probably 2 different compilers.


Solution

You can compile on windows using MinGW for Windows and gcc on Linux: MinGW is a minimalist implementation of gcc for windows. It's "the same compiler", however it's wont produce the same binary, because one is for windows, the other for linux.

It's better to write portable and standard code, so that you do not rely on any particular compiler. This way, it will compile under most platform and compilers. Boost, Qt, Ace are some example cross-platform libraries that you could use.



Answered By - Xaqq
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing