Cross compiler prefix and path in eclipse - c++

I'm trying to create a C++ project on eclipse. I have installed eclipse-cdt for that.
While creating a project, a pop up window asks for cross compiler prefix and cross compiler path. Could someone please explain what are those and what do I need to add in those fields? Are those fields absolutely necessary to fill?

If you are using a Mac, you can select MacOS GCC instead of Cross GCC. If you are on Windows, you will have to install a C++ compiler. I recommend you install Cygwin, try following the directions here.
https://www3.ntu.edu.sg/home/ehchua/programming/howto/eclipsecpp_howto.html
Once you've installed the C++ compiler, restart Eclipse and try to create the project again. Hope this helps.

In Cross compiler Prefix you need to write 'arm-none-eabi-' and in Cross compiler path you have to select the path for GCC bin folder. You need to install Cygwin GCC for this.
I have found few steps in below link.
https://www3.ntu.edu.sg/home/ehchua/programming/howto/Cygwin_HowTo.html#cygwin

Just in case anybody else is like me and needs more explicit directions as #yeremy is correct in that you have to select MacOSX GCC. It's just that at the point where the OP is, he overshot where he could have made the selection and needs to back up a few windows (about 3) to choose the MacOSX GCC as the Toolchain of choice. Attaching a link below which goes through the steps and which also shows image of window where you can make the selection (figure 11).
Getting Started with C++ for Eclipse - CodeGuru

When Eclipse doesn't detect a toolchain (to be installed separately) it only offers the option "Cross GCC". Don't choose that.
Sites like this tell you that a properly installed toolchain (Cygwin / MinGW) is automatically discovered using the PATH environment variable. This is not the case on my machine.
There's no way to configure a toolchain in Eclipse manually (as of writing) but you can fool Eclipse into finding one without changing your global PATH:
Go to Preferences/C/C++/Build/Environment,
Add a variable PATH and point it to your toolchain path(s), e.g. d:\Mingw\bin;d:\Mingw\msys\1.0\bin. Separate paths with a semicolon.

For newbies just starting out C++ projects in Eclipse:
1 - Click File --> New--> C/C++ Project
2 - In the "Templates for New C/C++ Project" window, Select C++ Managed Build --> Click Next
3 - Provide a project name --> Select "Empty Project" in Project Type section (which is under Executable) and Select "MinGW GCC" in the Toolchains section
4 - Click Finish
Note: Selecting "MinGW GCC" will eliminate the headache of inputting the Cross GCC related prefix and path. Happy C++ learning.
enter image description here

Related

Eclipse CDT missing features

We have a C++ project we want to enhance using Eclipse on Linux (CentOS 7). We have one Linux VM with Eclipse and CDT (a C++ plug-in) installed. Using CMake, we generated make files for the project and brought it up in Eclipse (File → Import → General → Existing Projects into Workspace). From there we need to do some fixes to make it compile C++ 11 code. We do this via the "Properties → C/C++ General → Preprocessor Include Paths, Macros etc." page. It all builds and works fine.
We created new Linux VMs with the same version of Linux. We installed Eclipse (Oxygen) and installed the CDT plug-in. We followed all the same steps as above, except in these new VMs, there is no "C/C++ General → Preprocessor Include Paths, Macros etc." option in the Properties dialog. We can get the code to compile as C++ 11, but the IDE itself doesn't recognize C++ 11 and marks most of the code as errors. If we had the "Preprocessor Include Paths, Macros etc." page, we could makes the necessary changes, but for the life of us, we can't figure out why it doesn't show up in the new VMs. Both Eclipse installs have the same plug-ins (one, namely, CDT).
Is there something we're missing? Is there another way to access the options that the missing page allows?
UPDATE
Perhaps some visual will help. Here is what the Properties page looks like when opened on the original Linux VM:
Here is what the Properties page looks like when opened in the new VMs:
As you can see, in the second image, there is no "Preprocessor Include Paths, Macros, etc." option underneath "C/C++ General". That is the problem. Without that page, we can't do several things to the project we need to to get it to operate correctly.
I can't really be proud of our solution to this problem. The version of Eclipse that works is Oxygen.1a Release (4.7.1a). The "latest and greatest" release of Eclipse (at the time) was Oxygen.2 Release (4.7.2). We downloaded and installed 4.7.1a and it worked. There must be a defect in 4.7.2 that prevents it from correctly recognizing C++ 11 code.
Oxygen.1a 4.7.1a imports the project perfectly and shows up all the options we need to make changes and get the application to compile and run correctly.

How do I set up C/C++ on Eclipse in Windows?

