나는이 같은 SDL2.0을 다운로드 한 : Cygwin 및 SDL 2.0 : 컴파일하는 방법?
~/tmp>wget http://www.libsdl.org/tmp/release/SDL2-2.0.0.tar.gz
그때 나는 그것을 압축을 푼 디렉토리로 가서
./configure && make && make install
했다. 모든 것이 잘되었습니다. 이제 아주 간단한 샘플을 만들었습니다 (아래 참조). 나는 그것이 작동하지 않습니다 컴파일 할 때 내 문제는, 그래서 현재 디렉토리에 SDL2.dll를 복사하고 내가 성공하지 알고있는 모든 조합을 시도 :
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -l SDL2.dll
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -lSDL2.dll
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -L SDL2.dll
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -LSDL2.dll
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -l SDL2
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -lSDL2
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -L SDL2
~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -LSDL2
모든 오류 중 하나입니다 :
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lSDL2.dll
collect2: error: ld returned 1 exit status
또는 :
[email protected] ~/tmp/SDL2-2.0.0 >gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -LSDL2.dll
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xe): undefined reference to `SDL_Init'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x42): undefined reference to `SDL_CreateWindow'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x50): undefined reference to `SDL_GetWindowSurface'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x67): undefined reference to `SDL_RWFromFile'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x77): undefined reference to `SDL_LoadBMP_RW'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x9c): undefined reference to `SDL_UpperBlit'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xa7): undefined reference to `SDL_UpdateWindowSurface'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xb2): undefined reference to `SDL_FreeSurface'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xda): undefined reference to `SDL_PollEvent'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xef): undefined reference to `SDL_DestroyWindow'
/cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xf4): undefined reference to `SDL_Quit'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o: bad reloc address 0x20 in section `.eh_frame'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status
당신은 어떻게 할 것인가?
는 여기에 내가 컴파일하려고 내 소스 코드입니다 :
이 Cygwin에서 작동 할 경우#include <SDL.h>
int main(int argc, char *argv[]) {
int running;
SDL_Window *window;
SDL_Surface *windowsurface;
SDL_Surface *image;
SDL_Event event;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow("Hello World",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
592, 460, SDL_WINDOW_SHOWN);
windowsurface = SDL_GetWindowSurface(window);
image = SDL_LoadBMP("exampleimage.bmp");
SDL_BlitSurface(image, NULL, windowsurface, NULL);
SDL_UpdateWindowSurface(window);
SDL_FreeSurface(image);
running = 1;
while (running) {
while (SDL_PollEvent(&event) != 0) {
if (event.type == SDL_QUIT) {
running = 0;
break;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
이와 같이 연결할 수 없습니다. '-lSDL2'-flag로 연결합니다. – Jocke