【待完善】make: command not found,以及libtool.m4 and ltmain.sh have a version mismatch问题的解决方案...

文章详细记录了解决使用Cygwin配置与编译ZThread库时遇到的问题,包括安装libtool、autoconf和automake等依赖,以及如何正确配置和编译库文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前为了使用一个库,都是去下载源码,然后根据开发者提供的README手动用GCC编译,一直不能使用Makefile感觉很蛋痛,比如最近使用的ZThread

还是怪自己以前过于依赖IDE

 

最近发现用Cygwin就可以使用诸如./configure, make这样的命令,感觉灰常欣喜,尝试去编译ZThread库(因为我发现虽然之前我用GCC手动编译了ZThread但是在使用的过程中,ZThread总是往控制台上打印诸多的DEBUG信息,想必是编译选项的问题,我又不知道到哪个头文件中去找#define DEBUG,所以就想使用make,看使用ZThread作者写的configuration文件以及Makefile来编译能不能解决问题)

 

刚刚下载下来Cygwin就等着上去configure+make呢,问题就来了,输入./configure之后,等了一段时间报错(见红色文字):

$ ./configure
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... i686-pc-cygwin
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
Loading m4 macros from share
checking for g++... g++
checking for C++ compiler default output file name... a.exe
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for gcc... gcc
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 dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
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 pthread.h usability... no
checking pthread.h presence... no
checking for pthread.h... no
checking for sched_get_priority_max in -lrt... no
checking for sched_yield... no
checking for pthread_yield... no
checking for pthread_key_create... no
checking for pthread_keycreate... no
checking for doxygen... no
detecting for ftime() function
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for _ftime()... yes
checking how to run the C++ preprocessor... g++ -E
checking for ANSI C header files... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking for target implementation... compile-time guess
checking for sigsetjmp()... no
checking for _beginthreadex()... no
checking for a sed that does not truncate output... /usr/bin/sed
checking for ld used by gcc... d:/mingw/mingw32/bin/ld.exe
checking if the linker (d:/mingw/mingw32/bin/ld.exe) is GNU ld... yes
checking for d:/mingw/mingw32/bin/ld.exe option to reload object files... -r
checking for BSD-compatible nm... /cygdrive/d/MinGW/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking dlfcn.h usability... no
checking dlfcn.h presence... no
checking for dlfcn.h... no
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... no
checking for xlf... no
checking for frt... no
checking for pgf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for f90... no
checking for xlf90... no
checking for pgf90... no
checking for epcf90... no
checking for f95... no
checking for fort... no
checking for xlf95... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for gfortran... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking the maximum length of command line arguments... 8192
checking command to parse /cygdrive/d/MinGW/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 for correct ltmain.sh version... grep: character class syntax is [[:space:]], not [:space:]
no

*** Gentoo sanity check failed! ***
*** libtool.m4 and ltmain.sh have a version mismatch! ***
*** (libtool.m4 = 1.5.10, ltmain.sh = ) ***

Please run:

  libtoolize --copy --force

if appropriate, please contact the maintainer of this
package (or your distribution) for help.

输入:libtoolize --copy --force提示libtoolize: command not found

咋办?搜了一下相关的问题,原来是因为安装Cygwin的时候没有安装libtool

重新运行Cygwin-setup(注意,无需卸载,重新运行setup,选择你没有安装的package即可),搜索libtool,勾选并安装,问题解决

 

然后再次运行libtoolize --copy --force,又报错:

$ libtoolize --copy --force
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: You should add the contents of the following files to `aclocal.m4':
libtoolize:   `/usr/share/aclocal/libtool.m4'
libtoolize:   `/usr/share/aclocal/ltoptions.m4'
libtoolize:   `/usr/share/aclocal/ltversion.m4'
libtoolize:   `/usr/share/aclocal/ltsugar.m4'
libtoolize:   `/usr/share/aclocal/lt~obsolete.m4'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

又搜了一下,在这篇BLOG说是因为没安装autoconf的原因,再回去安装autoconf,如图

 

再试一次libtoolize --copy --force

结果还是报同样的错误,回头去看(上面有图,就是libtool那张)原来是libtool-debuginfo和cygwin64-libtool没有安装

于是安装libtool-debuginfo和cygwin64-libtool

再试一次libtoolize --copy --force,成功运行

好了,继续:./configure --prefix D:/ZThread/bin #--prefix指定编译时输出二进制文件的目录

然后还是报错,又运行libtoolize --copy --force,还是报错,无语了

然后,上网搜了半天,在这里找到提示说使用:autoreconf --force --install --symlink

然后又报错Can't exec "aclocal"

继续搜,在这里找到提示说要安装automake(然后我就去Cygwin-setup安装了automake-1.8,注意不要重复安装多个版本,否则会出问题)

 

然后输入make install又提示make: command not found

还是同样的套路,把make package给勾选安装就行了

 

<think>好的,我现在要帮助用户解决在Ubuntu上运行Qt的build.sh脚本时出现的“No such file or directory”以及相关命令未找到的问题。用户提到了几个引用,我需要先仔细看看这些引用内容,再结合常见的问题解决方法进行分析。 首先,引用[1]是关于设置PATH环境变量的,用户将某个路径添加到PATH中。这可能与系统找不到某些库文件或工具有关。但用户的问题是关于头文件缺失和配置脚本的问题,所以这个可能和库路径有关,但需要进一步确认。 引用[2]显示错误是fontconfig.cpp:42:22: error: ft2build.h: No such file or directory。这个错误通常是因为缺少FreeType库的开发文件。在Ubuntu上,可能需要安装libfreetype6-dev包来提供所需的头文件和库。 引用[3]提到用户直接执行autoconfigure.sh脚本,并且建议用sudo运行。这里可能存在两个问题:一是autoconfigure.sh是否存在或权限是否正确,二是是否需要安装autoconf等工具来生成配置脚本。 用户的问题集中在运行build.sh时出现的文件找不到错误,可能涉及配置脚本缺失。我需要考虑几个方面: 1. 依赖项是否安装:比如构建Qt需要的基本开发工具(build-essential)、库文件(如libxcb相关的库、libgl1-mesa-dev等)、以及特定组件如FreeType的开发包。 2. 配置脚本是否正确生成:Qt的源代码通常需要先运行配置脚本(configure),但用户提到的是build.sh,可能这个脚本内部调用了configure或者其他的配置步骤。如果configure脚本不存在,可能需要通过运行autoconf或相关的工具生成,或者确认源代码是否完整。 3. 环境变量设置是否正确:比如PATH是否包含必要的工具路径,或者是否有其他环境变量需要设置,比如PKG_CONFIG_PATH等。 接下来,根据常见问题,可能的解决步骤包括: - 确保安装了所有必要的依赖包。例如,对于ft2build.h缺失的问题,安装libfreetype6-dev。 - 检查build.sh脚本是否存在,或者是否有执行权限。如果用户下载的Qt源码中的build.sh可能不存在,或者需要先执行配置生成步骤。 - 确保configure脚本存在,如果不存在,可能需要运行autoconf或相关的生成工具,或者用户可能没有正确解压源码,或者源码包损坏。 另外,用户提到的错误是“ft2build.h: No such file or directory”,这明确指向缺少FreeType开发文件。所以第一步应该是安装libfreetype6-dev。然后,如果配置脚本缺失,可能需要安装automake、autoconf、libtool等工具,并重新生成配置脚本。 另外,用户执行autoconfigure.sh时是否成功?如果这个脚本是用来生成configure的,但执行时出错,可能需要检查是否缺少相关工具,比如autoconf、automake等。安装这些工具后再次运行脚本。 可能的解决方案步骤: 1. 安装缺少的依赖项: sudo apt-get install libfreetype6-dev 还有其他可能的依赖如libfontconfig1-dev、libx11-dev、libxext-dev等。 2. 安装构建工具: sudo apt-get install build-essential sudo apt-get install autoconf automake libtool 3. 确保Qt源代码正确解压,检查configure文件是否存在。如果不存在,可能需要生成,或者重新下载源码。 4. 运行配置前,可能需要设置环境变量,如引用[1]中的PATH设置,确保编译器能找到正确的库路径。 5. 执行配置脚本时使用正确的参数,或者检查是否有权限问题,可能需要用sudo运行。 用户提到运行autoconfigure.sh需要sudo,但有时候以root权限运行可能会引起问题,特别是涉及到路径权限时,需要注意。 总结起来,用户的问题可能源于缺少开发包、构建工具或配置脚本生成失败。需要分步骤安装依赖,生成配置,然后构建。</think>### 解决方案步骤 #### 1. 安装缺失的开发依赖库 `ft2build.h`缺失表明系统缺少FreeType字体库的开发文件,执行以下命令安装: ```bash sudo apt-get install libfreetype6-dev libfontconfig1-dev ``` 同时补充安装Qt编译所需的基础依赖: ```bash sudo apt-get install build-essential libgl1-mesa-dev libxcb-xinerama0-dev libxkbcommon-dev ``` #### 2. 验证配置脚本权限与完整性 进入Qt源码目录,检查`configure`脚本是否存在: ```bash cd qt-everywhere-src-5.12.10 ls -l configure ``` 如果不存在,可能是源码包损坏,需重新下载。若存在但无执行权限,则添加权限: ```bash chmod +x configure ``` #### 3. 生成配置脚本(可选) 若引用[3]中提到的`autoconfigure.sh`是自定义脚本,需确保已安装`autoconf`和`automake`: ```bash sudo apt-get install autoconf automake libtool ``` 然后执行脚本: ```bash sudo ./autoconfigure.sh # 注意检查脚本逻辑是否合理 ``` #### 4. 设置环境变量 根据引用[1],确保动态库路径包含在`LD_LIBRARY_PATH`中(非PATH): ```bash export LD_LIBRARY_PATH=/home/lzq/forQt/debian-11-linux-rootfs/usr/lib/aarch64-linux-gnu:${LD_LIBRARY_PATH} ``` #### 5. 执行配置与编译 手动运行Qt的配置脚本并指定安装路径: ```bash ./configure -prefix /opt/Qt5.12.10 -opensource -confirm-license make -j$(nproc) sudo make install ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值