Difference between installed packages of GCC compiler - c++

After I installed the gcc cross compiler on my ubuntu, I noticed a few new packages.
arm-linux-gnueabihf-g++
arm-linux-gnueabihf-g++-4.8
Both packages compile my code correctly. I suspect that one compiler is a version independent (ie once i install version 4.9 this package would still be named as it is) and one is specifically for version 4.8 only.
What could be the difference between the following two packages and which one I should use to cross compile in eclipse?

Related

How to run g++-6 on debian 10, need to compile older buildroot system (Cross compiling)

How to run g++-6 on debian 10, need to compile older buildroot files.(NCurves(host-ncurses-5.9) is crashing)
I have tried to patch the files in the buildroot but it like walking into a swamp.
Fixing one problem to find the next problem.
Tried compiling 6.3 compiler from source but this is crashing with the latest gcc-8 compiler.
Any suggestions? (I always assumed that older compilers should compile with newer compilers)
My other options are:
* Running virtual machine (VM or docker) with Debian Jessie
* Compile an older compiler with a docker GCC compiler.(No idea if this works)
* maybe turn off the compiling of the local files in buildroot? (Could not find any info on this)
There is a gcc-6 package available in Debian. So you just need to sudo apt install gcc-6. link
No reason to compile gcc from source unless you need a very specific version, but even then Docker is the far easier solution since gcc has an official repo on Docker Hub. I'd also double check that you have the proper ncurses dev library installed.
The overall best solution is to containerize the correct build environment (compiler, libraries, etc.), though. It ensures you'll always be able to build the product, especially if a re-factor is not viable.

How to use previous versions of g++

I am currently running a debian Jessy whose g++'s version is 4.9. For some reason I need to compile a code in g++-4.7 or previous version.
I got the files of gcc-4.7 and g++-4.7 from a debian wheezy of a friend who has g++-4.7.
I tried to make the apt-get install, it seemed to have worked for the gcc but not for the g++. I put the files in the /bin, but he doesn't seem to locate the g++-4.7 package.
When I try to compile my code I specify g++-4.7 but get the error :
g++: error trying to exec 'cc1plus': execvp: No such file or directory
Any idea how to figure this out?
My advise is to add the wheezy repositories to /etc/apt/sources.list and then install g++-4.7 using apt-get. Using this method you will also get bugfixes etc.
I guess, currently you're just having dependency Problems. These will be solved when you use apt-get.
It is very easy to install gcc from sources. Remember that you have also to use a binutils version which maps to the gcc version. Mostly it is possible to run older gcc versions on actual binutils, but I have also seen a problem during install.
I have installed a long list of gcc versions in /opt/
Simply copy an older gcc version somewhere in the file system can result in problems with using the correct library versions.
If you install different gcc versions and also the related libraries e.g.libstdc++ , don't forget to update your library data base ( ldconfig/LD_LIBRARY_PATH/...) Maybe http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html can help.

OpenMP on Mac not working anymore

I had OpenMP compiling and executing in C/C++ on my Mac but then I formatted and reinstalled a fresh copy of OS X. I believe the only difference in the setup was that I had Xcode 5 before the format, and now I have Xcode 6.
Now I get fatal error: 'omp.h' file not found
I read this has something to do with clang and gcc, but, my confusion lies with why did it work before and now its not working?
After some research I seem to have found an answer.
GCC included in the latest version of Xcode (Xcode 6) is only a symbolic link to clang. Since clang does not support OpenMP at this time, you need to install a different version of GCC. The easiest way to do this would be to use Homebrew or MacPorts.
Keep in mind that even when you do this you will probably need to alter your $PATH to have /usr/local come before /usr/bin. This is because Homebrew will have placed your newly installed GCC in /usr/local. Also, some implementations may name the command gcc-49 instead of plain gcc.
Mac OSX uses clang.The gcc compiler in OS X does not support OpenMP. To use this feature a new gcc compiler needs to be installed.
Go to Terminal, if you have not installed Hombrew, install it:
/usr/bin/ruby -e "$(curl -fsSL https://`enter code here`raw.githubusercontent.com/Homebrew/install/master/install)"
then install new version of gcc
brew reinstall gcc --without-multilib
This will not make changes to the existing gcc compiler installed by Xcode as we are reinstalling it.
After running the command given below compile the files using the new version of gcc using the syntax : gcc-version -fopenmp filename.c
To find the version type gcc and then press tab. This will list out all the possible variants of gcc. The version number can be found out from this. For example : gcc-6, gcc-4.9,etc

mingw without g++ compiler

