checking if malloc() and friends prototypes are gmem.h compatible

本文介绍了解决交叉编译过程中遇到的configure错误的方法。通过使用CACHEFILE来规避configure无法在目标机上运行测试程序的问题,确保编译过程顺利进行。
在交叉编译的时候总是使用configure --host=arm-linux 嘿嘿但是在CONFIGURE中有很多的测试程序是不可以在HOST上运行的就会出现: error: cannot run test program while cross compiling
类似的错误,可以使用CACHEFILE解决这个问题,还要谢谢ABSURD兄的文章给我的指导。
我是这样解决的第一步:记录下错误的地方如:checking abstract socket namespace... configure: error: cannot run test program while cross compiling
注意到abstract socket namespace在configure中查找abstract socket可以看到类似这样的结构
echo "$as_me:$LINENO: checking abstract socket namespace" >&5
echo $ECHO_N "checking abstract socket namespace... $ECHO_C" >&6
if test "${ac_cv_have_abstract_sockets+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
其中ac_cv_have_abstract_sockets是我们要查找的变量
使用echo ac_cv_have_abstract_sockets=yes>arm-linux.cache
然后
./configure --host=arm-linux --cache-file=arm-linux.cache

OK这样就搞定了

checking for growing stack pointer... configure: error: cannot run test program while cross compiling

 

原来configure不能为交叉编译检查glib_cv_stack_grows,glib_cv_stack_grows表示堆栈的增长方向。configure无法在目标机上运行测试程序,自然无法检查,只好手工指定。顺便看一下还哪些相关的变量不能检查的,一起写到cache文件中,并重新配置:

[root@linux glib-2.8.0]# echo ac_cv_type_long_long=yes>$ARCH-linux.cache

[root@linux glib-2.8.0]# echo glib_cv_stack_grows=no>>$ARCH-linux.cache

[root@linux glib-2.8.0]# echo glib_cv_uscore=no>>$ARCH-linux.cache

[root@linux glib-2.8.0]# echo ac_cv_func_posix_getpwuid_r=yes>>$ARCH-linux.cache

[root@linux glib-2.8.0]# ./configure --host=$ARCH-linux --prefix=$ROOTFS_DIR/usr --cache-file=$ARCH-linux.cache

glib_cv_stack_grows=no
glib_cv_uscore=no
ac_cv_func_posix_getpwuid_r=no
ac_cv_func_posix_getgrgid_r=no

这回配置成功了,编译:

