Page 1 of 1

My code won't compile

Posted: Wed Feb 18, 2015 11:56 pm
by Acidray121
Hi, im new to CodeLite and to C++, trying to learn on my own from a hands-on approach. Anyway i have this code that i got from a book im reading (it's supposed to be a converter from Celsius to Fahrenheit):

Code: Select all

 // 
 // Program to convert temperature from Celsius degree 
 // units into Fahrenheit degree units: 
 // Fahrenheit = Celsius * (212 - 32)/100 + 32 
 // 
 #include <cstdio> 
 #include <cstdlib> 
 #include <iostream> 
 using namespace std; 
 int main(int nNumberofArgs, char* pszArgs[]) 
 {
 // enter the temperature in Celsius 
 int celsius; 
 cout << “Enter the temperature in Celsius:”; 
 cin >> celsius; 
 // calculate conversion factor for Celsius 
 // to Fahrenheit 
 int factor; 
 factor = 212 - 32; 
 // use conversion factor to convert Celsius 
 // into Fahrenheit values 
 int fahrenheit; 
 fahrenheit = factor * celsius/100 + 32; 
 // output the results (followed by a NewLine) 
 cout << “Fahrenheit value is:”; 
 cout << fahrenheit << endl; 
 // wait until user is ready before terminating program 
 // to allow the user to see the program results 
 system(“PAUSE”); 
 return 0; 
 }
when i try to compile and run, i get this error message:

C:\Windows\system32\cmd.exe /C " -j 2 -e -f Makefile"
'-j' is not recognized as an internal or external command,
operable program or batch file.
0 errors, 0 warnings

Please help me around this? :?:

Re: My code won't compile

Posted: Thu Feb 19, 2015 12:57 am
by Gibbon1
That looks like you do not have an entry for make in your compiler setting. Or you have no compilers installed (not sure).

Are you on Winders or Linux? Either way go to Settings->Build Settings->Compilers Tab and take a look.

See attached image.

Note about 'make.exe' under windows. Some versions are compiled to run under mysys or cygwin. If you use a cygwin/mysys make.exe with a native minGW compiler it will not work.

Also if mingw32-make.exe finds sh.exe in the path it WILL try to use it and fail, unless you force it to use CMD.exe via the command line as in

mingw32-make -j4 SHELL=cmd.exe

Note SHELL=cmd.exe is what forces mingw-32-make to used the dos shell.
-j4 is telling it to expect processor four cores to speed things up.

Re: My code won't compile

Posted: Thu Feb 19, 2015 12:36 pm
by Jarod42
[OT] @Acidray121: you have a code balise to format your post correctly.

Re: My code won't compile

Posted: Thu Feb 19, 2015 1:51 pm
by Gibbon1
Doesn't really matter the key bit is this

C:\Windows\system32\cmd.exe /C " -j 2 -e -f Makefile"

Should really look more like this

C:\Windows\system32\cmd.exe /C "C:/MinGW-4.8.1/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile"

Re: My code won't compile

Posted: Wed May 13, 2015 4:36 am
by JSeb
Gibbon1 wrote:Note about 'make.exe' under windows. Some versions are compiled to run under mysys or cygwin. If you use a cygwin/mysys make.exe with a native minGW compiler it will not work.
Any chance I could get some clarifications on that?

I have both C:\MinGW\bin\mingw32-make.exe and C:\MinGW\msys\1.0\bin\make.exe present on my system.

Under the compiler tab, I find by default the following command next to the Make tool:
C:/MinGW/bin/mingw32-make.exe -j2 SHELL=cmd.exe
But then it just won't compile ("No errors found" in the output console, but no exe generated).

When I try to change the Make command for
C:\MinGW\msys\1.0\bin\make.exe
Then I get
C:\Windows\system32\cmd.exe /C "C:/MinGW/msys/1.0/bin/make.exe -e -f Makefile"
----------Building project:[ HelloWorld - Release ]----------
make[1]: Entering directory `/c/DEVTEST/Hello/HelloWorld'
C:/MinGW/bin/g++.exe -c "C:/DEVTEST/Hello/HelloWorld/main.cpp" -O2 -Wall -DNDEBUG -o ./Release/main.cpp.o -I. -I.
make[1]: *** [Release/main.cpp.o] Error 1
make[1]: Leaving directory `/c/DEVTEST/Hello/HelloWorld'
make: *** [All] Error 2
1 errors, 0 warnings

Re: My code won't compile

Posted: Wed May 13, 2015 7:51 am
by eranif
Install a MinGW compiler as described here:
http://codelite.org/AddNewCompiler/AddNewCompiler
Avoid using MSYS with CodeLite

Eran