C HelloWorld build fails

General questions regarding the usage of CodeLite
CodeLitely
CodeLite Curious
Posts: 6
Joined: Thu Dec 22, 2011 2:47 pm
Genuine User: Yes
IDE Question: C++
Contact:

C HelloWorld build fails

Post by CodeLitely » Fri Jan 06, 2012 2:20 pm

I am using CodeLite 3.5.5377 on Windows 7. I have successfully compiled and run a HelloWorld C++ Console Application. I am now trying to do a C HelloWorld console application. I made a workspace LearningC, and a new project HelloWorld. For the project I selected "Console" and "Simple executable (gcc)". After a trivial modification to the main.cpp that it creates, I tried to build and was unsuccessful. There is a "warning" about not finding stdio.h. I don't recall having to tell a compiler about headers in the standard C library before. It also says that the build had 0 errors and 1 warnings. However, in the Debug directory, there is no executable file. This is the build output:
_________________________________________________________________________________________________
----------Build Started--------
C:\Windows\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "LearningC_wsp.mk""
----------Building project:[ HelloWorld - Debug ]----------
mingw32-make.exe[1]: Entering directory `c:/Home/CodeLite/LearningC/HelloWorld'
c:/Home/CodeLite/LearningC/HelloWorld/main.c:1: warning: No include path in which to find stdio.h
gcc: unrecognized option `-MP'
gcc: unrecognized option `-MT./Debug/main.o'
gcc: unrecognized option `-MF./Debug/main.o.d'
main.o: c:/Home/CodeLite/LearningC/HelloWorld/main.c
gcc -c "c:/Home/CodeLite/LearningC/HelloWorld/main.c" -g -O0 -Wall -o ./Debug/main.o -I. -I.
c:/Home/CodeLite/LearningC/HelloWorld/main.c:1: stdio.h: No such file or directory
mingw32-make.exe[1]: *** [Debug/main.o] Error 1
mingw32-make.exe[1]: Leaving directory `c:/Home/CodeLite/LearningC/HelloWorld'
mingw32-make.exe: *** [All] Error 2
----------Build Ended----------

User avatar
eranif
CodeLite Plugin
Posts: 6122
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: C HelloWorld build fails

Post by eranif » Fri Jan 06, 2012 2:40 pm

I am not sure which codelite you installed, but you have a broken compiler (or codelite is picking the wrong compiler)
Either fix it, or install the cone that comes with codelite

In any case, its an environment problem
Eran
Make sure you have read the HOW TO POST thread

CodeLitely
CodeLite Curious
Posts: 6
Joined: Thu Dec 22, 2011 2:47 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: C HelloWorld build fails

Post by CodeLitely » Sat Jan 07, 2012 9:00 am

eranif wrote:I am not sure which codelite you installed, but you have a broken compiler (or codelite is picking the wrong compiler)
Either fix it, or install the cone that comes with codelite

In any case, its an environment problem
Eran
I am using the version that has minGW and wxWidgets included.

I typed "gcc --version" at the command line and got 2.95. This is coming from a version that came with Free Pascal (the MingGW-4.6.1 is not in the PATH). Rather than modify the path I changed the "PATH environment variable" edit box in Settings->Build Settings->gnu gcc->Tools to "C:\MinGW-4.6.1\bin". This fixed the compile error. Thanks!

I need to add more to the path as it couldn't find "makedir", but it seems like the build process has a bug as at the end (as in my original output) it reports "0 errors...", when it did have an error and did not create the executable:
__________________________________________________________________________________________________________
----------Build Started--------
C:\Windows\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "LearningC_wsp.mk""
----------Building project:[ HelloWorld - Debug ]----------
mingw32-make.exe[1]: Entering directory `c:/Home/CodeLite/LearningC/HelloWorld'
'makedir' is not recognized as an internal or external command,
operable program or batch file.
mingw32-make.exe[1]: *** [Debug/.d] Error 1
mingw32-make.exe[1]: *** Waiting for unfinished jobs....
mingw32-make.exe[1]: Leaving directory `c:/Home/CodeLite/LearningC/HelloWorld'
mingw32-make.exe: *** [All] Error 2
----------Build Ended----------
0 errors, 0 warnings

CodeLitely
CodeLite Curious
Posts: 6
Joined: Thu Dec 22, 2011 2:47 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: C HelloWorld build fails

Post by CodeLitely » Sat Jan 07, 2012 9:00 am

duplicate post
Last edited by CodeLitely on Sat Jan 07, 2012 9:02 am, edited 1 time in total.

User avatar
eranif
CodeLite Plugin
Posts: 6122
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: C HelloWorld build fails

Post by eranif » Sat Jan 07, 2012 10:46 am

CodeLitely wrote: Rather than modify the path I changed the "PATH environment variable" edit box in Settings->Build Settings->gnu gcc->Tools to "C:\MinGW-4.6.1\bin". This fixed the compile error. Thanks!
What you did here is override the PATH environment variable instead of prepending the MinGW's bin directory

Set it to:

Code: Select all

C:\MinGW-4.6.1\bin;$(PATH)
And restart codelite

Eran
Make sure you have read the HOW TO POST thread

CodeLitely
CodeLite Curious
Posts: 6
Joined: Thu Dec 22, 2011 2:47 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: C HelloWorld build fails

Post by CodeLitely » Sun Jan 08, 2012 5:59 am

eranif wrote:
CodeLitely wrote: Rather than modify the path I changed the "PATH environment variable" edit box in Settings->Build Settings->gnu gcc->Tools to "C:\MinGW-4.6.1\bin". This fixed the compile error. Thanks!
What you did here is override the PATH environment variable instead of prepending the MinGW's bin directory

Set it to:

Code: Select all

C:\MinGW-4.6.1\bin;$(PATH)
I missed in the tooltip that you could use the existing PATH as well in that edit box. That's handy. But my intention was to completely override the PATH environment variable to avoid the possibility of any programs being invoked from the wrong directory. I set it to:

C:\MinGW-4.6.1\bin;c:\Program Files (x86)\CodeLite

and HelloWorld compiled OK.

Post Reply