Author Topic: Same project under Linux and Windows?  (Read 488 times)

Offline Sephiroth

  • Single posting newcomer
  • *
  • Posts: 4
Same project under Linux and Windows?
« on: March 18, 2021, 04:34:22 pm »
I am about to start a cross-platform project which will include a library for functionality and a GUI front-end, likely in Qt. I want the application to work on Linux (I use Plasma) and Windows 7 and up. Instead of having two copies of the project, I was considering placing the project on a Google Drive and setting build properties to the local drives of the Windows and Linux systems. How would I go about this, or is it even possible yet?

Offline sodev

  • Regular
  • ***
  • Posts: 427
Re: Same project under Linux and Windows?
« Reply #1 on: March 18, 2021, 04:55:04 pm »
Use git or any other RCS/VCS. Really, this is the way. CodeBlocks does support different platform configurations inside one project file, but depending on the required different settings it might be easier to use different projects per platform like CodeBlocks does itself.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2957
Re: Same project under Linux and Windows?
« Reply #2 on: March 18, 2021, 05:48:59 pm »
The general idea is to create a target per platform:
Project->Properties->Build targets->Platform
ecc...

If you have the same source libraries, you can use global variables to differentiate between your windows and linux machine
http://wiki.codeblocks.org/index.php/Global_compiler_variables

Offline AndrewCot

  • Single posting newcomer
  • *
  • Posts: 8
Re: Same project under Linux and Windows?
« Reply #3 on: March 18, 2021, 11:15:22 pm »
If you are going to use QT then IMHO use QT Creator. On Windows use MSYS2 (https://www.msys2.org/) and on Linux use the packages from the distro. The one QT project can be used for windows and Linux.
If you want to use Codeblocks have a look at wxWidget or SDL2 as a cross platform GUI. Unfortunately you will end up with two projects, one for Windows and one for Linux, but it is relatively easy to keep them in sync as they are text files and can be diffed using Winmerge on Windows or Meld on Linux.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2957
Re: Same project under Linux and Windows?
« Reply #4 on: March 18, 2021, 11:25:44 pm »
Quote
Unfortunately you will end up with two projects
As i said, this is not strictly needed... But this is nitpicking :)

Offline Sephiroth

  • Single posting newcomer
  • *
  • Posts: 4
Re: Same project under Linux and Windows?
« Reply #5 on: March 21, 2021, 02:04:27 am »
I know that Qt is cross-platform, which is why I chose it. Not sure what the point of MSYS2 is since I run Gentoo on my Linux boxes. I did not consider Git for some reason. I just did not think about it. I will likely use it now, but what about Qt Creator? I want to code using Code::Blocks but how do I make that mesh with Qt Creator?

See the UI I want to be cross-platform. 90% of this project will be pure C++ code however, and will work fine on any standard system, even Apple. I do not want separate projects due to 90% or more being identical on all platforms. It doesn't make sense to me. My idea was to have a Windows folder with the Windows-only code, a Linux folder with Linux-only code, and a Common folder with the code that does all the work. Why is this not a good idea or why can't I do it this way?

Offline LETARTARE

  • Regular
  • ***
  • Posts: 445
  • L'ami de l'homme.The friend of man.
Re: Same project under Linux and Windows?
« Reply #6 on: March 21, 2021, 10:25:04 am »
Hello,
I do not respond directly to your questioning, but I give you my experience with 'Qt' and 'Code::Blocks'.
As you, I develop the same application under Win64, Win32 and Linux (OpenSuse : Leap-15.2) : https://github.com/letartare/gcv .
Also I created a plugin for 'Code::Blocks':
http://forums.codeblocks.org/index.php/topic,20000.0.html) and https://github.com/letartare/cb_addonforqt  
that using multiple files 'xxx.cbp' allows to manage the construction of the different binary under Window or Linux (xxx_win32.cbp, xxx_win64.cbp, xxx_lin64.cbp).
The creation of  '*.ui' files is carried out by 'QtDesigner'.
Creating translation is done by scripting files that calls 'Qt' tools.
These calls are driven from the 'Tools' menu of 'Code: Blocks'.

Have a good day.


« Last Edit: March 21, 2021, 03:30:30 pm by LETARTARE »
CB-rev12446, plugins : AddOnForQt-3.3 sdk260
1-Win7 Business Pack1 64bits : wx-3.1.5, gcc-8.1.0,
2-Vista Business Pack2 32bits : wx-3.1.4, gcc-8.1.0
3-OpenSuse-15.2-Leap 64bits : wx-3.03, gcc-7.5.
=> !! The messages are translated by Deepl !!