News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Help with setup

Started by fanotto, December 05, 2008, 03:15:44 PM

Previous topic - Next topic

fanotto

Hi

I have installed Code::Blocks on a Debian 64b computer. I have some old cb project files which now do not work because cb does not find the included libraries (like <vector> and <time.h> or <glut.h>)and errors like "error: 'srand' was not declared in this scope". Do I have to declare the paths somewhere? Where?

Jenna

You don't need paths for standard libs, and the path to glut.h should already be set in your old project (if it has worked).

You are just missing some header files that are in dev-packages like libstdc++6-x.x-dev, linux-libc-dev, freeglut3-dev .
I guess you are also missing (at least) the g++-package (it depends on libstdc++6-x.x-dev) and most likely some more.

fanotto

#2
Quote from: jens on December 06, 2008, 10:14:45 AM
You don't need paths for standard libs, and the path to glut.h should already be set in your old project (if it has worked).

The old projects have worked.

Quote from: jens on December 06, 2008, 10:14:45 AM
You are just missing some header files that are in dev-packages like libstdc++6-x.x-dev, linux-libc-dev, freeglut3-dev .
I guess you are also missing (at least) the g++-package (it depends on libstdc++6-x.x-dev) and most likely some more.

I have all the packages you mention. So it have to be "some more".

I can locate the files and it looks ok to me.

:~$ locate glut.h
/usr/include/GL/freeglut.h
/usr/include/GL/glut.h
/usr/share/doc/freeglut3-dev/freeglut.html

:~$ locate time.h
/usr/include/mf-runtime.h
/usr/include/time.h
/usr/include/utime.h
/usr/include/bits/time.h
/usr/include/linux/time.h
/usr/include/linux/utime.h
/usr/include/sys/time.h
/usr/include/wx-2.8/wx/datetime.h
+ many more references.


edit: As for g++ I have plain g++ 4.3.2, not multilib version. I am not sure what the differences are.



Jenna

In this case, please turn on full commandline logging and post the build log output:

Change "Settings -> Compiler and debugger... -> Global compiler settings -> Other settings(rightmost tab)" "Compiler logging" to "Full commandline".

fanotto

-------------- Build: Debug in slange ---------------

g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/Color.cpp -o obj/Debug/Slangespill/Color.o
/home/xemil/c++/Slangespill/Color.cpp: In member function 'std::string Color::getColorString()':
/home/xemil/c++/Slangespill/Color.cpp:85: warning: control reaches end of non-void function
gcc -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/FrameTimer.c -o obj/Debug/Slangespill/FrameTimer.o
g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/Main.cpp -o obj/Debug/Slangespill/Main.o
g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/Point2D.cpp -o obj/Debug/Slangespill/Point2D.o
g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/Scene.cpp -o obj/Debug/Slangespill/Scene.o
g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/Tid.cpp -o obj/Debug/Slangespill/Tid.o
g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/Viewer.cpp -o obj/Debug/Slangespill/Viewer.o
g++ -Wall  -g    -I/usr/include  -c /home/xemil/c++/Slangespill/former.cpp -o obj/Debug/Slangespill/former.o
/home/xemil/c++/Slangespill/former.cpp: In member function 'void Base::setRPosition()':
/home/xemil/c++/Slangespill/former.cpp:43: error: 'srand' was not declared in this scope
/home/xemil/c++/Slangespill/former.cpp:44: error: 'rand' was not declared in this scope
Process terminated with status 1 (0 minutes, 3 seconds)
2 errors, 1 warnings

Jenna

Do you include stdlib.h from the libc6-dev package, or another header that implicitely includes this ?

fanotto

Quote from: jens on December 06, 2008, 03:47:20 PM
Do you include stdlib.h from the libc6-dev package, or another header that implicitely includes this ?

I have the following in former.cpp:

#include "Point2D.h"
#include "Color.h"
#include <string>
#include <vector>
#include <GL/glut.h>

#include "former.h"

#include "Viewer.h"

#include <time.h>
#include <unistd.h>
#include <queue>


using namespace std;


Jenna

Quote from: fanotto on December 06, 2008, 03:56:22 PM
Quote from: jens on December 06, 2008, 03:47:20 PM
Do you include stdlib.h from the libc6-dev package, or another header that implicitely includes this ?

I have the following in former.cpp:

#include "Point2D.h"
#include "Color.h"
#include <string>
#include <vector>
#include <GL/glut.h>

#include "former.h"

#include "Viewer.h"

#include <time.h>
#include <unistd.h>
#include <queue>


using namespace std;



I use gcc-4.2 as default compiler and srand is found.

To test it with gcc-4.3 I have set up an extra toolchain, and ...
... srand is no longer in scope.

Add #include <stdlib.h> and it should work.

fanotto

Thanks a lot Jens. It worked.

For now I am very confused about the standard libraries and STL and what to include where. But if I need to include less files for the functions I want it might be a good thing.  Been a while since programming at school and hope I can get into it as hobbyist.

Thanks again.