-2
我想跟隨在懶富一SDL2教程:http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php錯誤compilling SDL2代碼
我也做了教程和執行程序時出現在我的窗口,即使我得到了很多的編譯錯誤的時編譯教程代碼。當我使用g ++編譯器的錯誤是:
g++ sdl -w -lSDL2
sdl:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
sdl: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/crtbegin.o:(.data+0x0): first defined here
sdl: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crti.o:(.fini+0x0): first defined here
sdl: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o:(.text+0x0): first defined here
sdl: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crti.o:(.init+0x0): first defined here
sdl: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o:(.data+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/crtend.o:(.tm_clone_table+0x0): multiple definition of `\__TMC_END__'
sdl:(.data+0x10): first defined here
/usr/bin/ld: error in sdl(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: all] Error 1
我不知道這些編譯錯誤意味着什麼或如何解決它們。我嘗試使用gcc編譯器,但出現相同的錯誤。有人可以幫助我學習如何正確編譯SDL2代碼嗎?我的錯誤是什麼?我的Makefile文件如下:
# CC specifies which compiler we're using
CC = g++
# C_FLAGS specifies addicional compiler flags
CFLAGS = -w -lSDL2
#TARGETS specifies source files to be compiled
TARGETS = sdl
all: $(TARGETS)
$(CC) $(TARGETS) $(CFLAGS)
clean:
rm -f $(TARGETS)
'#TARGETS指定的源文件,以實際compiled'沒有,但指定的目標。 –
你有自己的標題嗎?你忘記了一名頭球后衛嗎? –
什麼是您試圖鏈接到libsdl的'sdl'文件?它從哪裏來的?源文件是否保存在該文件中?如果是這樣 - 它只是提出問題,而'-w'則讓編譯器確信你確實需要這些問題。 – keltar