我有两个基于 autotools 的项目 AAA 和 BBB:
尝试编译 BBB 时,我收到以下信息:
/usr/bin/ld: /usr/local/lib/libAAA.a(liboAAA_la-foo.o): relocation R_X86_64_PC32 against undefined symbol `malloc@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
Run Code Online (Sandbox Code Playgroud)
作为参考,产生错误的实际命令是:
gcc -shared -fPIC -DPIC .libs/libBBB_la-BBB.o .libs/libBBB_la-hash.o .libs/libBBB_la-vl_helpers.o -lm -L/usr/local/lib /usr/local/lib/libAAA.a -O3 -Wl,-soname -Wl,libBBB.so.0 -o .libs/libBBB.so.0.0.0
Run Code Online (Sandbox Code Playgroud)
我做错了什么,我该如何进行这项工作?
我正在尝试构建一个项目,但它抛出了一个错误:
autoreconf: running: /usr/bin/autoconf --force
configure.ac:19: error: possibly undefined macro: AC_SUBST
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
Run Code Online (Sandbox Code Playgroud)
我对构建工具很陌生,这就是为什么这个错误让我发疯。
有人可以帮我弄清楚我应该怎么做才能解决这个问题吗?
编辑:configure.ac 中的相应行是:
嘿,我仍然无法弄清楚我的 configure.ac 有什么问题。我的 configure.ac 看起来像这样:
PKG_CHECK_MODULES(libcurl, libcurl)
AP_VERSION=2.2.4
AP_CHECK_APACHE([$AP_VERSION], [
LIBTOOL="`$APR_CONFIG --apr-libtool`"
AC_SUBST([LIBTOOL])
MODULE_CFLAGS="$AP_CFLAGS"
AC_SUBST([MODULE_CFLAGS])
MODULE_LDFLAGS="`$APR_CONFIG --link-libtool` `$APU_CONFIG --link-libtool`"
AC_SUBST([MODULE_LDFLAGS])
BIN_LDFLAGS="`$APR_CONFIG --link-libtool` `$APU_CONFIG --link-libtool` `$APR_CONFIG --ldflags --libs` `$APU_CONFIG --ldflags --libs`"
AC_SUBST([BIN_LDFLAGS])
prefix="$AP_PREFIX"
], AC_MSG_ERROR([*** Apache version $AP_VERSION not found!]))
Run Code Online (Sandbox Code Playgroud)
它在 AC_SUBST([LIBTOOL]) 处中断。请帮忙
这一直困扰着我多年,但我一直忽视它,就像我怀疑其他人一样.
AM_INIT_AUTOMAKE([dist-bzip2])
AC_PROG_CC
AC_PROG_LIBTOOL
AC_C_INLINE
AM_PROG_CC_C_O
Run Code Online (Sandbox Code Playgroud)
有了上面的configure.ac文件,configure会去找我一个C编译器,但接下来继续:
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 xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for …Run Code Online (Sandbox Code Playgroud) 我正在使用brew安装一些软件,当我尝试安装软件时,我得到了这个:
localhost:~ timger$ brew install autoconf
Error: No available formula for autoconf
localhost:~ timger$ brew install automake
Error: No available formula for automake
localhost:~ timger$ brew install libtool
Error: No available formula for libtool
localhost:~ timger$ brew install pkg-con
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的HTML Tidy c ++包装器库构建在linux上(目前在Ubuntu上进行测试),但make失败并出现libtool错误:"libtool:link:你必须指定一个输出文件"
这是我的Makefile.am:
## tidypp:
## A c++ wrapper around HTML Tidy Lib
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
lib_LTLIBRARIES = libtidypp-@TIDYPP_API_VERSION@.la
libtidypp_@TIDYPP_API_VERSION@_la_CPPFLAGS = $(DEPS_CFLAGS)
libtidypp_@TIDYPP_API_VERSION@_la_LIBADD = -ltidy $(DEPS_LIBS)
libtidypp_@TIDYPP_API_VERSION@_la_SOURCES = src/attribute.cpp src/buffer.cpp \
src/document.cpp src/inputsource.cpp src/mem.cpp src/node.cpp src/option.cpp \
src/outputsink.cpp src/tidypp.cpp include/tidypp/attribute.hpp \
include/tidypp/basic_wrapper.hpp include/tidypp/buffer.hpp \
include/tidypp/document.hpp include/tidypp/inputsource.hpp \
include/tidypp/io.hpp include/tidypp/mem.hpp include/tidypp/node.hpp \
include/tidypp/option.hpp include/tidypp/outputsink.hpp include/tidypp/tidypp.hpp
libtidypp_@TIDYPP_API_VERSION@_la_LDFLAGS = -version-info $(tidypp_SO_VERSION)
tidypp_includedir=$(includedir)/tidypp-@TIDYPP_API_VERSION@/tidypp
tidypp_include_HEADERS = include/tidypp/attribute.hpp \
include/tidypp/basic_wrapper.hpp include/tidypp/buffer.hpp \
include/tidypp/document.hpp include/tidypp/inputsource.hpp \
include/tidypp/io.hpp include/tidypp/mem.hpp include/tidypp/node.hpp \ …Run Code Online (Sandbox Code Playgroud) 我当前的项目在其include/tatoparser目录中有几个文件,我想与我的库一起分发.
qdii@nomada ~/MyProject $ ls include/tatoparser/
dataset.h interface_lib.h linkset.h sentence.h tagset.h
Run Code Online (Sandbox Code Playgroud)
我创建了一个Makefile.am引用这些文件:
qdii@nomada ~/MyProject $ cat include/Makefile.am
include_HEADERS = tatoparser/interface_lib.h tatoparser/sentence.h tatoparser/dataset.h tatoparser/tagset.h tatoparser/linkset.h
Run Code Online (Sandbox Code Playgroud)
但是,当我运行make install引用的文件被复制到/usr/include(或$(includedir)设置为)时,我希望它们被复制/usr/include/tatoparser.
我怎样才能做到这一点?
我正在安装apache的步骤如下所示
:http://ports.ubuntu.com/ubuntu-ports生动受限的主要多元宇宙>> /etc/apt/sources.list
apt-get install -y git\
openssl\
subversion\
autoconf的\
libtool的\
APR的\
APR的-UTIL\
使\
libpcre3-dev的\
libpcre ++ - dev的\
的libxml2-dev的\
libexpat1-dev的\
蟒蛇
git clone https://github.com/apache/httpd.git
cd httpd
svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr && cd srclib/apr && ./buildconf && ./build libtool && make && make install
./buildconf给出错误如下
./buildconf
找到apr源:srclib/apr
重建srclib/apr/configure
buildconf:检查安装...
buildconf:python版本2.7.9( ok)
buildconf:autoconf版本2.69(ok)
buildconf:找不到libtool.
您需要安装libtool 1.4或更高版本
才能从SVN构建APR.
./buildconf因apr而失败
在上面,因为我已经安装了libtool.但是找不到libttol.当我说apt-get install -y libtool时我得到消息为
#apt-get install -y libtoo
apt-get install -y libtool
读取包列表...完成
构建依赖关系树
读取状态信息. ..完成
libtool已经是最新版本了.
0升级,0新安装,0删除,26未升级.
W:重复来源.列表条目http://ports.ubuntu.com/ubuntu-ports/ vivid/restricted ppc64el包(/var/lib/apt/lists/ports.ubuntu.com_ubuntu-ports_dists_vivid_restricted_binary-ppc64el_Packages)W
:重复来源.list条目 …
当我安装 LLVM 时,发生错误:
? build make
[ 0%] Linking CXX static library ../libLLVMSupport.a
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make[2]: *** [lib/libLLVMSupport.a] Error 1
make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
make: *** [all] Error 2
? build which libtool
/usr/local/bin/libtool
Run Code Online (Sandbox Code Playgroud)
我已经尝试解决它,但失败了。
http://flummox-engineering.blogspot.com/2014/04/libtool-unrecognized-option-static.html
我有一个旧项目,我想使用 cMake 而不是旧的自动工具。
旧程序的作用是,在输入 make 之后,它将在名为 .libs 的隐藏文件夹中创建 libtest.a、libtest.la、libtest.so.1.0.0 等,然后在我输入 make install 后,它将安装所有库到目标文件夹 $TEST_ROOT/lib (环境变量),它还会将所有 .h 文件安装到 $TEST_ROOT/include 文件夹中。
在 Makefile.am 中:
source_list=test1.cpp test2.cpp
include_HEADERS=test1.h test2.h
AM_LDFLAGS="-pthread -lm -lrt"
lib_LTLIBRARIES=libtest.la
libtest_la_SOURCES=$(source_list)
libtest_la_LDFLAGS=$(AM_LDFLAGS) -static-libgcc
Run Code Online (Sandbox Code Playgroud)
在configure.ac中,我只看到相关的一行,
if test -n "${TEST_ROOT}"; then
ac_default_prefix=${TEST_ROOT}
includedir=${ac_default_prefix}/include
fi
Run Code Online (Sandbox Code Playgroud)
坦白说,我不太明白为什么上面的代码会将.a、.la、.so等库放在一起,然后将它们安装到当前的文件夹中。也许自动工具可以识别“ac_default_prefix”和“includeddir”?
无论如何,我想用 cmake 做同样的事情,以下是我的尝试,但不是完整的解决方案。
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/.libs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR}/.libs)
set(CMAKE_CXX_FLAGS "-O3 -Wall")
set(CMAKE_EXE_LINKER_FLAGS "-pthread -lm -lrt")
file(GLOB SOURCES "*.cpp")
add_library(test STATIC ${SOURCES})
Run Code Online (Sandbox Code Playgroud)
上面的代码将在构建文件夹中编译 libtest.a,而不是在构建文件夹内的 .libs 文件夹中(这意味着 CMAKE_RUNTIME_OUTPUT_DIRECTORY 等不起作用)。
其次,它只会构建libtest.a,没有libtest.la,没有libtest.so.1.0.0等。
第三,我仍然不确定如何让 make install 像自动工具一样工作。我可以只设置目标包含目录和目标lib目录,然后make install将所有.h文件和.so、.a、.la文件安装到目标目录中吗?
请帮忙。
谢谢。
我正在尝试在 MacOS 上使用 Autotools 构建一个框架。该框架包含一个库(我们称之为 libmytools.dylib)和一个使用该库的可执行文件。我想要的是在运行时动态链接这个库。
可执行文件通常安装到/Library/Frameworks/mytools.Framework/Versions/Current/Commands/mytools
库通常安装到
/Library/Frameworks/mytools.Framework/Versions/Current/Libraries/libmytools.dylib
如果框架安装在该位置,一切正常,但是当框架未安装在计算机上而是仅嵌入到另一个项目中时,则无法找到该库。
我需要的是所谓的“Runpath Dependent Library”,如下所述: https ://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html
所以我所做的就是添加mytools_LDFLAGS = -rpath @executable_path/../Libraries到 makefile 中。
但不幸的是 libtool 拒绝将我的可执行文件与动态 -rpath 链接并显示以下错误:libtool: link: only absolute run-paths are allowed.
我也尝试过mytools_LDFLAGS = -dynamic -rpath @executable_path/../Libraries,但结果是一样的......
我究竟做错了什么??