I just did the default Java (8) installation of Eclipse on my Windows (8, yikes) laptop, and it seems to work just fine. However, I'm not as good at Java as I am with C and C++, and for some work it's more expeditious to use C/C++ than Java.
Unfortunately, the Eclipse installer for Windows doesn't make it very easy to set up Eclipse for C/C++. It looks like I'd be fine with Linux or BSD, but then I'd have to scrounge up another laptop (because I need the mobility) and install Linux or BSD on it. Yes, I need to leave Windows on this machine, so Windows hate isn't going to help me.
My lazy web search turned up this article: "Install Eclipse for C++ Development on Windows 7 64-bit". Is there a better installation guide than that, or does anyone care to describe the process in more detail?
Even though you have CDT features installed, you need to install a GCC compiler for windows such as MinGW or Cygwin. Once you install them, add the 'bin' folder in the installed path to the environment variables and then restart eclipse. You should now see MinGW compiler when you select "Create new C Project". After this step, proceed with your C programs and this should resolve your problems.
You will have to install a GCC compiler in your PC and then link it to the project each time you create a project. This can be done while you create a new project, or even after you have done so. You can download MinGW compiler through the following link
https://sourceforge.net/projects/mingw/files/latest/download?source=files
Once you have downloaded the compiler and installed it, it can be linked through the following steps:
i. While creating a new project, choose MinGW GCC compiler in the tool chains.
ii. Once you have finished creating a project, go to Project->Properties.
iii. Look for Run/Debug Settings in the left panel.
iv. Click on the New tab and select C/C++ Application.
v. Look for Environment option.
vi. Click on the New tab.
vii. Type "PATH" in the Name bar and fill the Value bar with the path of the compiler. For me, its C:\MinGW\bin.
vii. Click on OK and you are done!
The instructions you link to have you install Eclipse IDE for C/C++ developers which will work fine to get a C/C++ development environment up.
If you would instead like to use your EXISTING installation of Eclipse and add C++ Development Tooling (CDT) you can launch Eclipse and then use Install New Software to install the C/C++ Development Tools

Eclipse CDT C++ - [Main] program not specified

Hi This is my first time working with C++ on eclipse. I'm using cygwin.
I'm just trying to create a simple hello world program. The build is successful but when I try to run, it says "launch failed. binary not found".
In settings which I check the run configuration, there's nothing listed on clicking "search project..". Am I doing something wrong?
Would really appreciate any help on this. Thanks!
You probably found your solution, but here's for anyone else who might have the same problem:
If you want to use cygwin toolchain then you'll have to build a makefile first, and then build your project. You can follow the official guide here: http://help.eclipse.org/indigo/index.jsp (C/C++ Development User Guide >> Getting Started >> Creating a Makefile project)
If you don't mind changing the cygwin toolchain: The fastest way to build and run a C/C++ project would be to create another project, this time un-ticking the show project types and choose as MINGW GCC toolchain (check 1st image below). After you create your project, you just right click on project and choose the rebuild option (check 2nd image below).

Using Eclipse CDT for Pintool development

So, I've got some stuff that I need to develop with pintools, and I'm having a hard time using eclipse with it all.
I found this, but it doesn't give very specific details. I was hoping that someone could provide very specific instructions as to how to use eclipse on Mac (or linux) to develop pintools.
I tried it a little, and found that on mac you have to install the clang build toolchain, and even then, doing a simple import of the MyPinTool was harder than it seemed because the makefile specifies a lot of extra options/variables that I don't know how best or correctly to configure in eclipse.
You can download pintools. The makefile that I'm talking about is in source/tools/MyPinTool, it sources a file located at tools/makefile.gnu.config
EDIT: by the way, I'm on Mac OS X Lion with an i7 using pin 2.12
c++ --version returns this:
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM
3.1svn) Target: x86_64-apple-darwin11.4.2 Thread model: posix
I'll guess that you are using the newest version of Eclipse (4.2) and that you start working from the template MyPinTool pintool in "source/tools". I'll take those guesses because it is much easier to configure CDT to recognize the pin environment from a compiling tool, rather than manual configuring it.
First create a makefile project from existing source:
Then go to your project properties and select under "C/C++ General" -> "Preprocessor Include..." the "CDT GCC build output parser", make sure that it is enabled and if you are using clang++ as the compiler, that you add it in the compiler pattern:
Now build your pintool from within eclipse (either click on the hammer icon in the toolbar, or right click your projet and select "Build Project"). CDT should parse the build output and resolve all the paths and required macros from it. Basically, now you are good to go... But...
I have found that CDT has some quirks, if this doesn't work, try and do the following:
Check if you are working on a "deep" path (/a/b/c/d/e/f/g/h/i/j/k/l/m), sometimes CDT takes the relative build path used by the make file, and translates it to a wrong absolute path. I've found that working in a "shallower" path resolves this issue (I should open a bug report for this...).
Sometimes the indexer doesn't kick in right away. Try refreshing the project, rebuilding the index (Right click on project then "Index" -> "Rebuild"), and even restarting eclipse then doing this again.
I know it is a bit of voodoo magic, but I got it working :)
I tested this procedure on a fresh kit with MyPinTool but if it still doesn't work, please provide the steps you did and what errors does eclipse give you.

