Jump to content
  • Advertisement
Sign in to follow this  
Splinter of Chaos

Makefile troubles

This topic is 3590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm getting a little more hardcore into my work environment (Vim, makefiles, etc.) and I just can't seem to get gcc to recognize SDL. I put SDL's include folder in gcc's include folder and I now have an SDL folder right next to GL in minGW\include. It can't find the SDL folder. I think the problem is it doesn't expect it to be there. I'll put SDL.h in the include folder and it's findable. Anything in the GL folder is findable. How to I show it how to find SDL's folder? (And preferably a solution that doesn't involve me writing the path to it in every make file, and for every additional library I use.)

Share this post


Link to post
Share on other sites
Advertisement
SDL includes an app to return the locations and flags required to find and correctly compile. The commands are:
$ sdl-config --cflags

$ sdl-config --libs


On my system, this produces:
-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT

-lSDL -lpthread



For a Makefile you would do something like this:
CFLAGS=-O2 -W -Wall -pedantic
LIBS=-lGL -lGLU -lglut

SDL_CFLAGS := $(shell sdl-config --cflags)
SDL_LDFLAGS := $(shell sdl-config --libs)

CPPFLAGS=$(CFLAGS) $(SDL_CFLAGS)
LDFLAGS=$(LIBS) $(SDL_LDFLAGS)

Share this post


Link to post
Share on other sites
Windows XP. I installed it by copying the files to the right places. I followed Lazy Foo's tutorial to make sure I didn't miss any thing.
http://lazyfoo.net/SDL_tutorials/lesson01/windows/mingw/index.php

Might part of the problem be that I installed MinGW in a place other than c:\MinGW?

Share this post


Link to post
Share on other sites
Sorry, my mistake, that is for Linux makefiles. I should have noticed the mention of minGW.

You mentioned that you placed the include folder in minGW\include folder, which means you have the SDL headers in minGW\include\SDL. But you didn't mention if you had copied the SDL library files over, as specified by Lazy Foo's item #2. According to the tutorial you need to copy the files in SDL\lib folder to minGW\lib.

If thats not the problem then maybe you could post the error messages you receive when you try to compile.

Share this post


Link to post
Share on other sites
For your viewing pleasures (warning: long):

C:\WINDOWS\system32\cmd.exe /c make
g++ main.cpp -lmingw32 -lSDLmain -lSDL -mwindows
In file included from main.cpp:51:
Graphics.h:24:21: SDL/SDL.h: No such file or directory
Graphics.h:27:28: SDL/SDL_opengl.h: No such file or directory
Graphics.h:29:23: SOIL/SOIL.h: No such file or directory
In file included from Graphics.h:32,
from main.cpp:51:
Controller.h:19: error: ISO C++ forbids declaration of `SDL_Joystick' with no ty
pe
Controller.h:19: error: expected `;' before '*' token
Controller.h:20: error: `SDL_Event' does not name a type
Controller.h: In constructor `Controller::Controller()':
Controller.h:31: error: `SDL_GetKeyState' undeclared (first use this function)
Controller.h:31: error: (Each undeclared identifier is reported only once for ea
ch function it appears in.)
Controller.h:33: error: `joystick' undeclared (first use this function)
Controller.h:33: error: `SDL_JoystickOpen' undeclared (first use this function)
Controller.h:36: error: `SDL_GetError' undeclared (first use this function)
Controller.h: In member function `bool Controller::eventToProcess()':
Controller.h:50: error: `events' undeclared (first use this function)
Controller.h:50: error: `SDL_PollEvent' undeclared (first use this function)
Controller.h: In member function `bool Controller::userWantsQuit()':
Controller.h:55: error: `events' undeclared (first use this function)
Controller.h:55: error: `SDL_QUIT' undeclared (first use this function)
Controller.h:55: error: `SDLK_ESCAPE' undeclared (first use this function)
Controller.h: In member function `bool Controller::processMouse()':
Controller.h:64: error: `events' undeclared (first use this function)
Controller.h:64: error: `SDL_MOUSEBUTTONUP' undeclared (first use this function)

Controller.h:67: error: `SDL_BUTTON_LEFT' undeclared (first use this function)
Controller.h:70: error: `SDL_MOUSEBUTTONDOWN' undeclared (first use this functio
n)
Controller.h: In destructor `Controller::~Controller()':
Controller.h:82: error: `SDL_JoystickOpened' undeclared (first use this function
)
Controller.h:83: error: `joystick' undeclared (first use this function)
Controller.h:83: error: `SDL_JoystickClose' undeclared (first use this function)

