Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: making a cross platform program  (Read 10720 times)

0 Members and 1 Guest are viewing this topic.

AK_IL

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: making a cross platform program
« Reply #15 on: October 26, 2014, 08:52:50 pm »
Take the source and compile it on Linux.
Using what program?
Assuming I've built and wrote many cpp and hpp files, it's all organized in vs but you can't run it on linux.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: making a cross platform program
« Reply #16 on: October 26, 2014, 08:53:32 pm »
You don't build project files or solutions.  You build C++ source code.  Project files, solutions and makefiles are usually specific to a single compiler or platform, so you should never rely on only one set of them (unless of course they're SCons/CMake/QMake build files, from which let you can generate the project files/solutions/makefiles for any compiler/IDE on any platform).

As a first step, you could probably benefit from using a few compilers' command line interfaces, just to wean yourself of the idea that Visual Studio is "the thing that compiles C++".  Just install MinGW or clang and build a simple Hello World example from the command line with them.  If you can do that on Windows, you can do it on Linux exactly the same way.  Then you can worry about what IDEs or meta-build systems you want to wrap the compilers with.

Edit: Since this latest question implies the misunderstanding is even worse than I thought, I feel the need to answer it directly.
Take the source and compile it on Linux.
Using what program?
It's called a "compiler."  It is not hard to find C++ compilers on Linux.  The most popular are gcc and clang, both of which have Mac OS and Windows versions (for some reason gcc for Windows is called MinGW).
« Last Edit: October 26, 2014, 08:58:28 pm by Ixrec »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: making a cross platform program
« Reply #17 on: October 26, 2014, 10:40:00 pm »
Quote
for some reason gcc for Windows is called MinGW
MinGW is not gcc. It's a minimal distribution of GNU tools for Window, which include the gcc compiler and other stuff.

The thing is, there's no official version of gcc for Windows. Different people provide their own build together with more or less other tools; these distributions are MinGW, TDM, nuwen, etc.

yes, I really wanted to make things even more confusing
Laurent Gomila - SFML developer

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: making a cross platform program
« Reply #18 on: October 27, 2014, 10:39:23 am »
Actually, I found its really easy to build many kinds of Makefile, Solutions, Projects using Premake: http://industriousone.com/what-premake . Its got simple Lua syntax, that means, no typing in arcane commands that cmake, make, autostuff, ant, ... need; and it lets you create those files even from different OS. Downside is one currently has to use an old 4.4beta, but they are working on 5.0.

select_this

  • Full Member
  • ***
  • Posts: 130
  • Current mood: just ate a pinecone
    • View Profile
    • darrenferrie.com
Re: making a cross platform program
« Reply #19 on: October 27, 2014, 11:00:17 am »
premake is also what I use, but it's still missing the ability to create an install target, which is a pretty big flaw as you'll have to manually add it into the makefile afterwards. It has been on the roadmap for a number of years but no one has yet tackled it.
Follow me on Twitter, why don'tcha? @select_this

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: making a cross platform program
« Reply #20 on: October 27, 2014, 08:19:52 pm »
Take the source and compile it on Linux.
Using what program?
Assuming I've built and wrote many cpp and hpp files, it's all organized in vs but you can't run it on linux.

Ok, this comment repeats some of what has already been said, but hopefully also adds some new useful info.

You should stop thinking about Visual Studio as a compiler - it is not. It is an IDE which includes a compiler (and an editor, debugger, linker, build system and more). You don't need to use Visual Studio to compile your code with its compiler (cl.exe), you can call it from the commandline.

For example; when I write my code (which gets built on Linux, OS X and Windows) I write the code using emacs and use Scons as my build system. Then when I tell scons to compile my program it calls gcc on Linux, clang on OS X and cl.exe on Windows to do the actual compilation. No Visual Studio project files anywhere (although scons can generate some for you from your SConstruct file if you want to), scons drives the build on all platforms and I just need to maintain a few SConstruct/SConscript files that tell scons what to build and what my dependencies are and then it takes care of the platform/compiler specific details and I rarely have to worry about that. It can also generate installation packages for you; like .deb packages on Linux, .msi packages on Windows etc.
And scons is just one of many such build systems. So pick one, learn it well and stop relying on Visual Studio and its project files to drive your build.
« Last Edit: October 27, 2014, 08:46:58 pm by Jesper Juhl »