Eclipse C++ : "Program "g++" not found in PATH"

I have gpp installed in my Windows 7 (32 bit) as shown in the picture.
PATH variable gas g++
"%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\g++"
Still eclipse shows the error:
"Program "g++" not found in PATH".
How can this be resolved?
Today I have bumped into this problem and solved it in the following way. I pressed "Reset defaults" button everywhere I could find it in Eclipse settings (for example, Preferences/C++/Build/Settings/Discovery). After that the error disappeared and the code compiled successfully.
This is how I got rid of it:
Install the MinGW.
Select all files in the Basic Setup and select apply the changes.
Select new C++ Project You will be able to see "MinGW GCC" in the toolchain section select the same and create project.
You need a gcc, g++ compiler toolchain (on your windows machine) for the eclipse which you have manually downloaded,
One of the options can be done implicit via cygwin installation(by selecting proper development packages for gcc, g++) and then add the location of the compiled gcc ,g++ package like C:\cygwin\etc\alternatives to the PATH variable for windows environment.
After this open eclipse and go to Project->properties->C/C++ Tool Chain Editor and add replace default GNU C++ compiler and GNU C Compiler with Cygwin C++ compiler and Cygwin C compiler and rebuild the project. The errors related to gcc, g++ PATH not found will now be gone.
You need:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
in the PATH.
and not
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\g++
as you wrote.
I got the same problem with mingw-64 (x86_64-4.9.1-release-posix-seh-rt_v3-rev1), Eclipse Luna 4.4.1 and CDT 8.5.0.201409172108, using Windows 7.
I solved this problem by putting the following two environment variables under
Window -> Preferences -> C/C++ -> Build-> Environment
name: MINGW_HOME value: (mingw installation directory without "\bin")
name: MSYS_HOME value: (msys installation directory without "\bin")
You can check
Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC
Built-in Compiler Settings MinGW [ Shared ]
, if it doesn't complain "Toolchain MinGW GCC is not detected on this system" then you're all set.
I had the same problem, the only solution that worked for me was this:
Open command-line and check whether "g++" actually executes the compiler
If (1) works, uncheck Project->Build automatically in Eclipse
Clean project
Build project
I had the same problem: Eclipse couldn't find (g++) and (gcc) in PATH even they were accessible from command-line. I was also sure they are pointed by PATH correctly.
I have just deleted the (.metadata) folder from Eclipse's Workspace as a mean to reset it and this worked for me.
The PATH is locate at Project Properties > C/C++ Build > Environment (see screenshot below).
For your reference, I am using MinGW, I got the same error before I got the MSYS install. Later I found out that I also need MSYS to be install because the make.exe wasn't come with MinGW. (I don't this error was cause be MSYS.)
After MSYS is installed, add MSYS and MinGW path into environment variable, restart Eclipse. Remember to rebuild your project in order to rectify the error. If error still persist after restart, recreate the workspace. At least this has solved the problem on my site, hopes this help on you too.
Good luck!
I had a similar problem. The error is raised, but the code is compiled and linked. The error was caused by the Error Parser using a different configuration than the one that is compiled.
The error parser configuration was only valid for the Linux configuration of my software. My active configuration was set for MinGW and Windows.
Solution:
In Elipse under Windows->Preferences->C/C++->Indexer set Build Configuration for the indexer to Use active build configuration.
Clean and rebuild, otherwise the old errors will remain visible
Maybe it has nothing to do here, but it could be useful for someone.
I installed jdk on: D:\Program Files\Java\jdk1.7.0_06\bin
So I added it to %PATH% variable and checked it on cmd and everything was ok, but Eclipse kept showing me that error.
I used quotation marks on %PATH% so it reads something like:
%SYSTEMROOT%\System32;"D:\Program Files\Java\jdk1.7.0_06\bin"
and problem solved.
I had similar problem and I solved it by:
Installing g++ The GNU C++ compiler using Ubuntu Software Center
Changing in: Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Build in Complier Settings [Shared]
from: ${COMMAND} -E -P -v -dD "${INPUTS}"
to: /usr/bin/${COMMAND} -E -P -v -dD "${INPUTS}"
I hope it helps.
I had the same problem in Sublime..
Right click on my computer
Advanced system settings
Environment variables
in system variables, change path to location of '...\MinGW\bin'
Example: D:\work\sublime\MinGW\bin
For me it got fixed with:
Go to:
Window -> Preferences -> C/C++ -> Build -> Environment
Then press "Add..."
Name: MINGW_HOME
Value: C:\MinGW (yours might be different if you choose a custom path)
Hit "Apply and Close"
Now, it shoud work if you did everything correctly
i think cgywin might not work for you as you can only compile your code in Win7 if you fire up the command prompt; you need to use MinGW compiler toolset instead. After you have install your compiler, go to Properties->C/C++ Build->Tool Chain Editor -> Change your current toolchain to MinGW GCC.
WINDOWS 7
If there is anyone new reading this, make sure to simply try a clean install of mingw before any of this. It will save you sooooo much time if that is your problem.
I opened up wingw installer, selected every program for removal, apply changes (under installation tab, upper left corner), closed out, went back in and installed every file (in "Basic Setup" section) availible. after that eclipse worked fine using "MinGW GCC" toolchain when starting a new C++ project.
I hope this works for someone else.
If not, I would do a reinstall of JDK (Java Developer's Kit) and ECLIPSE as well. I have a 64bit system but I could only get the 32bit versions of Eclipse and JDK to work together.
In my case, I didnt mark for instalation the mingw32-gcc-g++ package in the installation manager, that's why eclipse didn't know it.
Needed to go to the instalation manager, mark it (in basic setup tab) and update catalogue
If you have your PATH setup and you can see g++ --version via the command line, then try to delete the project and create a new c++ project.
So the reset defaults might work but I think it has to update the PATH if it wasn't added before.
Had this problem on windows 10, eclipse Neon Release (4.6.0) and MSYS2 installed.
Eclipse kept complaining that "Program 'g++' not found in PATH” and "Program 'gcc' not found in PATH”, yet it was compiling and running my C++ code.
From the command prompt, I could run g++.
Solution was to define the C++ Environmental variable for eclipse called 'PATH' to point to windows variable called 'path' also $(Path).
Menus: Preferences>>C/C++>>Build>>Environment
Looks like eclipse is case sensitive with the name of this environmental, while windows doesn't care about the case.
First Install MinGW or other C/C++ compiler as it's required by Eclipse C++.
Use https://sourceforge.net/projects/mingw-w64/
as unbelievably the download.cnet.com's version has malware attached.
Back to Eclipse.
Now in all those path settings that the Eclipse Help manual talks about INSTEAD of typing the path, Select Variables and
**MINGW_HOME**
and do so for all instances which would ask for the compiler's path.
First would be to click Preferences of the whatever project and C/C++ General then Paths and Symbols and add the
**MINGW_HOME** to those paths of for the compiler.
Next simply add the home directory to the Build Variables under the C++/C Build
Build Variables Screen Capture
All the tips did not work for me using the Gaisler Tools for GR712RC Installation for OS RTEMS.
I'm using the Eclipse Kepler.
The simple way was making a copy of sparc-rtems-gcc.exe to gcc.exe, and sparc-rtems-g++.exe to g++.exe, in the C:\opt\rtems-4.10-mingw\bin directory.
The reason is that eclipse cannot find your gcc or g++ environment variable path.
You might have tried to run c or c++ or fortran but eclipse cannot find out the compiler.
So, add the path in your environment variable.
Windows -> Search -environment variables -> click on environmental variables at bottom.
Click on path ->edit -> new -> your variable path
Path should be entire, for example:
C:\Users\mahidhai\cygwin64\usr\sbin
Make sure that the variable is permanently stored. It is not erased after you close the environment variables GUI.
Sometimes you might find it difficult to add a path variable.
Make sure windows is updated.
Even if Windows is updated and you have problems, directly go to the registry and navigate to the below.
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Add your path here. Remove any unnecessary repetitions of path variables.
Note:
You need to add your path variables in system environment variables -path
enter image description hereIf you just want to run C program but meet this error, it might mean that MinGw c++ compiler has not been installed even if "C:\MinGW\bin" has already been added to Windows Path variable.
Solution:
Run "mingw-get-setup.exe" to open MinGW Installation Manager
Open All Packages->MinGw->MinGW Base System->MinGW Compiler Suite
Select the following compilers to install:
. mingw32-gcc-g++
. mingw32-gcc-v3-core
. mingw32-gcc-vc-g++
Click Installation->Apply Changes to apply the above changes
Wait for the installation finishing(There might be some errors, just ignore them).
Restart Eclipse.
Done.
It Worked in my environment.
Hope it works in your case.