I cannot make SDL + OpenGL work in Visual Studio 2012

I just started a tutorial on learning C ++ OpenGL using SDL. The steps shown in the video were done using an IDE called Code Blocks, but I thought it would work for Visual Studio 2012 as well.

I downloaded the SDL2 developer, which is designed for Windows x64 (my Windows 7 has 64 bits, but Visual Studio 2012 I have x86 version)

To install SDL2 in Visual Studio 2012, I installed:

  • .h files in the include folder (D: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ include \ SDL).
  • .lib files in the lib folder (D: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ lib \ SDL).
  • The .dll file in the C: / Windows / system folder.

After that, I opened the IDE, created a new project, and when I wrote the code, autocomplete appeared for certain SDL functions, which means success ... until I tried to start it.

This is the code I wrote according to the video:

#include "SDL.h"

int main(int argc, char* args[]){
    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_Quit();

    return 0;
}

When I click "Start debugging" or "Start without debugging", after clicking "yes" to create it, the output comes up with errors.

Here is a screenshot of the code I wrote, plus the output:

Screenshot of non-working opengl sdl in visual studio 2012

After that, I tried an older version of SDL, which the tutorial already used, which was 1.2 (I overwritten several files of a newer version), but still have not received good results.

How to fix this so that I can practice with OpenGL + SDL features?

+3
source share
2 answers

<sub> TL; DR: sub>

,

  • (#include <*.h>) include ,
  • lib (*.lib, , ) ,
  • (*.dll), , .lib ( VS , )

#include <SDL.h>, , , . , , , . , ++ Include Visual Studio 2012 ( 2011 2010). SDL.h include, - . , <SDL/SDL.h> - .

#include . . , , , , ( .lib), , ( .dll, , .lib, ).

, include . , #include <SDL.h>, , , SDL.h SDL.lib ( , SDL.dll). , #pragma, , . ScottMcP-MVP, SDL.lib Project Properties->Configuration Properties->Linker->Input->Additional Dependencies. unresolved external, , , . - SDL.h SDL.lib SDL.lib .

, , , , , "" SDL_Init, , / -- , .

, /recap, GUI /. , , :

./compiler -I/path/to/my/includes -L/path/to/my/lib -lmylibrary.lib mycode.cpp  -o myexecutable.exe

mycode.cpp #include <mylibrary.h>. , ./compiler , . :

./compiler -I/path/to/my/includes mycode.cpp -o mycompiledcode.o
./linker -L/path/to/my/lib -lmylibrary.lib mycompiledcode.o -o myexecutable.exe

, SDL.dll . , , Windows. . linux rpath ( ). application configuration incorrect, dll , , dll . dll - .

. OpenGL - !


[EDIT]

x32 x64 lib, . , x32, double ram, . OpenGL x64, , , .

Additional Dependencies - , "SDL.lib". Visual Studio. SDL, .

_main, , * spit * SDL . #include <SDL.h> #undef main (, #ifdef ):

#include <SDL.h> //my include is <SDL2/SDL.h>, as I have both an SDL and SDL2 dir in my include path

#ifdef main
#undef main //remove SDL main() hook if it exists
#endif

: </> "/" - #include <filename> #include " " ?

+5

lib exe. . "", "", "", " ". lib.

+1

All Articles