brick2
December 28th, 2013, 02:13 AM
Ok so I have installed libSDL1.2-dev and did the following in the Eclipse:
C/C++ Build>Settings - Tool Settings>GCC C Compiler - Include paths (-l)>"/usr/include/SDL"
C/C++ Build>Settings - Tool Settings>GCC C Linker - Libraries (-l)>"SDL"
After looking around on the net, there were a lot of people saying that it is in essence some sort of a linking error, and that the path to the libs should be included. How this would be done at this point I do not know nor whether this is a solution to the problem at hand. Here is my code and the build output.
#include <iostream>
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
using namespace std;
int main(int argc, char *argv[])
{
SDL_Init( SDL_INIT_EVERYTHING );
//Set memory usage
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
//Window title
SDL_WM_SetCaption( "Window", 0 );
//Window Size
SDL_SetVideoMode( 600, 400, 32, SDL_OPENGL );
//Screen color
glClearColor( 1, 1, 1, 1 ); // RED, GREEN, BLUE , APLHA
//Portion to be displayed
glViewport( 0, 0, 600, 400 );
//2D rendering
glMatrixMode( GL_PROJECTION );
//Save it
glLoadIdentity();
//Disable depth checking
glDisable( GL_DEPTH_TEST );
//5 seconds Delay
SDL_Delay( 5000 );
SDL_Quit();
}
BUILD OUTPUT:
Building target: XO_Game
Invoking: Cross G++ Linker
g++ -o "XO_Game" ./src/XO_Game.o -l"SDL"
./src/XO_Game.o: In function `main':
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:28: undefined reference to `glClearColor'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:31: undefined reference to `glViewport'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:34: undefined reference to `glMatrixMode'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:37: undefined reference to `glLoadIdentity'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:40: undefined reference to `glDisable'
collect2: ld returned 1 exit status
make: *** [XO_Game] Error 1
ERRORS:
undefined reference to `glClearColor'
undefined reference to `glViewport'
undefined reference to `glMatrixMode'
undefined reference to `glLoadIdentity'
undefined reference to `glDisable'
Using:
Ubuntu 12.04 LTS
Eclipse Kelper CDT
This is the matter that I need help with. One more time I am really sorry for my previous post that was a mistake on my part.
C/C++ Build>Settings - Tool Settings>GCC C Compiler - Include paths (-l)>"/usr/include/SDL"
C/C++ Build>Settings - Tool Settings>GCC C Linker - Libraries (-l)>"SDL"
After looking around on the net, there were a lot of people saying that it is in essence some sort of a linking error, and that the path to the libs should be included. How this would be done at this point I do not know nor whether this is a solution to the problem at hand. Here is my code and the build output.
#include <iostream>
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
using namespace std;
int main(int argc, char *argv[])
{
SDL_Init( SDL_INIT_EVERYTHING );
//Set memory usage
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
//Window title
SDL_WM_SetCaption( "Window", 0 );
//Window Size
SDL_SetVideoMode( 600, 400, 32, SDL_OPENGL );
//Screen color
glClearColor( 1, 1, 1, 1 ); // RED, GREEN, BLUE , APLHA
//Portion to be displayed
glViewport( 0, 0, 600, 400 );
//2D rendering
glMatrixMode( GL_PROJECTION );
//Save it
glLoadIdentity();
//Disable depth checking
glDisable( GL_DEPTH_TEST );
//5 seconds Delay
SDL_Delay( 5000 );
SDL_Quit();
}
BUILD OUTPUT:
Building target: XO_Game
Invoking: Cross G++ Linker
g++ -o "XO_Game" ./src/XO_Game.o -l"SDL"
./src/XO_Game.o: In function `main':
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:28: undefined reference to `glClearColor'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:31: undefined reference to `glViewport'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:34: undefined reference to `glMatrixMode'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:37: undefined reference to `glLoadIdentity'
/home/relax/workspace/XO_Game/Debug/../src/XO_Game.cpp:40: undefined reference to `glDisable'
collect2: ld returned 1 exit status
make: *** [XO_Game] Error 1
ERRORS:
undefined reference to `glClearColor'
undefined reference to `glViewport'
undefined reference to `glMatrixMode'
undefined reference to `glLoadIdentity'
undefined reference to `glDisable'
Using:
Ubuntu 12.04 LTS
Eclipse Kelper CDT
This is the matter that I need help with. One more time I am really sorry for my previous post that was a mistake on my part.