0

On Eclipse CDT Helios + Mingw64 + SDL2 + SDL_Image:

IMG_Init make the window not showing anymore.

This problem occurs only on Eclipse. Hand compile(using same configurations) on console and running it works fine.

This is my code:

#include <SDL2/SDL.h>
#include <SDL_image.h>

int main(int argc, char* argv[]) {   
    SDL_Init(SDL_INIT_EVERYTHING);
    IMG_Init(IMG_INIT_PNG);//this line is the issue
    SDL_Window *window = 0;
    window = SDL_CreateWindow("Hello World!",
                              SDL_WINDOWPOS_CENTERED,
                              SDL_WINDOWPOS_CENTERED,
                              640, 480,
                              SDL_WINDOW_SHOWN);   
    SDL_Delay(2000);    
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}
Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
Patric
  • 763
  • 1
  • 8
  • 17
  • 1
    Make sure you're linking with `SDL2_image`, not with `SDL_image`. – keltar Mar 31 '15 at 06:58
  • Iep, everything linked correctly ^^ It works in other environments, except on Eclipse. – Patric Apr 01 '15 at 18:49
  • Eclipse don't have its own compiler/linker, it uses gcc/ld. What is the difference between your compilation/linking line and the one you use in eclipse? Is there a `LD_PRELOAD`/`LD_LIBRARY_PATH`? – keltar Apr 02 '15 at 04:03
  • They are identical to the one I use on sublime text for eg. `// **** Build of configuration Debug for project main **** // **** Internal Builder is used for build **** // g++ -ID:\\GCC\\SDL2_image\\include\\ -ID:\\GCC\\SDL2_ttf\\include\\ -ID:\\GCC\\glm\\ -ID:\\GCC\\SDL2\\include\\ -O3 -g3 -Wall -c -fmessage-length=0 -std=c++11 -omain.o ..\main.cpp // g++ -LD:\\GCC\\SDL2\\lib\\x64\\ -LD:\\GCC\\SDL2_image\\lib\\x64\\ -LD:\\GCC\\SDL2_ttf\\lib\\x64\\ -omain.exe main.o -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf // Build complete for project main // Time consumed: 6328ms` – Patric Apr 02 '15 at 04:19

0 Answers0