Code::Blocks Forums

User forums => Help => Topic started by: mark1977 on February 16, 2012, 06:03:11 pm

Title: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: mark1977 on February 16, 2012, 06:03:11 pm
Hi,

As soon as I start a new (let's say empty) project choosing the GNU GCC Compiler, the project opens this file:

c:\MinGW\lib\gcc\mingw32\4.6.1\include\c++\cstdlib

Which is strange. Then I add files to the project and attempt to build, but I get this error:

c:\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\cstdlib|176|error: '::llabs' has not been declared|

I have tried to compile from the command line using gcc and my own makefile - everything is fine. I'm using Windows 7 and Code::Blocks 10.05.

Is this something to do with C::B's include directories...? Any ideas?

Thanks,

Mark
Title: Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: stahta01 on February 16, 2012, 06:30:28 pm
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Title: Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: mark1977 on February 16, 2012, 07:03:02 pm
Thanks for the link, I enabled full command line and it didn't give any indication that CB was using any unusual include directories.

The problem seems to be the include line

#include <cstdlib>

Again I stress that this doesn't occur from the command line using g++. Does anybody know whereabouts I can look in CB's to see if it's doing anything suspicious?

Thanks,

Mark
Title: Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: oBFusCATed on February 16, 2012, 07:28:31 pm
The full log is this place. You see the exact commands it is executing.
If you execute them in a terminal they will fail with the same errors.

Please check your toolchain settings, because there is a chance they are wrong.
Also if you have two mingw versions, one in x:\mingw and the other in some other place, they might interfere, because mingw has hardcoded paths to x:\mingw.
Title: Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: mark1977 on February 16, 2012, 07:47:12 pm
The exact command is:

g++.exe -Wall -fexceptions  -g     -c "C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp" -o obj\Debug\HydroLa\CPP\SetParam.o

I can't run this in a terminal because it doesn't recognise obj as part of a path. But I can run the first part:

g++.exe -Wall -fexceptions  -g     -c "C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp"

Which compiles fine.

My toolchain paths are fine:

C:\MinGW

with everything in the usual \bin place...
Title: Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: oBFusCATed on February 16, 2012, 08:11:28 pm
cd to the root of your project for the -o option to work.

Then paste the full log and your default.cont file.
Title: Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
Post by: mark1977 on February 16, 2012, 08:35:41 pm
Thankyou Obfuscated.

If I change into the correct directory as suggested, the source compiles fine.

Here's my log:

Code
-------------- Build: Debug in CKat2 ---------------

g++.exe -Wall -fexceptions  -g     -c "C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp" -o obj\Debug\HydroLa\CPP\SetParam.o
In file included from C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp:6:0:
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/cstdlib:176:11: error: '::llabs' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/cstdlib:211:22: error: '__gnu_cxx::llabs' has not been declared
C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp: In function 'int SetParams(const char*)':
C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp:150:46: warning: operation on 'i' may be undefined [-Wsequence-point]
C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp:171:1: warning: control reaches end of non-void function [-Wreturn-type]
C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp: In function 'int openfile(const char*, std::vector<double>*)':
C:\Users\local admin\codes\CKat2\HydroLa\CPP\SetParam.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 3 warnings
 

and here's my default.conf :

http://pastebin.com/LrGd8qVC