Author Topic: gcc finds errors in cstdlib when compiling my code in C::B - why?  (Read 6952 times)

Offline mark1977

  • Multiple posting newcomer
  • *
  • Posts: 26
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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7070
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline mark1977

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
« Reply #2 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13165
    • Travis build status
Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
« Reply #3 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline mark1977

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
« Reply #4 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...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13165
    • Travis build status
Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
« Reply #5 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline mark1977

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: gcc finds errors in cstdlib when compiling my code in C::B - why?
« Reply #6 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