Author Topic: Help with setup  (Read 6882 times)

Offline fanotto

  • Single posting newcomer
  • *
  • Posts: 5
Help with setup
« on: December 05, 2008, 03:15:44 pm »
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?
« Last Edit: December 05, 2008, 03:20:23 pm by fanotto »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Help with setup
« Reply #1 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).

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.

Offline fanotto

  • Single posting newcomer
  • *
  • Posts: 5
Re: Help with setup
« Reply #2 on: December 06, 2008, 02:05:26 pm »
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.

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.


« Last Edit: December 06, 2008, 02:09:42 pm by fanotto »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Help with setup
« Reply #3 on: December 06, 2008, 03:08:33 pm »
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".

Offline fanotto

  • Single posting newcomer
  • *
  • Posts: 5
Re: Help with setup
« Reply #4 on: December 06, 2008, 03:34:20 pm »
-------------- 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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Help with setup
« Reply #5 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 ?

Offline fanotto

  • Single posting newcomer
  • *
  • Posts: 5
Re: Help with setup
« Reply #6 on: December 06, 2008, 03:56:22 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;


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Help with setup
« Reply #7 on: December 06, 2008, 04:47:31 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.

Offline fanotto

  • Single posting newcomer
  • *
  • Posts: 5
Re: Help with setup
« Reply #8 on: December 06, 2008, 08:43:39 pm »
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.