In file included from main.cpp:51:
Graphics.h: At global scope:
Graphics.h:46: error: `GLuint' does not name a type
Graphics.h:49: error: expected constructor, destructor, or type conversion befor
e '*' token
Graphics.h:49: error: expected `,' or `;' before '*' token
Graphics.h:56: error: `HGLRC' does not name a type
Graphics.h:57: error: `HDC' does not name a type
Graphics.h:58: error: `HWND' does not name a type
Graphics.h:59: error: `HINSTANCE' does not name a type
Graphics.h: In function `bool getGL_Error()':
Graphics.h:74: error: `GLenum' undeclared (first use this function)
Graphics.h:74: error: expected `;' before "error"
Graphics.h:76: error: `error' undeclared (first use this function)
Graphics.h:76: error: `glGetError' undeclared (first use this function)
Graphics.h:76: error: `GL_NO_ERROR' undeclared (first use this function)
Graphics.h:85: error: `GL_INVALID_ENUM' undeclared (first use this function)
Graphics.h:89: error: `GL_INVALID_VALUE' undeclared (first use this function)
Graphics.h:93: error: `GL_INVALID_OPERATION' undeclared (first use this function
)
Graphics.h:97: error: `GL_STACK_OVERFLOW' undeclared (first use this function)
Graphics.h:101: error: `GL_STACK_UNDERFLOW' undeclared (first use this function)

Graphics.h:105: error: `GL_OUT_OF_MEMORY' undeclared (first use this function)
Graphics.h: In function `void finish()':
Graphics.h:123: error: `SDL_Quit' undeclared (first use this function)
Graphics.h: At global scope:
Graphics.h:127: error: `GLvoid' does not name a type
Graphics.h:147: error: `LRESULT' does not name a type
Graphics.h: In function `void init_GL()':
Graphics.h:215: error: `glClearColor' undeclared (first use this function)
Graphics.h:218: error: `glClearDepth' undeclared (first use this function)
Graphics.h:220: error: `GL_LEQUAL' undeclared (first use this function)
Graphics.h:220: error: `glDepthFunc' undeclared (first use this function)
Graphics.h:222: error: `GL_POLYGON_SMOOTH' undeclared (first use this function)
Graphics.h:222: error: `glEnable' undeclared (first use this function)
Graphics.h:223: error: `GL_LINE_SMOOTH' undeclared (first use this function)
Graphics.h:224: error: `GL_SMOOTH' undeclared (first use this function)
Graphics.h:224: error: `glShadeModel' undeclared (first use this function)
Graphics.h:231: error: `GL_PERSPECTIVE_CORRECTION_HINT' undeclared (first use th
is function)
Graphics.h:231: error: `GL_NICEST' undeclared (first use this function)
Graphics.h:231: error: `glHint' undeclared (first use this function)
Graphics.h:232: error: `GL_POLYGON_SMOOTH_HINT' undeclared (first use this funct
ion)
Graphics.h:234: error: `GL_PROJECTION' undeclared (first use this function)
Graphics.h:234: error: `glMatrixMode' undeclared (first use this function)
Graphics.h:235: error: `glLoadIdentity' undeclared (first use this function)
Graphics.h:236: error: `glOrtho' undeclared (first use this function)
Graphics.h:238: error: `GL_MODELVIEW' undeclared (first use this function)
Graphics.h: In function `bool initSDL_GL(int, int, int)':
Graphics.h:267: error: `SDL_INIT_EVERYTHING' undeclared (first use this function
)
Graphics.h:267: error: `SDL_Init' undeclared (first use this function)
Graphics.h:269: error: `SDL_GetError' undeclared (first use this function)
Graphics.h:275: error: `SDL_OPENGL' undeclared (first use this function)
Graphics.h:275: error: `SDL_SetVideoMode' undeclared (first use this function)
Graphics.h: In function `void draw_GL()':
Graphics.h:312: error: `glLoadIdentity' undeclared (first use this function)
Graphics.h:314: error: `glFlush' undeclared (first use this function)
Graphics.h:315: error: `SDL_GL_SwapBuffers' undeclared (first use this function)

Graphics.h:316: error: `GL_COLOR_BUFFER_BIT' undeclared (first use this function
)
Graphics.h:316: error: `GL_DEPTH_BUFFER_BIT' undeclared (first use this function
)
Graphics.h:316: error: `glClear' undeclared (first use this function)
Graphics.h: At global scope:
Graphics.h:322: error: `GLuint' does not name a type
Graphics.h: In function `void drawRect(GLfloat, GLfloat, bool)':
Graphics.h:370: error: `GL_QUADS' undeclared (first use this function)
Graphics.h:370: error: `glBegin' undeclared (first use this function)
Graphics.h:377: error: `glVertex2f' undeclared (first use this function)
Graphics.h:384: error: `glEnd' undeclared (first use this function)
Graphics.h:387: error: `glLoadIdentity' undeclared (first use this function)
Graphics.h: At global scope:
Graphics.h:400: error: variable or field `drawTex' declared void
Graphics.h:400: error: `drawTex' declared as an `inline' variable
Graphics.h:400: error: `GLuint' was not declared in this scope
Graphics.h:400: error: expected primary-expression before "w"
Graphics.h:400: error: expected primary-expression before "h"
Graphics.h:401: error: expected primary-expression before "bool"
Graphics.h:402: error: initializer expression list treated as compound expressio
n
Graphics.h:402: error: expected `,' or `;' before '{' token
Graphics.h:423: error: expected `,' or `...' before '*' token
Graphics.h:424: error: ISO C++ forbids declaration of `SDL_Color' with no type
Graphics.h: In function `Uint32 colorToUint32(int)':
Graphics.h:430: error: `color' undeclared (first use this function)
Graphics.h: In function `void clearScreen()':
Graphics.h:441: error: `SDL_Rect' undeclared (first use this function)
Graphics.h:441: error: expected `;' before "srnClear"
Graphics.h:442: error: `srnClear' undeclared (first use this function)
Graphics.h:444: error: `Uint16' has not been declared
Graphics.h:445: error: `Uint16' has not been declared
Graphics.h:447: error: `screen' undeclared (first use this function)
Graphics.h:447: error: `SDL_MapRGB' undeclared (first use this function)
Graphics.h:447: error: `SDL_FillRect' undeclared (first use this function)
In file included from main.cpp:52:
time.h:8:27: SDL/SDL_Timer.h: No such file or directory
In file included from main.cpp:52:
time.h: In constructor `Timer::Timer(Uint32)':
time.h:28: error: `SDL_GetTicks' undeclared (first use this function)
time.h: In member function `Uint32 Timer::set()':
time.h:48: error: `SDL_GetTicks' undeclared (first use this function)
time.h: In function `Uint32 getTicks()':
time.h:60: error: `SDL_GetTicks' undeclared (first use this function)
In file included from Character.h:11,
from main.cpp:54:
ScreenOb.h: In member function `virtual void ScreenOb::draw(GLfloat, GLfloat) co
nst':
ScreenOb.h:53: error: `glTranslatef' undeclared (first use this function)
ScreenOb.h:55: error: `glRotatef' undeclared (first use this function)
In file included from Character.h:74,
from main.cpp:54:
Box.h: In member function `virtual void Box::draw()':
Box.h:27: error: `GL_LINE_LOOP' undeclared (first use this function)
Box.h:27: error: `glBegin' undeclared (first use this function)
Box.h:28: error: `glVertex2f' undeclared (first use this function)
Box.h:32: error: `glEnd' undeclared (first use this function)
Box.h:34: error: `glLoadIdentity' undeclared (first use this function)
In file included from main.cpp:55:
Player.h: At global scope:
Player.h:11: error: `GLuint' does not name a type
In file included from Player.h:16,
from main.cpp:55:
Bullet.h: In member function `virtual void Bullet::draw()':
Bullet.h:34: error: `GL_TRIANGLE_STRIP' undeclared (first use this function)
Bullet.h:34: error: `glBegin' undeclared (first use this function)
Bullet.h:35: error: `glColor4fv' undeclared (first use this function)
Bullet.h:37: error: `glVertex2f' undeclared (first use this function)
Bullet.h:40: error: `glEnd' undeclared (first use this function)
Bullet.h:42: error: `glLoadIdentity' undeclared (first use this function)
In file included from main.cpp:55:
Player.h: In constructor `Player::Player()':
Player.h:33: error: `player_texture' undeclared (first use this function)
Player.h:34: error: `loadImage' undeclared (first use this function)
Player.h: In member function `virtual void Player::draw()':
Player.h:39: error: `GL_TEXTURE_2D' undeclared (first use this function)
Player.h:39: error: `glEnable' undeclared (first use this function)
Player.h:43: error: `player_texture' undeclared (first use this function)
Player.h:43: error: `drawTex' cannot be used as a function
In file included from main.cpp:56:
Map.h: At global scope:
Map.h:6: error: `GLuint' does not name a type
Map.h:16: error: `GLuint' does not name a type
In file included from main.cpp:56:
Map.h:24:3: warning: no newline at end of file
main.cpp: In function `int main(int, char**)':
main.cpp:70: error: `GL_TEXTURE_ENV' undeclared (first use this function)
main.cpp:70: error: `GL_TEXTURE_ENV_MODE' undeclared (first use this function)
main.cpp:70: error: `GL_MODULATE' undeclared (first use this function)
main.cpp:70: error: `glTexEnvf' undeclared (first use this function)
make: *** [Bounce] Error 1
shell returned 2
Hit any key to close this window...


