错误现象:
cygwin下make编译crosstool-ng出错:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0
$ make
SED 'ct-ng'
SED 'scripts/crosstool-NG.sh'
SED 'scripts/saveSample.sh'
SED 'scripts/showTuple.sh'
GEN 'config/configure.in'
GEN 'paths.mk'
GEN 'paths.sh'
DEP 'nconf.gui.dep'
DEP 'nconf.dep'
DEP 'lxdialog/checklist.dep'
DEP 'lxdialog/inputbox.dep'
DEP 'lxdialog/util.dep'
DEP 'lxdialog/textbox.dep'
DEP 'lxdialog/yesno.dep'
DEP 'lxdialog/menubox.dep'
DEP 'mconf.dep'
DEP 'conf.dep'
BISON 'zconf.tab.c'
GPERF 'zconf.hash.c'
LEX 'lex.zconf.c'
DEP 'zconf.tab.dep'
CC 'zconf.tab.o'
CC 'conf.o'
LD 'conf'
zconf.tab.o:zconf.tab.c:(.text+0x162a): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0x47fe): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0x56ec): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0x58be): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0xc70b): undefined reference to `_libintl_gettext'
zconf.tab.o:zconf.tab.c:(.text+0xc719): more undefined references to `_libintl_gettext' follow
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: zconf.tab.o: bad reloc address 0x110 in section `.data'
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
Makefile:108: recipe for target `conf' failed
make[2]: *** [conf] Error 1
Makefile:160: recipe for target `build-lib-kconfig' failed
make[1]: *** [build-lib-kconfig] Error 2
Makefile:120: recipe for target `build' failed
make: *** [build] Error 2
原因:
Cygwin下虽然已经安装了intl库,但是此处make编译的时候,没有链接进去,所以报错。
解决办法:
修改对应的Makefile文件:
crosstool-ng-1.18.0\kconfig\Makefile
去添加对应的intl库,即改为:
# What’s needed to build ‘conf’
conf_SRC = conf.c
conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ))
$(conf_OBJ) $(conf_DEP): CFLAGS += $(INTL_CFLAGS)
conf: LDFLAGS += -lintl
# What’s needed to build ‘mconf’
mconf_SRC = mconf.c
mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC))
$(mconf_OBJ) $(mconf_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
#mconf: LDFLAGS += $(NCURSES_LDFLAGS)
mconf: LDFLAGS += -lintl $(NCURSES_LDFLAGS)
# What’s needed to build ‘nconf’
nconf_SRC = nconf.c nconf.gui.c
nconf_OBJ = $(patsubst %.c,%.o,$(nconf_SRC))
nconf_DEP = $(patsubst %.c,%.dep,$(nconf_SRC))
#$(nconf_OBJ) $(nconf_DEP): CFLAGS += $(INTL_CFLAGS) -I/usr/include/ncurses
#nconf: LDFLAGS += -lmenu -lpanel -lncurses
$(nconf_OBJ) $(nconf_DEP): CFLAGS += -I/usr/include/ncurses/ $(INTL_CFLAGS)
nconf: LDFLAGS += -lintl -lmenu -lpanel -lncurses
![]() | 此处也同时添加了ncurses库,解决了undefined reference to `_wattrset'的问题 |
|---|---|
此问题的解决,是在折腾: 时,去参考: Re: crosstool-NG Cygwin Build Fails 而找到的解决办法。 可以看出,其中,在添加intl的同时,也同时去添加了对应的ncurses那个库。 那是因为,后期,同样会出现类似的错误第 5.1.2.2 节 “lxdialog/menubox.o:menubox.c:(.text+0x7d): undefined reference to `_wattrset'”的 所以,此处,也加上对应的ncurses库,一并解决了类似的问题。 |
![]() | 此处不要通过make时加LDFLAGS参数去添加-lintl和-lcurses |
|---|---|
其实,上面贴出来的,修改makefile的办法,的确已经解决了此处的,缺少intl和缺少ncurses的库的两个问题了。 只是,后来,在另外一个Cygwin环境下去折腾同样的make编译crosstool-ng的时候: 【记录】Cygwin下配置编译和安装crosstool-ng 由于之前解决上面这个问题的时候: 用的解决办法是: 不去修改makefile,而直接给make加上LDFLAGS参数加上-lintl: make LDFLAGS="-lintl" 当时也是可以解决此问题的。 并且,接着去解决了:第 5.1.2.2 节 “lxdialog/menubox.o:menubox.c:(.text+0x7d): undefined reference to `_wattrset'” 用的方法也是,继续给make的LDFLAGS添加对应的-lcurses的参数: make LDFLAGS="-lintl -lcurses" 然后,后来就出现,相对来说,至少到目前为止,没有完全搞懂的问题: 【已解决】Cygwin下make编译crosstool-ng出错:nconf.o:nconf.c:(.text+0×373): undefined reference to `_free_item’ 觉得是属于比较诡异的问题。 而最终的解决办法是: 不要用make时给定LDFLAGS参数的方式去添加intl和curses的库 还是用上述的办法,修改对应的makefile,添加对应的intl的库,调整对应的
$(INTL_CFLAGS) -I/usr/include/ncurses
变成:
-I/usr/include/ncurses/ $(INTL_CFLAGS)
即可彻底解决此诡异的问题。 在该诡异问题的根本原因没有搞清楚之前,别人如果遇到类似的错误,还是参照此处,修改makefile去解决类似的问题。 |




![[注意]](https://www.crifan.com/files/res/docbook/images/note.png)
![[小心]](https://www.crifan.com/files/res/docbook/images/caution.png)

