当我运行时,make
我得到这个输出,表明它无法链接 SDL:
/usr/bin/ld: .libs/text.o:/home/mint/libgraph-1.0.2/grtext.h:77: multiple definition of `InternalFont'; .libs/libgraph.o:/home/mint/libgraph-1.0.2/grtext.h:77: first defined here
/usr/bin/ld: .libs/text.o:/home/mint/libgraph-1.0.2/grtext.h:87: multiple definition of `TP'; .libs/libgraph.o:/home/mint/libgraph-1.0.2/grtext.h:87: first defined here
/usr/bin/ld: .libs/shapes.o:/home/mint/libgraph-1.0.2/shapes.h:121: multiple definition of `_internal_linestyle'; .libs/libgraph.o:/home/mint/libgraph-1.0.2/shapes.h:121: first defined here
/usr/bin/ld: .libs/shapes.o:/home/mint/libgraph-1.0.2/shapes.h:115: multiple definition of `_last_arc'; .libs/libgraph.o:/home/mint/libgraph-1.0.2/shapes.h:115: first defined here
/usr/bin/ld: .libs/polygon.o:/home/mint/libgraph-1.0.2/polygon.h:42: multiple definition of `_scanlist'; .libs/libgraph.o:/home/mint/libgraph-1.0.2/polygon.h:42: first defined here
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libSDL_image.a(IMG_xcf.o): warning: relocation against `stderr@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libSDL_image.a(IMG_xcf.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:377: libgraph.la] Error 1
make[1]: *** [Makefile:552: all-recursive] Error 1
make: *** [Makefile:268: all] Error 2
“./configure”的输出:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for egrep... grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking how to recognise dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... f77
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether f77 accepts -g... yes
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc static flag works... yes
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for f77 option to produce PIC... -fPIC
checking if f77 PIC flag -fPIC works... yes
checking if f77 supports -c -o file.o... yes
checking whether the f77 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking for gawk... (cached) gawk
checking for sdl-config... /usr/bin/sdl-config
checking for SDL - version >= 1.2.0... yes
checking SDL ==> SDL_image library... SDL_image = yes
checking for Guile... yes
checking for rint in -lm... yes
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking for unistd.h... (cached) yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking return type of signal handlers... void
checking for vprintf... yes
checking for _doprnt... no
checking for atexit... yes
checking for putenv... yes
checking for rint... yes
checking for strdup... yes
configure: creating ./config.status
config.status: creating doc/Makefile
config.status: creating doc/man/Makefile
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
“./configure CFLAGS=-fcommon”的输出:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for egrep... grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking how to recognise dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... f77
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether f77 accepts -g... yes
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc static flag works... yes
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for f77 option to produce PIC... -fPIC
checking if f77 PIC flag -fPIC works... yes
checking if f77 supports -c -o file.o... yes
checking whether the f77 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking for gawk... (cached) gawk
checking for sdl-config... /usr/bin/sdl-config
checking for SDL - version >= 1.2.0... yes
checking SDL ==> SDL_image library... SDL_image = yes
checking for Guile... yes
checking for rint in -lm... yes
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking for unistd.h... (cached) yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking return type of signal handlers... void
checking for vprintf... yes
checking for _doprnt... no
checking for atexit... yes
checking for putenv... yes
checking for rint... yes
checking for strdup... yes
configure: creating ./config.status
config.status: creating doc/Makefile
config.status: creating doc/man/Makefile
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
“制作”的输出
Makefile:934: warning: overriding recipe for target 'libgraph.pc'
Makefile:409: warning: ignoring old recipe for target 'libgraph.pc'
Makefile:934: warning: overriding recipe for target 'libgraph.pc'
Makefile:409: warning: ignoring old recipe for target 'libgraph.pc'
Makefile:934: warning: overriding recipe for target 'libgraph.pc'
Makefile:409: warning: ignoring old recipe for target 'libgraph.pc'
text.c: In function 'grgetch':
text.c:289:8: warning: implicit declaration of function 'refresh_interrupt' [-Wimplicit-function-declaration]
289 | refresh_interrupt(0);
| ^~~~~~~~~~~~~~~~~
text.c: In function 'kbhit':
text.c:336:4: warning: implicit declaration of function 'delay' [-Wimplicit-function-declaration]
336 | delay(100);
| ^~~~~
text.c: In function 'grscanf':
text.c:401:21: warning: passing argument 1 of 'vsscanf' from incompatible pointer type [-Wincompatible-pointer-types]
401 | num = vsscanf(&template,text,ap); // Guessing no of arguments
| ^~~~~~~~~
| |
| char (*)[21]
In file included from /usr/include/SDL/SDL_stdinc.h:37,
from /usr/include/SDL/SDL_main.h:26,
from /usr/include/SDL/SDL.h:30,
from grtext.h:25,
from text.c:24:
from text.c:24:
/usr/include/stdio.h:444:44: note: expected 'const char * restrict' but argument is of type 'char (*)[21]'
444 | extern int vsscanf (const char *__restrict __s,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~
text.c:447:17: warning: passing argument 1 of 'vsscanf' from incompatible pointer type [-Wincompatible-pointer-types]
447 | if (vsscanf(&input,text,ap) < num) break;
| ^~~~~~
| |
| char (*)[256]
In file included from /usr/include/SDL/SDL_stdinc.h:37,
from /usr/include/SDL/SDL_main.h:26,
from /usr/include/SDL/SDL.h:30,
from grtext.h:25,
from text.c:24:
/usr/include/stdio.h:444:44: note: expected 'const char * restrict' but argument is of type 'char (*)[256]'
444 | extern int vsscanf (const char *__restrict __s,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~
shapes.c: In function 'cleardevice':
shapes.c:34:5: warning: implicit declaration of function 'setbkcolor' [-Wimplicit-function-declaration]
34 | setbkcolor(getbkcolor());
| ^~~~~~~~~~
shapes.c:34:16: warning: implicit declaration of function 'getbkcolor' [-Wimplicit-function-declaration]
34 | setbkcolor(getbkcolor());
| ^~~~~~~~~~
shapes.c: In function 'moveto':
shapes.c:55:13: warning: implicit declaration of function 'getmaxx'; did you mean 'getx'? [-Wimplicit-function-declaration]
55 | CP.x = (x>getmaxx())? getmaxx() : x;
| ^~~~~~~
| getx
shapes.c:56:13: warning: implicit declaration of function 'getmaxy'; did you mean 'gety'? [-Wimplicit-function-declaration]
56 | CP.y = (y>getmaxy())? getmaxy() : y;
| ^~~~~~~
| gety
shapes.c: In function 'fastline':
shapes.c:76:12: warning: implicit declaration of function 'mapword' [-Wimplicit-function-declaration]
76 | x1<x2? mapword(x1, y1, dx) : mapword(x2, y2, dx);
| ^~~~~~~
shapes.c:79:14: warning: implicit declaration of function 'mapvword' [-Wimplicit-function-declaration]
79 | y1<y2? mapvword(x1, y1, dy) : mapvword(x2, y2, dy);
| ^~~~~~~~
shapes.c:89:4: warning: implicit declaration of function 'mappixel' [-Wimplicit-function-declaration]
89 | mappixel(x1, y1);
| ^~~~~~~~
shapes.c: In function 'line':
shapes.c:416:3: warning: implicit declaration of function 'safe_update' [-Wimplicit-function-declaration]
416 | safe_update(x1-_internal_linestyle.thickness, y1-_internal_linestyle.thickness,
| ^~~~~~~~~~~
shapes.c: In function 'pieslice':
shapes.c:544:33: warning: implicit declaration of function 'getcolor' [-Wimplicit-function-declaration]
544 | _boundaryfill((int)x, (int)y, getcolor());
| ^~~~~~~~
shapes.c: In function '_boundaryfill':
shapes.c:635:10: warning: implicit declaration of function 'getpixel' [-Wimplicit-function-declaration]
635 | curr = getpixel(x, y);
| ^~~~~~~~
polygon.c: In function 'drawpoly':
polygon.c:40:9: warning: implicit declaration of function 'line' [-Wimplicit-function-declaration]
40 | line(x1, y1, x2, y2);
| ^~~~
polygon.c: In function '_fillpoly':
polygon.c:94:3: warning: implicit declaration of function 'mappixel' [-Wimplicit-function-declaration]
94 | mappixel(curr->x,i);
| ^~~~~~~~
polygon.c:101:3: warning: implicit declaration of function 'mapword' [-Wimplicit-function-declaration]
101 | mapword(curr->x,i,p2->x-curr->x);
| ^~~~~~~
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libSDL_image.a(IMG_xcf.o): warning: relocation against `stderr@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libSDL_image.a(IMG_xcf.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:377: libgraph.la] Error 1
make[1]: *** [Makefile:552: all-recursive] Error 1
make: *** [Makefile:268: all] Error 2
答案1
首先要修复的是“多重定义”错误;要处理这个问题,请添加
CFLAGS=-fcommon
根据您的初始./configure
命令,IE
./configure CFLAGS=-fcommon ...
看GCC 10 移植说明了解详情。
我很惊讶构建与静态SDL_image
库链接。请编辑你的问题添加 的完整输出./configure
。