i am new to linux and I have the following question:
I am trying to install MINGW in Ubuntu.
I ran the command:
sudo apt-get install mingw-w64
It was installed, and if i put the command gcc it runs ok. The problem is g++ command does not work. I guess it is because i don't have the c++ compiler (as I read in similar questions in stackoverflow).
I read too that you can use the next command:
mingw-get install g++
but i don't have the executable program for this command.
My question is, how can I install that executable? or is there another way to update my mingw so I can use the g++ compiler?
Hope I have explained myself correctly. Thank you for any help I receive.
mingw-get is a windows specific package manager, it is not needed when you use a native linux package manager such as APT.
Installing package mingw-w64 depends on package g++-mingw-w64, which depends on g++-mingw-w64-i686 and g++-mingw-w64-x86-64.
These packages install the mingw cross compilers as
/usr/bin/x86_64-w64-mingw32-g++-posix
/usr/bin/x86_64-w64-mingw32-g++-win32
/usr/bin/i686-w64-mingw32-g++-posix
/usr/bin/i686-w64-mingw32-g++-win32
Older versions of mingw cross compiler shipped /usr/bin/i586-mingw32msvc-c++, which is replaced by i686-w64-mingw32-c++-win32
You can usually use this toolchain in a project by running ./configure CXX=i686-w64-mingw32-c++-win32 or make CXX=i686-w64-mingw32-c++-win32
Note: the above description is correct for the most recent toolchain in Debian unstable. It may need some minor tweaking for older systems.

Using homebrew, gcc and llvm with C++ 11

Here's my problem: I want to use C++11 features provided by either gcc or clang. However, I have these requirements:
I'm using a mac
I'm dependent on a bunch of libraries provided by homebrew (and really don't want to compile them myself). Specifically OSG, which itself is dependent on a ton of other libraries. And boost, though I can always compile that myself.
Homebrew seems to only want to use gcc (please correct me if I'm wrong). I can't find any options to switch to LLVM instead. While I understand that this might be due to the fact that not all libraries are compatible with LLVM yet, this would still be a nice feature for those that are.
The version of gcc that comes pre-installed on a mac of gcc is 4.2. gcc 4.2 doesn't have the c++11 features required. I've installed 4.7 via homebrew, but searches for how to set homebrew to use it all say don't do it (gcc 4.2 on the mac is not the vanilla version, so the 4.7 version I got won't be able to compile some things).
My questions are: Does anyone have any suggestions or fixes they have implemented to get around this problem? Should I give up on Homebrew? Does anyone know if Homebrew has a plan to switch to LLVM in the future? Does anyone have any upgrade-plan for how to deal with these incompatibilities?
I don't see how homebrew can continue to depend on gcc 4.2 in the long run, but haven't found any real discussion on this matter.
The default GCC on Mac is not real GCC of GNU. It's LLVM-GCC in fact, which is a branch of GCC. Several years ago, LLVM-GCC was terminated, and replaced with DragonEgg, which is a GCC plugin to use LLVM as a GCC backend.
LLVM-GCC is just a compiler frontend, whose role is using GCC frontend to translate the source code into LLVM IR[Intro to LLVM 11.3]. Once IR generated, LLVM backend will use it to generate binary code. This step has nothing to do with GCC.
The above goal was fully achieved from 10.7, whose components were all compiled by clang, a frontend provided by LLVM.
But Apple still kept LLVM-GCC and GCC runtime libraries. I guess its purpose might be providing a opportunity to compile some code GCC ONLY.
Now let's answer your questions:
If you want to use C++11 features, use clang++ -stc=c++11 -stdlib=libc++ instead. And clang might have already supported all c++11 features.
If you want homebrew supporting LLVM, it has already supported, at least on backend.
If you want homebrew using clang as a compiler frontend, it depends on homebrew community schedule. For example, you can append --with-c++11 argument to use clang to compile boost.But you cannot use this argument when brew install autoconf. In fact, some components might not be compiled correctly by clang.
If you know it can be compiled by clang but homebrew hasn't supported yet, you have to hack the corresponding ruby script at $HOMEBREW_ROOT/Library/Formula directory. Fortunately, in most of cases, replacing ./configure blablabla with ./configure blablabla CXX=clang++ -stc=c++11 -stdlib=libc++ works well. And by the way, if your hack is successful, please make a pull request to homebrew.
So, try it and have a fun.
I have an OS X Mountain Lion environment and use C++11. In this answer I'll break your requirement for not compiling your own stuff.
I use Homebrew and, I must say, I advise you to give up on depending on it to provide you clang and libc++ and all its formulas built with them.
What I've done, and I like, is
clone llvm, clang and libc++ from repositories.
install to /opt/local and put /opt/local/bin at top on /etc/paths.
build my development stuff with my new clang.
let Homebrew for installing tools like git and things I'll not develop for, just use.
I've followed clang build instructions for installing it to /opt/local.
For libc++, one detail: after running the buildit script, I've symlinked the include directory to /opt/local/lib/c++/v1 (clang on /opt/local looks for this as default directory), and also symlinked the libs to /opt/local/lib/ (but look that binaries will not automatically link to libc++ on /opt/local/lib. You must use install_name_tool for that).
use
clang++ -std=c++11 -stdlib=libc++
you can also install latest gcc from homebrew-dups
brew install [flags] https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb
For LLVM, brew install --HEAD llvm. To use clang or a brew-installed gcc, add --with-clang or --with-gcc=gcc-x.x where x.x is the version you want.