-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