我正在创作的项目中运行make distcheck
时遇到名义链接错误:
$ uname -a
Linux vbox 3.2.0-26-generic #41-Ubuntu SMP Thu Jun 14 17:49:24 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
Ubuntu 12.04 LTS \n \l
$ libtool --version
libtool (GNU libtool) 2.4.2
Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ automake --version
automake (GNU automake) 1.11.3
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Tom Tromey <tromey@redhat.com>
and Alexandre Duret-Lutz <adl@gnu.org>.
正如您所看到的,它正在使用g ++ 4.6和libtool 2.4.2在Ubuntu 12.04上出现。在使用g ++ 4.2.1和libtool 2.4.2(均通过自制软件安装)的OS X 10.7.4上,不会出现错误。它也没有出现在make check
。
以下是Makefile.am
的相关摘要:
# -- myprog --
#
lib_LTLIBRARIES += myproj/myprog/libmyprog.la
myproj_myprog_libmyprog_la_SOURCES = # ...
myproj_myprog_libmyprog_la_LIBADD = myproj/mylib/libmylib.la
sbin_PROGRAMS += myproj/myprog/myprog
myproj_myprog_myprog_SOURCES = myproj/myprog/main.cc
myproj_myprog_myprog_LDADD = myproj/myprog/libmyprog.la
# -- mylib --
#
lib_LTLIBRARIES += myprog/mylib/libmylib.la
myproj_mylib_libmylib_la_SOURCES = # ...
错误本身:
/usr/bin/ld: cannot find -lmylib
collect2: ld returned 1 exit status
libtool: install: error: relink `myproj/myprog/libmyprog.la' with the above command before installing it
我该如何解决这个问题?
答案 0 :(得分:0)
简而言之,订单(显然)很重要:
# -- mylib --
#
lib_LTLIBRARIES += myprog/mylib/libmylib.la
myproj_mylib_libmylib_la_SOURCES = # ...
# -- myprog --
#
lib_LTLIBRARIES += myproj/myprog/libmyprog.la
myproj_myprog_libmyprog_la_SOURCES = # ...
myproj_myprog_libmyprog_la_LIBADD = myproj/mylib/libmylib.la
sbin_PROGRAMS += myproj/myprog/myprog
myproj_myprog_myprog_SOURCES = myproj/myprog/main.cc
myproj_myprog_myprog_LDADD = myproj/myprog/libmyprog.la
现在我的项目在所有提到的平台上构建(check
和distcheck
)。