Do note that when I use my IDE (CodeBlocks), everything's fine, except somehow I'm linking something wrong with OpenGL, but I only hear a complaint when I use SOIL (Simple OpenGL Image Library). The problem can probably be narrowed down to my lack of understanding of make files.

Thanks a lot for helping me out with this.

Share this post


Link to post
Share on other sites
Based on the lazy foo page you gave, it appears you are using the command line version of MinGW. I installed it to see the setup and successfully compiled the sample code given in the tutorial.

I'm assuming that you are able to compile the sample program from the tutorial, so it is likely your makefile causing the problem. Please post the makefile.

Share this post


Link to post
Share on other sites
Actually, I am not able to compile the example.


C:\Documents and Settings\Owner\Desktop\Programming\C++\WorkSpace\SDL testing>g+
+ -o myprogram.exe mysource.cpp -lmingw32 -lSDLmain -lSDL
mysource.cpp:9:21: SDL\SDL.h: No such file or directory
mysource.cpp: In function `int main(int, char**)':
mysource.cpp:14: error: `SDL_INIT_EVERYTHING' undeclared (first use this functio
n)
mysource.cpp:14: error: (Each undeclared identifier is reported only once for ea
ch function it appears in.)
mysource.cpp:14: error: `SDL_Init' undeclared (first use this function)
mysource.cpp:17: error: `SDL_Quit' undeclared (first use this function)

C:\Documents and Settings\Owner\Desktop\Programming\C++\WorkSpace\SDL testing>


Here's the makefile for the project I was doing:

Bounce :
g++ main.cpp -lmingw32 -lSDLmain -lSDL -mwindows


Not much to really look at, I know.

Share this post


Link to post
Share on other sites
try

g++ main.cpp -ISDL -lmingw32 -lSDLmain -lSDL -mwindows

or

g++ main.cpp -Ic:/mingw/include/SDL -lmingw32 -lSDLmain -lSDL -mwindows

Though, you should really separate compilation and linking into 2 separate steps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!