我自己也没有写过这个程序,也不是我对cygwin和linux的经验,但从我可以告诉的文件似乎有正确的包括:
// tsim_argp.c
#include <argp.h>
#include <stdlib.h>
#include <unistd.h> /* nice */
#include "tsim_argp.h"
包含argp_usage的argp.h还包含了包含INT_MAX的limits.h所以我到底错过了什么?我得到了所有其他的c文件编译得很好,这只是最后一个引起问题的文件。
进行对话:
...
Making all in src
make[2]: Entering directory '/cygdrive/c/Users/David/Downloads/tsim-0.84/src'
gcc -DHAVE_CONFIG_H -I. -I.. -std=gnu99 -pedantic -Wall -Wextra -Wmissing-pro
totypes -DRESDIR=\"/c/Users/David/Downloads/Train_Simulator/share/tsim\" -g -O2
-MT tsim-tsim_argp.o -MD -MP -MF .deps/tsim-tsim_argp.Tpo -c -o tsim-tsim_argp.o
`test -f 'tsim_argp.c' || echo './'`tsim_argp.c
tsim_argp.c: In function 'setpriority':
tsim_argp.c:170:19: error: 'INT_MAX' undeclared (first use in this function)
if( priority == INT_MAX ) {
^
tsim_argp.c:170:19: note: each undeclared identifier is reported only once for e
ach function it appears in
...
Makefile:479: recipe for target 'tsim-tsim_argp.o' failed
make[2]: *** [tsim-tsim_argp.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/David/Downloads/tsim-0.84/src'
Makefile:247: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/David/Downloads/tsim-0.84'
Makefile:169: recipe for target 'all' failed
make: *** [all] Error 2
如果我直接在tsim_argp中包含limits.h库,则进行对话:
...
Making all in src
make[2]: Entering directory '/cygdrive/c/Users/David/Downloads/tsim-0.84/src'
gcc -std=gnu99 -pedantic -Wall -Wextra -Wmissing-prototypes -DRESDIR=\"/c/Users/
David/Downloads/Train_Simulator/share/tsim\" -g -O2 -L/usr/X11R6/lib -lXaw -lXt
-lXmu -lX11 -lXext -o tsim.exe tsim-AddToggleWidget.o tsim-DialogPopup.o tsim-f
ile.o tsim-resources.o tsim-timer.o tsim-tsim.o tsim-bitmap.o tsim-DrawingPalett
e.o tsim-Graph.o tsim-sound.o tsim-train.o tsim-BitmapDirectory.o tsim-errcheck.
o tsim-pipe.o tsim-Sprite.o tsim-tsim_argp.o -lXt -lXmu -lXext -lXaw -lX11
tsim-tsim_argp.o: In function `parse_opt':
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:113: undefined refer
ence to `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:113:(.text+0xbe): re
location truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:83: undefined refere
nce to `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:83:(.text+0x10e): re
location truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:98: undefined refere
nce to `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:98:(.text+0x15c): re
location truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:68: undefined refere
nce to `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:68:(.text+0x1a3): re
location truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:118: undefined refer
ence to `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:118:(.text+0x294): r
elocation truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
tsim-tsim_argp.o:/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:103
: more undefined references to `argp_usage' follow
tsim-tsim_argp.o: In function `parse_opt':
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:103:(.text+0x2c4): r
elocation truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:73:(.text+0x2f4): re
location truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:88:(.text+0x324): re
location truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:127:(.text+0x354): r
elocation truncated to fit: R_X86_64_PC32 against undefined symbol `argp_usage'
tsim-tsim_argp.o: In function `parse':
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:234: undefined refer
ence to `argp_parse'
/cygdrive/c/Users/David/Downloads/tsim-0.84/src/tsim_argp.c:234:(.text+0x429): r
elocation truncated to fit: R_X86_64_PC32 against undefined symbol `argp_parse'
collect2: error: ld returned 1 exit status
Makefile:228: recipe for target 'tsim.exe' failed
make[2]: *** [tsim.exe] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/David/Downloads/tsim-0.84/src'
Makefile:247: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/David/Downloads/tsim-0.84'
Makefile:169: recipe for target 'all' failed
make: *** [all] Error 2
答案 0 :(得分:0)
在Cygwin中,看起来 argp 是独立的库。您需要在 gcc 行中添加:-largp
。