December 7th, 2013, 09:35 PM
How to run c compiler from commandline
I am new to this so please bear with me a moment.
dev-c++ 5.5.3 is installed.
I can write a "hello.c" file, compile, and then run from the ide or a command line.
I have not been able to find the .exe to compile from the command line (dos prompt I used to call it).
I looked in the MinGW32\bin and elsewhere.
I have read about needing to specify something in PATH, but I do not understand. My config.sys and autoexec.bat files are empty. Using windows xp.
Again I can use the IDE, I want to also be able to do everything from the command line. I think this is compile and link and debug if necessary.
Also what I have found online is usually for C++, but I am writing in c.
December 7th, 2013, 09:57 PM
I figured it out
I really have been searching for hours.Now I figured it out just after posting the question.
c:\MinGW32\bin\gcc.exe c:\01\hello.c -o c:\01\hello.exe
the examples I read left out:
c:\MinGW32\bin c:\01\ c:\01\
I always seem to get tripped up on simple things.
December 8th, 2013, 12:18 AM
Very well you overcome it yourself. Congratulations!
If you set up your PATH environment variable to include the folder where gcc.exe resides, you will make things much easier for you.
The other not-too-bad idea is to setup virtual machine (VirtualBox will do all right) and install Ubuntu in it, for example (download disk image and start virtual machine with it).
gcc is preexisting here with all paths set up. You can also use Ubuntu from bootable CD to try if you like it. Though if you do not want to install it and only run from CD for your exercises - Knoppix could be bit nicer.
Installing and using many developer tools under linux is somewhat easier in my opinion. They are included in repositories so you are usually only need to tell the system to install g++ or python or java, git or svn - and you have it in a few seconds.
December 8th, 2013, 10:47 PM
PATH environment variable. Nice. Now I work from the C:\ prompt.
I have Ubuntu 10.10 on a partition. It is old for my old computer, but I can compile in a terminal, and go online.
Ubuntu seems to "mount" in / but I am working in / home username (or / /home /username).
I do not know how my computer's name fits in, and I think this means I am not "running in root(as root?)"(not the folder root); but this is probably a question for a thread in the linux section of this forum.
Anyways, thank you very much!
January 8th, 2014, 09:07 PM
Actuall I have now put "C:\MinGW32\bin;" instead of "C:\MinGW32\bin\gcc.exe" into my PATH. Works better now.
January 9th, 2014, 11:41 PM
Sorry not trying to hijack your thread but I reg'd here to post a similar question..:
I'm trying to compile a hello.c type thing too but am getting an error.
Using TCC (tiny compiler) Maybe I should be using something else?
1: /* Hello.c: This is my first C program */
2: #include <stdio.h>
6: printf ("Hello. This is my first C program.\n");
7: return 0;
have this saved Hello.c in c:\tcc\
I type tcc Hello.c
and get "1:error: declaration expected"
Any ideas? When I use the tcc examples this way it compiles fine.
January 9th, 2014, 11:57 PM
whoops figured it out
When I took out the line numbers at the beginning of each line it worked.