How does one configure Eclipse to compile using -std=c99? - c

The question is in the title. Using GCC version 3.4.5 on Windows Vista and a recent version of the Eclipse C/C++ IDE (not sure what version exactly because it's hard to figure out which version is the one for the whole IDE, but I downloaded it two weeks ago so it can't be that old).

This depends on the build system you use, but you can always try adding the "CFLAGS=-std=c99" as a build and/or environment variable the the builder.

Related

I have installed MinGW and codelite and everything works except showing "locals" when stoping at a breakpoint when debugging

I have installed recently on my windows 10 the MinGW for using it on C development plus codelite.
Everything works, I can compile and run programs, but I can't find the way to make the debugger show me the value of locals. I am newbie on software development world and I have no idea what can be missing.
I downloaded mingw, installed it for c and c++ languages, added the paths on the environment variables config and then installed codelite, where I could scan the MinGW compiler.
If anyone can guide, I would by highly grateful.
Best regards,

How to install working MinGW in my 32-bit Windows 10

I'm a complete newbie to programming and I want to start learning C. I downloaded Visual studio code and MinGW, then tried to execute a simple 'hello world'. However, I get this error:
This version of C:\MinGW\bin\gcc.exe is not compatible with the version of Windows you're running.
After some searching, I think I have figured out that it is because I'm using Windows 10 32-bit. I can't find helpful videos or tutorials. What should I do?
Try with MinGW-w64 (e.g. from https://winlibs.com/) instead of old MinGW, and make sure VSCode is properly configured for it (see: https://code.visualstudio.com/docs/cpp/config-mingw).

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.

How do I compile a .c file on my Mac?

How do I compile a .c file on my Mac?
You'll need to get a compiler. The easiest way is probably to install XCode development environment from the CDs/DVDs you got with your Mac, which will give you gcc.
Then you should be able compile it like
gcc -o mybinaryfile mysourcefile.c
You will need to install the Apple Developer Tools. Once you have done that, the easiest thing is to either use the Xcode IDE or use gcc, or nowadays better cc (the clang LLVM compiler), from the command line.
According to Apple's site, the latest version of Xcode (3.2.1) only runs on Snow Leopard (10.6) so if you have an earlier version of OS X you will need to use an older version of Xcode. Your Mac should have come with a Developer Tools DVD which will contain a version that should run on your system. Also, the Apple Developer Tools site still has older versions available for download. Xcode 3.1.4 should run on Leopard (10.5).
In 2017, this will do it:
cc myfile.c
Just for the record in modern times,
for 2017 !
1 - Just have updated Xcode on your machine as you normally do
2 - Open terminal and
$ xcode-select --install
it will perform a short install of a minute or two.
3 - Launch Xcode. "New" "Project" ... you have to choose "Command line tool"
Note - confusingly this is under the "macOS" tab.
Select "C" language on the next screen...
4- You'll be asked to save the project somewhere on your desktop. The name you give the project here is just the name of the folder that will hold the project. It does not have any importance in the actual software.
5 - You're golden! You can now enjoy c with Mac and Xcode.
You can use gcc, in Terminal, by doing gcc -c tat.c -o tst
however, it doesn't come installed by default. You have to install the XCode package from tour install disc or download from http://developer.apple.com
Here is where to download past developer tools from, which includes XCode 3.1, 3.0, 2.5 ...
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.3.3.3.1
Ondrasej is the "most right" here, IMO.
There are also gui-er ways to do it, without resorting to Xcode. I like TryC.
Mac OS X includes Developer Tools, a developing environment for making
Macintosh applications. However, if someone wants to study programming
using C, Xcode is too big and too complicated for beginners, to write
a small sample program. TryC is very suitable for beginners.
You don't need to launch a huge Xcode application, or type unfamiliar
commands in Terminal. Using TryC, you can write, compile and run a C,
C++ and Ruby program just like TextEdit. It's only available to
compile one source code file but it's enough for trying sample
programs.
Use the gcc compiler. This assumes that you have the developer tools installed.
STEP 1
Just check wheater your MacBook has the compiler or not using this command 👉🏻 clang --version in your command line interface. If the tool exists then you will be able to see the version like this
STEP 2
Next, go to the directory where your source code exists using CMD Interface, then run the command make "filename" without the .c extension.
STEP 3
The final command to run your source code after compiling it is ./filename without the .c extension.
This is how you can compile and run your program on the Macintosh system.

Resources