Quote: -------------- Build: Debug in simple --------------- Linking console executable: ../simple_debug obj/Debug/src/main.o: In function `main': ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:109: undefined reference to `SDL_Init' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:115: undefined reference to `SDL_GL_SetAttribute' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:116: undefined reference to `SDL_GL_SetAttribute' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:117: undefined reference to `SDL_GL_SetAttribute' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:118: undefined reference to `SDL_GL_SetAttribute' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:119: undefined reference to `SDL_GL_SetAttribute' obj/Debug/src/main.o:~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:120: more undefined references to `SDL_GL_SetAttribute' follow obj/Debug/src/main.o: In function `main': ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:123: undefined reference to `SDL_WM_SetCaption' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:126: undefined reference to `SDL_SetVideoMode' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:134: undefined reference to `SDL_Quit' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:144: undefined reference to `SDL_PollEvent' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:165: undefined reference to `SDL_GL_SwapBuffers' ~/Source Code/OpenGL 3.0/chapter_1/simple/src/main.cpp:168: undefined reference to `SDL_Quit' collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 0 seconds) 13 errors, 0 warningsany thoughts? oh i'm a noob at programming!
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
"Beginning OpenGL Game Programming II" 1st sdl code error
Hello, i've downloaded the latest bugfix of the sample code for "Beginning OpenGL Game Programming II" and when i try to compile the ch 1 "simple" with code::block under linux i get those SDL errors:
Looks like you've forgotten to link your program with the SDL library.
Not sure how you do it in Code::Blocks, but using vanilla gcc it would usually just be a matter of adding the argument -lSDL to the compiler.
Not sure how you do it in Code::Blocks, but using vanilla gcc it would usually just be a matter of adding the argument -lSDL to the compiler.
No. SDL, and other libraries as well, ships with two parts: header files and library files.
Header files contains function declarations which is only used to tell the compiler what function are available for use. Any time you #include a header file, you're basicly telling the compiler "You may not know exactly what these functions are, but it's ok to use them because I'll provide them later."
Library files on the other hand contains the actual fragments of executable machine code for those functions.
Once it's time for the compiler to link all your bits and pieces of code into the final executable, you need to tell the compiler where it should look for the code for the functions that you haven't already supplied. This is where the arguments to the linker come into play. The -lSDL argument I mentioned before tells gcc: "If I've tried to use a function that you can't find, you should also try looking for it in the file called libSDL.so".
So, you need to find a way to specify in code::blocks in which files it should look for functions that you don't supply yourself. A bit of googling turned up this thread, which should point you in the right direction.
Header files contains function declarations which is only used to tell the compiler what function are available for use. Any time you #include a header file, you're basicly telling the compiler "You may not know exactly what these functions are, but it's ok to use them because I'll provide them later."
Library files on the other hand contains the actual fragments of executable machine code for those functions.
Once it's time for the compiler to link all your bits and pieces of code into the final executable, you need to tell the compiler where it should look for the code for the functions that you haven't already supplied. This is where the arguments to the linker come into play. The -lSDL argument I mentioned before tells gcc: "If I've tried to use a function that you can't find, you should also try looking for it in the file called libSDL.so".
So, you need to find a way to specify in code::blocks in which files it should look for functions that you don't supply yourself. A bit of googling turned up this thread, which should point you in the right direction.
wow that actually helped me a lot thank you very much! I'll post as soon as i get the the compiled code!
Cheers
ok i've succes fully compiled the Code thanks to you Luctus!
Cheers
ok i've succes fully compiled the Code thanks to you Luctus!
Hi Setlec,
I'll take a look at this, you aren't the first person to report this linking problem with the first example. I'm away for the next week, but I'll fix up a new version asap. Glad you got it working OK in the end.
Luke.
I'll take a look at this, you aren't the first person to report this linking problem with the first example. I'm away for the next week, but I'll fix up a new version asap. Glad you got it working OK in the end.
Luke.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement