Author Topic: porting huge C++ project to linux  (Read 559 times)

Offline 23pret

  • Single posting newcomer
  • *
  • Posts: 2
porting huge C++ project to linux
« on: June 25, 2018, 05:24:49 pm »
Hi

I  have a basic question.   I have a huge C++ windows project to port Linux. Can I use code block IDE to open windows based visual studio project, change to Linux compiler build fix errors etc or do I need to create a blank Linux project and manually add all the files and then compile build?

Thanks for the help

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11144
    • Travis build status
Re: porting huge C++ project to linux
« Reply #1 on: June 25, 2018, 05:39:30 pm »
It depends. What is the project format you're using on windows? cbp, some visual studio project?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline 23pret

  • Single posting newcomer
  • *
  • Posts: 2
Re: porting huge C++ project to linux
« Reply #2 on: June 25, 2018, 05:43:55 pm »
Iam using Visual studio C++ project

Online sodev

  • Almost regular
  • **
  • Posts: 169
Re: porting huge C++ project to linux
« Reply #3 on: June 25, 2018, 05:51:47 pm »
Define huge. A solution with one project and 10000 files in it? Or a solution with 1000 projects with 10 files each in it, all with different compiler settings, custom compile rules, tons of property sheets? But i guess it doesn't matter that much, because Visual Studio compiler settings are 100% incompatible to GCC ;D.

There is a project importer for MSVC solutions, but its sort of quite dated so i don't know until which version it works, and afaik it's also limited in what special constructs it understands. But anyway, since you need to setup for GCC this won't help you much, you have to convert all settings yourself so imho you are better off starting with an empty project (or multiple) and add everything to it. But depending on your project this is the smallest issue you have to think about, how much does your project use windows specific code? MSVC specific code? Ancient c++-non-standard-compliant-code?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11144
    • Travis build status
Re: porting huge C++ project to linux
« Reply #4 on: June 25, 2018, 08:50:01 pm »
Iam using Visual studio C++ project
Then try the importers (you need the project importer plugin loaded), but if you're using newer vstudios (2012 or newer) it might not work. But I guess it could help if at least it adds the files in the project.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline rjansen

  • Single posting newcomer
  • *
  • Posts: 1
Re: porting huge C++ project to linux
« Reply #5 on: July 12, 2018, 09:14:46 pm »
I did that using vs2008 windows solution imported to Codeblocks under CentOS7 -- it worked but the result was not that usable as too many flags change. I threw it away and started over.

Best way I found was to get one project fully configured as you like and then copy this over and over again (outside of the ide) to make new cbp files for new projects. Then use a text editor to change the title and import. Next from within the IDE throw away the source tree from the new project and add the new projects source.

I did about 100 projects this way.

Now I just wish they had workspace virtual folders so I could organize my projects into logical groups.
« Last Edit: July 16, 2018, 09:55:47 pm by rjansen »

Offline Krice

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: porting huge C++ project to linux
« Reply #6 on: July 13, 2018, 02:08:32 pm »
But i guess it doesn't matter that much, because Visual Studio compiler settings are 100% incompatible to GCC

It's because each compiler has their own compiler flags. But if you compile "normal" way each compiler simply produces a working object/executable file from a C++ source code file. Compiler settings don't matter in that, they mostly help catch errors, optimize code etc.

Contrary to what some people believe, Visual C++ is these days pretty ok compiler and it supports most of C++ standards, just like GCC. If you keep it simple and don't do any super magic stuff it's going to compile in both GCC and VC just fine. I'm doing exactly that, I have set up my projects to work 1:1 in both compilers and IDEs, because some built-in compiler flags in GCC are nice, they catch more stuff than VC, but Visual Studio's static analyzer tool is also quite nice.

C++ itself is not a big problem when porting, it's mostly older C functions, but even they have a quite solid standard implementation. The two actual problems are external libraries and setting up the project for both Code::Blocks and Visual Studio (or worse: linux vs. Windows). I think you just have to keep track of two projects, what files are in the project etc. but it's not that hard if the project is moderate size. Porting from linux to Windows is actually harder than the other way around, this is something linux fanboys tend to forget. It's mostly libraries, many linux projects use shady, weird libraries which aren't available for Windows in the first place so you run out of luck really fast.
« Last Edit: July 13, 2018, 02:13:18 pm by Krice »