I am using Eclipse Luna SR1a (4.4.1) and assuming you can install and run Eclipse
C++11
Download gcc-5.0-bin.tar.gz from http://hpc.sourceforge.net
Unzip the file
You will get a usr folder and the folder structure will be following
usr ▸ local ▸ bin
usr ▸ local ▸ include
usr ▸ local ▸ lib
usr ▸ local ▸ libexec
usr ▸ local ▸ share
Rename the local folder to hpc-gcc and move it to your home directory.
For my case the path will be like,
Users ▸ shahabuddin ▸ hpc-gcc ▸ bin
Users ▸ shahabuddin ▸ hpc-gcc ▸ include
Users ▸ shahabuddin ▸ hpc-gcc ▸ lib
Users ▸ shahabuddin ▸ hpc-gcc ▸ libexec
Users ▸ shahabuddin ▸ hpc-gcc ▸ share
Version Test
Create a CPP project in Eclipse and run the code
// version-test.cpp by Bill Weinman <http://bw.org/> #include <iostream> #include <sstream> #include <vector> using namespace std; int main( int argc, char ** argv ) { stringstream version; version << "GCC version: " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "\nVersion string: " << __VERSION__; cout << version.str() << endl; // vector<string> v = { "one", "two", "three" }; // C++11 feature - initializer list // // for( string s : v ) { // C++11 feature - range-based for loop // cout << s << endl; // } return 0; }
Output should be like,
GCC version: 4.2.1
Version string: 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)
Configuration of C++11
Right click the project and select Properties (Cmd + I)
Under C/C++ Build -> Environment
Add these variables
Variable: CPATH
Value: ${HOME}/hpc-gcc/include
Variable: DYLD_LIBRARY_PATH
Value: ${HOME}/hpc-gcc/lib
Variable: LIBRARY_PATH
Value: ${HOME}/hpc-gcc/lib
Variable: PATH
Value: ${HOME}/hpc-gcc/bin:/usr/bin:/bin:/usr/sbin:/sbin
Finally it will look like this,
Carefully set the Variable and Value. Otherwise you might get the following error,
dyld: Library not loaded: /usr/local/lib/libmpc.3.dylib
Referenced from: /Users/shahabuddin/hpc-gcc/bin/../libexec/gcc/x86_64-apple-darwin14.0.0/5.0.0/cc1plus
Reason: image not found
g++: internal compiler error: Trace/BPT trap: 5 (program cc1plus)
make: *** [version-test.o] Abort trap: 6
Now go to C/C++ Build -> Settings
Under GCC C++ Compiler -> Miscellaneous -> Other flags
Add -std=c++11
Under GCC C Compiler -> Miscellaneous -> Other flags
Add -std=gnu11
Finally it will look like this,
Clean the project and Run again
Output should be,
GCC version: 5.0.0
Version string: 5.0.0 20141005 (experimental)
You might as well uncomment the bottom part now.
Output should be,
GCC version: 5.0.0
Version string: 5.0.0 20141005 (experimental)
one
two
three
I’m having the “Reason: image not found” problem that you describe but after check and recheck every path I can’t find anything wrong , do you know other cause fot this?
Mac OS : El Capitan 10.11.2
Eclipse: Version: Mars.1 Release (4.5.1)
GCC 6.0