My code won't compile

General questions regarding the usage of CodeLite
Acidray121
CodeLite Curious
Posts: 1
Joined: Wed Feb 18, 2015 11:51 pm
Genuine User: Yes
IDE Question: C++
Contact:

My code won't compile

Post 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? :?:
Gibbon1
CodeLite Expert
Posts: 167
Joined: Fri Jul 22, 2011 5:32 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: My code won't compile

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: My code won't compile

Post by Jarod42 »

[OT] @Acidray121: you have a code balise to format your post correctly.
Gibbon1
CodeLite Expert
Posts: 167
Joined: Fri Jul 22, 2011 5:32 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: My code won't compile

Post 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"
JSeb
CodeLite Curious
Posts: 4
Joined: Wed May 13, 2015 3:48 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: My code won't compile

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: My code won't compile

Post by eranif »

Install a MinGW compiler as described here:
http://codelite.org/AddNewCompiler/AddNewCompiler
Avoid using MSYS with CodeLite

Eran
Make sure you have read the HOW TO POST thread
Post Reply