Suppress program not found errors in Eclipse CDT
Based on the information provided, these errors are coming from the scanner discovery part of CDT.
On my machine the full error looks like this:
Description Location Type
Program "g++" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Built-in Compiler Settings MinGW] options C/C++ Scanner Discovery Problem
Program "gcc" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Built-in Compiler Settings MinGW] options C/C++ Scanner Discovery Problem
Or as a screenshot
What is going on here is Eclipse CDT is (attempting to) launch GCC and G++ to find out what the global settings are for things like include paths, etc.
To fix the problem, go to the Location specified in the error message and adjust the scanner settings. Here is the matching setting to go with the specific error I received.
Your error might be in the project or in the global settings.
To update the MinGW setting, you can provide the path to a batch file that looks like GCC/G++ but sets up your environment correctly first, or you can point directly at the GCC that Eclipse CDT did not find on its own.
For example you can have:
D:\path\to\my\compilers\${COMMAND}.exe ${FLAGS} -E -P -v -dD "${INPUTS}"
As the setting instead of the default.
To aid the debugging, check the Allocate console in the Console View to see exactly what is being run and what output is being generated.
And here is what you might see when it does not work. Hopefully the error messages in the console are sufficient to resolve the problem on your machine.
21:12:54 **** Running scanner discovery: CDT GCC Built-in Compiler Settings MinGW ****
"D:\\path\\to\\my\\compilers\\g++.exe" -E -P -v -dD C:/Temp/workspace/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.C
Cannot run program "D:\path\to\my\compilers\g++.exe": Launching failed
Error: Program "D:\path\to\my\compilers\g++.exe" not found in PATH
PATH=[\bin;\bin; -- snip --]
21:12:54 Build Finished (took 37ms)
Here is a screenshot to match:
If it does work, you should see lots of #define
s and the like showing the global state of your compiler.
Unable to install LLVM toolchain for Eclipse CDT
This is a setup from scratch that worked for me (ubuntu 14.04 + eclipse mars + clang 3.6.2). You will be probably interested in steps 8 and 9.
Install Ubuntu
Install Java 8:
sudo apt-add-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java8-installer
Install g++:
apt-get install g++
Install llvm/clang 3.6.2:
http://llvm.org/releases/download.html
Download and extract to folder of your choice. I renamed the extracted folder to 'clang+llvm-3.6.2' so it is more convenient during setup. Also I have moved it into /home/[user_name]/Development folder that I created.
Add LLVM/Clang to PATH:
sudo gedit /etc/environment
Append the path to point to your llvm/clang bin folder.
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/[your_user_name]/Development/clang+llvm-3.6.2/bin"
Yours might look different, depending on where you placed your llvm/clang.
Save changes, reboot.
Install build-essential:
sudo apt-get update
apt-get install build-essential
Install eclipse:
Download and extract to a folder of your choice. (I moved it to my Development folder and renamed to eclipse_mars, but it is optional)
Install CDT and LLVM Support:
In opened Eclipse, 'Help > Install New Software > Work with: --All available sites--'.
Once the list loads, expand Programming Languages, install 'C/C++ Development Tools SDK' and 'C/C++ LLVM-Family Compiler Build Support'.
Configure eclipse:
In the top menu bar, select 'Window > Prefences'.
Select 'C/C++ > LLVM' in the left menu.
In the 'LLVM installation folder:', navigate to your LLVM bin folder
(/home/[your_user_name]/Development/clang+llvm-3.6.2/bin)
and click Apply and OK.Select 'File > New > C++ Project' in the menu. C++ Project popup window opens.
Enter Project name, select Project type in the Executable group
and 'LLVM with Clang(Linux)' in Toolchains. Click 'Next > Next'.In the Select Configurations, click 'Advanced settings' button.
Select 'C/C++ Build > Settings' in the left menu.
In the 'Tool Settings' tab, scroll down and select 'LLVM Clang++ > Dialect'.
Change it to 'ISO C++11 (-std=c++0x)' and click 'Apply' button.In the 'Tool Settings' tab, scroll down and select 'LLVM Clang C++ linker > Libraries'.
Make sure the 'Libraries(-l)' list contains 'stdc++'.
Make sure the 'Library search path(-L) list contains '/usr/lib/gcc/x86_64-linux-gnu/4.8'Click 'Apply' button.
In the left menu, select 'C/C++ General > Preprocessor include paths, Macros etc.'
Click 'Providers' tab and make sure 'CDT GCC Built-in Compiler Settings [Shared]' is selected. (Should be selected already).
Click 'OK' button.
Click 'Finish' button.
You should be now able to compile and run your code.
usr/bin/ld: cannot find -lnameOfTheLibrary
If your library name is say libxyz.so
and it is located on path say:
/home/user/myDir
then to link it to your program:
g++ -L/home/user/myDir -lxyz myprog.cpp -o myprog
Related Topics
Best Library for Statistics in C++
Reading an Application's Manifest File
Why and How to Use Namespaces in C++
Problems with Running Exe File Built with Visual Studio on Another Computer
C++ Read File Line by Line Then Split Each Line Using the Delimiter
Programmatically Access CPU Fan on a Laptop? (Windows)
How to Expand an Array Dynamically in C++? {Like in Vector }
How to Serialize Derived Template Classes with Boost.Serialize
Understanding Region of Interest in Opencv 2.4
Calling a Constructor to Re-Initialize Object
Calling a Function Through Its Address in Memory in C/C++
Why Isn't There an Operator[] for a Std::List
Is Boost Shared_Ptr <Xxx> Thread Safe
C++: How to Get Fprintf Results as a Std::String W/O Sprintf
Implicit Conversion When Overloading Operators for Template Classes