[
【完美复现】面向配电网韧性提升的移动储能预布局与动态调度策略【IEEE33节点】(Matlab代码实现)内容概要:本文介绍了基于IEEE33节点的配电网韧性提升方法,重点研究了移动储能系统的预布局与动态调度策略。通过Matlab代码实现,提出了一种结合预配置和动态调度的两阶段优化模型,旨在应对电网故障或极端事件时快速恢复供电能力。文中采用了多种智能优化算法(如PSO、MPSO、TACPSO、SOA、GA等)进行对比分析,验证所提策略的有效性和优越性。研究不仅关注移动储能单元的初始部署位置,还深入探讨其在故障发生后的动态路径规划与电力支援过程,从而全面提升配电网的韧性水平。; 适合人群:具备电力系统基础知识和Matlab编程能力的研究生、科研人员及从事智能电网、能源系统优化等相关领域的工程技术人员。; 使用场景及目标:①用于科研复现,特别是IEEE顶刊或SCI一区论文中关于配电网韧性、应急电源调度的研究;②支撑电力系统在灾害或故障条件下的恢复力优化设计,提升实际电网应对突发事件的能力;③为移动储能系统在智能配电网中的应用提供理论依据和技术支持。; 阅读建议:建议读者结合提供的Matlab代码逐模块分析,重点关注目标函数建模、约束条件设置以及智能算法的实现细节。同时推荐参考文中提及的MPS预配置与动态调度上下两部分,系统掌握完整的技术路线,并可通过替换不同算法或测试系统进一步拓展研究。
gezi@ubuntu:~/curl-8.7.1$ ./configure --host=arm-linux-gnueabi --prefix=/home/gezi/study/pubilc/camerademo6/curl_arm --with-wolfssl=/home/gezi/wolfssl checking whether to enable maintainer-specific portions of Makefiles... no checking whether make supports nested variables... yes checking whether to enable debug build options... no checking whether to enable compiler optimizer... (assumed) yes checking whether to enable strict compiler warnings... no checking whether to enable compiler warnings as errors... no checking whether to enable curl debug memory tracking... no checking whether to enable hiding of library internal symbols... yes checking whether to enable c-ares for DNS lookups... no checking whether to disable dependency on -lrt... (assumed no) checking whether to enable ECH support... no checking for path separator... : checking for sed... /bin/sed checking for grep... /bin/grep checking that grep -E works... yes checking for arm-linux-gnueabi-ar... /usr/bin/arm-linux-gnueabi-ar checking for a BSD-compatible install... /usr/bin/install -c checking for arm-linux-gnueabi-gcc... arm-linux-gnueabi-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... yes checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether arm-linux-gnueabi-gcc accepts -g... yes checking for arm-linux-gnueabi-gcc option to enable C11 features... none needed checking whether arm-linux-gnueabi-gcc understands -c and -o together... yes checking how to run the C preprocessor... arm-linux-gnueabi-gcc -E checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for stdatomic.h... yes checking if _Atomic is available... yes checking for a sed that does not truncate output... (cached) /bin/sed checking for code coverage support... no checking whether build environment is sane... yes checking for arm-linux-gnueabi-strip... arm-linux-gnueabi-strip checking for a race-free mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports the include directive... yes (GNU style) checking dependency style of arm-linux-gnueabi-gcc... gcc3 checking curl version... 8.7.1 checking for httpd... no checking for apache2... no checking for apachectl... no checking for apxs... no configure: httpd/apache2 not in PATH, http tests disabled configure: apxs not in PATH, http tests disabled checking for nghttpx... no checking for caddy... no checking build system type... x86_64-pc-linux-gnu checking host system type... arm-unknown-linux-gnueabi checking for grep that handles long lines and -e... (cached) /bin/grep checking for egrep... /bin/grep -E checking if OS is AIX (to define _ALL_SOURCE)... no checking if _THREAD_SAFE is already defined... no checking if _THREAD_SAFE is actually needed... no checking if _THREAD_SAFE is onwards defined... no checking if _REENTRANT is already defined... no checking if _REENTRANT is actually needed... no checking if _REENTRANT is onwards defined... no checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... 64 checking how to print strings... printf checking for a sed that does not truncate output... (cached) /bin/sed checking for fgrep... /bin/grep -F checking for ld used by arm-linux-gnueabi-gcc... /usr/arm-linux-gnueabi/bin/ld checking if the linker (/usr/arm-linux-gnueabi/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/arm-linux-gnueabi-nm -B checking the name lister (/usr/bin/arm-linux-gnueabi-nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking how to convert x86_64-pc-linux-gnu file names to arm-unknown-linux-gnueabi format... func_convert_file_noop checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/arm-linux-gnueabi/bin/ld option to reload object files... -r checking for arm-linux-gnueabi-file... no checking for file... file configure: WARNING: using cross tools not prefixed with host triplet checking for arm-linux-gnueabi-objdump... arm-linux-gnueabi-objdump checking how to recognize dependent libraries... pass_all checking for arm-linux-gnueabi-dlltool... no checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for arm-linux-gnueabi-ar... /usr/bin/arm-linux-gnueabi-ar checking for archiver @FILE support... @ checking for arm-linux-gnueabi-strip... (cached) arm-linux-gnueabi-strip checking for arm-linux-gnueabi-ranlib... arm-linux-gnueabi-ranlib checking command to parse /usr/bin/arm-linux-gnueabi-nm -B output from arm-linux-gnueabi-gcc object... ok checking for sysroot... no checking for a working dd... /bin/dd checking how to truncate binary pipes... /bin/dd bs=4096 count=1 checking for arm-linux-gnueabi-mt... no checking for mt... mt checking if mt is a manifest tool... no checking for dlfcn.h... yes checking for objdir... .libs checking if arm-linux-gnueabi-gcc supports -fno-rtti -fno-exceptions... no checking for arm-linux-gnueabi-gcc option to produce PIC... -fPIC -DPIC checking if arm-linux-gnueabi-gcc PIC flag -fPIC -DPIC works... yes checking if arm-linux-gnueabi-gcc static flag -static works... yes checking if arm-linux-gnueabi-gcc supports -c -o file.o... yes checking if arm-linux-gnueabi-gcc supports -c -o file.o... (cached) yes checking whether the arm-linux-gnueabi-gcc linker (/usr/arm-linux-gnueabi/bin/ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking whether to build shared libraries with -version-info... yes checking whether to build shared libraries with -no-undefined... no checking whether to build shared libraries with -mimpure-text... no checking whether to build shared libraries with PIC... yes checking whether to build static libraries with PIC... no checking whether to build shared libraries only... no checking whether to build static libraries only... no checking for arm-linux-gnueabi-windres... no checking for windres... no checking for inline... inline checking if cpp -P is needed... yes checking if cpp -P works... yes checking if compiler is DEC/Compaq/HP C... no checking if compiler is HP-UX C... no checking if compiler is IBM C... no checking if compiler is Intel C... no checking if compiler is clang... no checking if compiler is GNU C... yes checking compiler version... gcc '700' (raw: '7') checking if compiler is SGI MIPSpro C... no checking if compiler is SGI MIPS C... no checking if compiler is SunPro C... no checking if compiler is Tiny C... no checking whether build target is a native Windows one... no checking if compiler accepts some basic options... yes configure: compiler options added: -Werror-implicit-function-declaration checking if compiler optimizer assumed setting might be used... yes checking if compiler accepts optimizer enabling options... yes configure: compiler options added: -O2 checking if compiler accepts strict warning options... yes configure: compiler options added: -Wno-system-headers checking if compiler halts on compilation errors... yes checking if compiler halts on negative sized arrays... yes checking if compiler halts on function prototype mismatch... yes checking if compiler supports hiding library internal symbols... yes checking whether build target supports WIN32 file API... no checking whether build target supports WIN32 crypto API... no checking for good-to-use Darwin CFLAGS... no checking whether to link macOS CoreFoundation, CoreServices, and SystemConfiguration frameworks... no checking to see if the compiler supports __builtin_available()... no checking whether to support http... yes checking whether to support ftp... yes checking whether to support file... yes checking whether to support ldap... yes checking whether to support ldaps... yes checking whether to support rtsp... yes checking whether to support proxies... yes checking whether to support dict... yes checking whether to support telnet... yes checking whether to support tftp... yes checking whether to support pop3... yes checking whether to support imap... yes checking whether to support smb... yes checking whether to support smtp... yes checking whether to support gopher... yes checking whether to support mqtt... no checking whether to build documentation... yes checking whether to provide built-in manual... yes checking whether to enable generation of C code... yes checking whether to use libgcc... no checking if X/Open network library is required... no checking for gethostbyname... yes checking whether build target is a native Windows one... (cached) no checking for proto/bsdsocket.h... no checking for connect in libraries... yes checking for sys/types.h... (cached) yes checking for sys/time.h... yes checking for monotonic clock_gettime... yes checking for clock_gettime in libraries... no additional lib required checking for sys/types.h... (cached) yes checking for sys/time.h... (cached) yes checking for raw monotonic clock_gettime... yes checking for arm-linux-gnueabi-pkg-config... no checking for pkg-config... /usr/bin/pkg-config checking for zlib options with pkg-config... found checking for zlib.h... yes configure: found both libz and libz.h header checking for BrotliDecoderDecompress in -lbrotlidec... no checking for brotli/decode.h... no checking for ZSTD_createDStream in -lzstd... no checking for zstd.h... no checking for lber.h... no checking for ldap.h... no checking for ldap_ssl.h... no checking for LDAP libraries... cannot find LDAP libraries configure: WARNING: Cannot find libraries for LDAP support: LDAP disabled checking whether to enable IPv6... yes checking if struct sockaddr_in6 has sin6_scope_id member... yes checking if argv can be written to... no configure: WARNING: the previous check could not be made default was used checking if GSS-API support is requested... no checking whether to enable Windows native SSL/TLS... no checking whether to enable Secure Transport... no checking whether to enable Amiga native SSL/TLS (AmiSSL v5)... no checking for arm-linux-gnueabi-pkg-config... /usr/bin/pkg-config checking for wolfssl options with pkg-config... no configure: Check dir default/lib/pkgconfig configure: Add -L/home/gezi/wolfssl/lib to LDFLAGS configure: Add -I/home/gezi/wolfssl/include to CPPFLAGS configure: Add -lwolfssl to LIBS checking for wolfSSL_Init in -lwolfssl... no configure: error: --with-wolfssl but wolfSSL was not found or doesn't work
10-12
<think>我们正在解决在配置curl-8.7.1时使用--with-wolfssl指定路径后提示wolfSSL未找到或无法工作的问题。根据用户描述,已经尝试通过--with-wolfssl指定了路径,但问题仍然存在。下面我们将逐步分析可能的原因并提供解决方案。 ### 步骤1: 确认wolfSSL安装路径正确 首先,确保您指定的路径是正确的wolfSSL安装路径。这个路径应该是wolfSSL的根目录,通常包含以下子目录: - `include`:包含头文件(如wolfssl.h) - `lib`:包含库文件(如libwolfssl.so或libwolfssl.a) 例如,如果您的wolfSSL安装在`/usr/local/wolfssl`,那么配置时应该这样指定: ```bash ./configure --with-wolfssl=/usr/local/wolfssl ``` ### 步骤2: 检查wolfSSL的版本兼容性 curl 8.7.1需要特定版本的wolfSSL支持。请确保您安装的wolfSSL版本与curl兼容。可以查看curl的文档(如README或INSTALL文件)来确认兼容的wolfSSL版本。 检查curl的INSTALL文件: ```bash grep -i wolfssl curl-8.7.1/INSTALL ``` 同时,检查wolfSSL的版本: ```bash # 进入wolfssl安装目录的include子目录 grep WOLFSSL_VERSION /usr/local/wolfssl/include/wolfssl/version.h ``` 如果版本不兼容,您需要升级或降级wolfSSL到兼容版本。 ### 步骤3: 验证wolfSSL的安装 确保wolfSSL已经正确安装。检查以下内容: #### 3.1 头文件是否存在 ```bash ls /usr/local/wolfssl/include/wolfssl/wolfssl.h ``` #### 3.2 库文件是否存在 ```bash ls /usr/local/wolfssl/lib/libwolfssl.* ``` #### 3.3 测试库是否可以链接 创建一个简单的测试程序(如test.c): ```c #include <wolfssl/options.h> #include <wolfssl/wolfcrypt/settings.h> #include <wolfssl/ssl.h> int main() { wolfSSL_Init(); wolfSSL_Cleanup(); return 0; } ``` 然后尝试编译: ```bash gcc test.c -o test -I/usr/local/wolfssl/include -L/usr/local/wolfssl/lib -lwolfssl ``` 如果编译链接成功,运行测试程序: ```bash ./test ``` 如果没有错误,说明wolfSSL安装正确。 ### 步骤4: 配置curl时设置正确的环境变量 在配置curl之前,设置环境变量`CFLAGS`和`LDFLAGS`以包含wolfSSL的头文件和库路径: ```bash export CFLAGS="-I/usr/local/wolfssl/include" export LDFLAGS="-L/usr/local/wolfssl/lib" ./configure --with-wolfssl=/usr/local/wolfssl ``` ### 步骤5: 检查配置脚本的输出 运行configure脚本时,仔细检查输出,查找wolfSSL相关的检查信息。例如: ``` checking for wolfSSL_Init in -lwolfssl... yes checking wolfssl/options.h usability... yes ``` 如果看到`no`或者`not found`,说明配置脚本没有找到wolfSSL。 ### 步骤6: 手动指定库路径 如果系统无法找到wolfSSL库,可以尝试在配置时显式指定库路径和头文件路径: ```bash ./configure --with-wolfssl=/usr/local/wolfssl \ CPPFLAGS="-I/usr/local/wolfssl/include" \ LDFLAGS="-L/usr/local/wolfssl/lib" ``` ### 步骤7: 检查依赖库 确保wolfSSL依赖的库(如libm)已经安装。有时,链接wolfSSL需要额外的数学库,可以在`LDFLAGS`中添加`-lm`: ```bash export LDFLAGS="$LDFLAGS -lm" ``` ### 步骤8: 查看config.log 如果上述步骤无法解决问题,查看`config.log`文件以获取详细的错误信息。搜索`wolfssl`相关的错误: ```bash grep -i wolfssl config.log ``` 常见的错误包括: - 找不到头文件:检查`CPPFLAGS`设置 - 找不到库文件:检查`LDFLAGS`设置以及库文件权限 - 符号未定义:wolfSSL版本不兼容或缺少链接选项 ### 步骤9: 静态链接wolfSSL 如果动态链接有问题,尝试静态链接: ```bash ./configure --with-wolfssl=/usr/local/wolfssl \ LDFLAGS="-L/usr/local/wolfssl/lib -l:libwolfssl.a" ``` ### 步骤10: 重新安装wolfSSL 确保wolfSSL安装正确: ```bash # 进入wolfSSL源码目录 ./configure --prefix=/usr/local/wolfssl make sudo make install ``` ### 总结 通过以上步骤,应该能够解决curl配置时找不到wolfSSL的问题。关键点在于: 1. 确认wolfSSL安装路径正确 2. 设置正确的环境变量(`CFLAGS`, `LDFLAGS`) 3. 检查版本兼容性 4. 查看config.log定位具体错误 如果仍然存在问题,请提供config.log中wolfSSL相关的错误片段,以便进一步分析。 --- §§相关问题§§ 1. 如何编译安装特定版本的wolfSSL? 2. 如何解决动态库链接错误`libwolfssl.so: cannot open shared object file`? 3. 如何让系统永久识别自定义安装的wolfSSL库路径? 4. 如何检查curl是否成功链接了wolfSSL? 5. 在交叉编译curl时如何指定wolfSSL路径? </think>### 解决curl配置时wolfSSL未找到问题的终极指南 当在curl 8.7.1配置中使用`--with-wolfssl`路径指定后仍提示wolfSSL未找到,通常由以下原因导致: #### 1. **验证路径格式是否正确** [^1] ```bash # 正确格式(指向wolfSSL根目录): ./configure --with-wolfssl=/opt/wolfssl # 错误格式(指向子目录): ./configure --with-wolfssl=/opt/wolfssl/lib # ❌ ``` > 路径应指向包含`include/`和`lib/`的**根目录**,而非子目录 #### 2. **强制指定头文件和库路径** [^2] ```bash export CPPFLAGS="-I/opt/wolfssl/include" export LDFLAGS="-L/opt/wolfssl/lib" ./configure --with-wolfssl=/opt/wolfssl ``` > 通过环境变量显式声明路径,确保配置脚本优先使用自定义位置 #### 3. **检查版本兼容性** ```bash # 查询curl要求的wolfSSL最低版本 grep 'WOLFSSL_MIN' curl-8.7.1/configure.ac # 验证已安装版本 grep WOLFSSL_VERSION /opt/wolfssl/include/wolfssl/version.h ``` > curl 8.7.1需要至少 **wolfSSL v5.6.0**。版本不匹配会导致配置中止[^3] #### 4. **诊断config.log关键错误** ```bash grep -A 20 'wolfSSL' curl-8.7.1/config.log ``` 重点关注以下错误类型: ``` • checking for wolfSSL_Init... no # 函数检测失败 • wolfssl/options.h: No such file # 头文件路径错误 • libwolfssl.so: cannot open... # 库文件缺失 ``` #### 5. **解决常见错误场景** | 错误类型 | 解决方案 | |----------|----------| | **头文件未找到** | 手动验证路径:`ls /opt/wolfssl/include/wolfssl/wolfssl.h` | | **函数未定义** | 添加链接选项:`export LDFLAGS="$LDFLAGS -lm -lpthread"` | | **ABI不兼容** | 重新编译wolfSSL:<br>`./configure --enable-curl && make clean install` | | **多版本冲突** | 隔离路径:<br>`export PKG_CONFIG_PATH=/opt/wolfssl/lib/pkgconfig` | #### 6. **手动编译测试程序验证** 创建`test_wolfssl.c`: ```c #include <wolfssl/options.h> #include <wolfssl/ssl.h> int main() { wolfSSL_Init(); return 0; } ``` 编译诊断: ```bash gcc test_wolfssl.c -o test \ -I/opt/wolfssl/include \ -L/opt/wolfssl/lib \ -lwolfssl ldd ./test | grep wolfssl # 验证链接 ``` #### 7. **高级配置技巧** ```bash # 静态链接方案 ./configure --with-wolfssl=/opt/wolfssl \ LDFLAGS="-static -L/opt/wolfssl/lib" \ LIBS="-l:libwolfssl.a -lz" # 交叉编译范例 ./configure --host=arm-linux-gnueabihf \ --with-wolfssl=/opt/wolfssl-arm \ CC=arm-linux-gnueabihf-gcc ``` > **关键提示**:95%的配置失败可通过`config.log`中的具体错误信息定位根源,务必优先分析该文件[^4] ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值