Where do g++, make and GDB get installed with MinGW? - c

Please note: Although I'm specifically talking about the Eclipse CDT plugin, I'm almost 100% confident that any Windows/C/MinGW programmer can answer this question.
I'm on Windows 7 and am trying to write and compile a simple "Hello, C!" C application using Eclipse's CDT plugin. I'm reading their docs which state that having GCC installed is a prerequisite.
I just installed MinGW, making sure to include the following packages:
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
msys-base
Back in the CDT docs (under the section titled Windows configuration), it states that I need to add g++, make and GDB to my PATH.
I'm wondering where MinGW installs these utilities, so that I can add them to my system PATH, and make the Eclipse CDT recognize their location at startup.

When using the Eclipse CDT plugin, you need GCC and its 3 specific utilities installed locally. These three utilities are: g++, make and gdb.
On Windows you can choose to install these utilities via Cygwin or MinGW. For a MinGW-based solution, go to their site and download the MinGW Package Manager. Then open the manager and install the following packages:
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
msys-base
Then go to File >> Apply Updates and apply them. This will install the 3 utilities to the following directories on your machine:
C:\MinGW\bin\g++
C:\MinGW\bin\gdb
C:\MinGW\msys\1.0\make
Add these 3 binaries to your system PATH, restart Eclipse and you are all set.

Related

Switch C project configuration in Eclipse between Windows and Linux

I installed Eclipse with CDT plugin. I created a simple TCP client software that runs on Windows. I can open the project on Ubuntu also. I'd like to change build configuration in order to create Linux executable. Is it possible to create executable for the operating system that the project is compiled. I mean if I compile the project on Ubuntu, there should be Linux executable and if I compile the project on Windows, there should be Windows executable. Is it possible?
It is possible. When you are creating a Project in Eclipse, you are provided with two build options. One debug and one release. The release build will create the executable for the OS in which it is run.
Good Luck!

Cannot find -lpthread?

I am new to C programming.
I was trying to use the pthread API to write some concurrent program.
I downloaded eclipse IDE for C/C++ Developers, MinGW. I have put all the library, header files into the corresponding location of the MinGW file.
When I tried to build the project, there is always an error "cannot find -lpthread", what happened?
I have added the "-pthread" to the GCC compiler.
I have searched a lot in Google but seems no one have similar problem as me.
The answer to this question by someone who is also missing MinGW pthread library should help you out! Essentially the issue is that the MinGW installer script might not download the lpthread library upon installation. Quoted from link:
Just run and open MinGW Installation Manager, which should be pre-installed with MinGW, select "All Packages" on the left panel, and on the right panel, search for "mingw32-pthreads-w32" packages and install them.
I downloaded eclipse IDE for C/C++ Developers, MinGW.
MingGW uses the Windows API. The Windows API does not provide PThreads.
You need to install PThreads for Win32 to have PThreads available under Windows, and with this available under MinGW.
Eclipse is not configured to put the -pthread argument in the gcc compilation. To solve this, go to the Menu:
view sourceprint?
1.Project -> Properties
From the bar on the left:
view sourceprint?
1.c/c++ build -> GCC C Compiler -> Miscellaneous
Add the “-pthread” argument into the beginning of the “Other Flags” Also go to:
view sourceprint?
1.c/c++ build -> Settings -> GCC C Linker -> Libraries
And include the “pthread”library into the other libraries. Click Apply and rebuild the project. Pthreads must work now.
See the question on mingw.org. I ended up with adding 'C:/cygwin/lib' to the settings for the "Library search path (-L)" at properties >> c/c++ build >> settings >> MinGW C Linker >> Libraries.

C/C++ Run/Debug configuration in Eclipse

I am new to C/C++ development in Eclipse and trying to configure Eclipse. I'm working in a Linux environment with GNU GCC and my toolchain is detected by Eclipse. As given in the Eclipse documentation 1, I opened Run>>Run configurations. But the C/C++ Local tab is not there.
This is all I get.
But when I build a sample helloworld program, it's being built correctly.
Any idea why this happens?
1 http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_run_com.htm
I faced same issue as you. I was able to create and build one c/c++ project, but I couldn't run/debug it. Actually, I installed wrong CDT (CDT Visual C++ Support). Next I installed correct CDT (c/c++ development tools) and after one eclipse restart I had c/c++ application inside of Run Configuration.

What does Eclipse CDT come with?

This is what i currently have installed on my home computer:
http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2
Now, that was a pain to setup because you needed to use Cygwin to install a bunch of stuff in order for Eclipse to compile and run a C project. I found this the other day:
http://www.eclipse.org/cdt/
Does Eclipse CDT come with everything it needs to compile and run a C program or does it still depend on external files? Does it come with a standard library?
You do not have to use Cygwin and you can use alternatives such as mingw (it is simpler for most people to install). Checkout this tutorial for detailed description how to setup on Windows:
http://www.banym.de/eclipse/install-eclipse-cdt-on-windows-7
Compiler is responsible for standard library and in the case mentioned above it is mingw.
If you are on other hand interested about MAC OS installation checkout:
http://forge.mysql.com/wiki/Eclipse/CDT_on_Linux_and_Mac_OS_X
http://max.berger.name/howto/cdt/cdt.jsp

How to install C Compiler to Eclipse?

I have install the C/C++ CDT Version of Eclipse.
After making a HelloWorld.c file and get the code in there I get an error of "Launch failed. Binary not found".
I found in google that my Eclipse miss the compiler and I install MinGW on my computer and add the path to env variables (tested it with "gcc -v" in cmd and succeded).
But poorly it get the same Launch Failed error - any ideas, what step I forgot?
Some things to check:
1.) MinGW tools are installed as well. Make sure you have the C compiler and the Make program
2.) Check your Environment variables. Make sure both the compiler and Make are on the path.
3.) Eclipse is a temperamental beast at times, don't lose heart :-)
4.) If you're looking for a good IDE (without care for ideological concerns), might be worth looking at Bloodshed C++ IDE and Visual C++ 2010 express (or whatever they call their free version).
5.) Check the options menu in Eclipse to make sure it's looking at the correct environment variables for finding the Path.
IMHO, the simplest setup for eclipse on windows these days is cygwin - it seems to have been updated more recently than mingw, and works better.
Go to http://www.cygwin.com/, download the installer, select the default directory of c:\cygwin. Select 'All users'.
When it offers a list of packages, select 'gcc', 'binutils' and 'make' under the 'devel' category.
Add c:\cygwin\bin to your windows environment PATH.
Make sure Eclipse knows where to find your gcc compiler. An easier way would be to use EasyEclipse until you are more comfortable with your dev env.
I needed to move from the MinGW gcc to the CygWin gcc - all the C++2011 works and others say it is a better option too. Download the CygWin binaries etc. and then open up Eclipse.
In project properties, C/C++ Build -> Environment and set the CYGWIN_HOME variable. This worked fine for me on Eclipse Kepler Windows 7 (64Bit)
I also put the cygwin bin directory at the front of my Windows PATH variable.
Full details here:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_o_home.htm
You can try installing wascana. It automatically set up GNU compiler for you on Windows.

Resources