Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portable method to package C++11 program sources

so, C++11 has been around for a while and, given there already are compilers supporting it on most platforms, it would be nice to use it in some real software -- e.g. one that can be packaged in as-portable-as-possible package, preferably providing ./configure and so.

Because both Clang and GCC currently need -std=c++11 flag to compile c++11 source, and both sometimes require specific flags to work correctly (see for example How to compile C++11 with clang 3.2 on OSX lion? or C++11 Thread not working ), I'm quite afraid that the package won't work on some platforms that already support c++11 because of wrong invocation of compiler.

Q: Is there some standard how to correctly and portably compile c++11? E.g. autotools/autoconf check or some list of compiler/platform directives that describe all possible needed options? Or does the situation come from the fact that c++11 standard implementations are currently marked as "experimental" and the standard will eventually stabilize and become the default choice, not needing any usage of extra compiler flags?

Thanks

-exa

like image 969
exa Avatar asked Nov 02 '22 21:11

exa


1 Answers

Well, if you`re trying to write portable code, i would recommend using cmake a very powerful cross-platform, open-source build system.

Using cmake you should be able to identify the compilers available in your current machine and then generate your makefiles using the flags that you want in each case.

I have been using cmake for almost a year by now and it has significantly reduced the time consumed when trying to get a project compiling in different platforms.

like image 88
flazzari Avatar answered Dec 04 '22 01:12

flazzari