【发布时间】:2019-02-19 23:26:37
【问题描述】:
有没有办法获取#include <hdr.h> 指令读取的文件的绝对路径?
对于#include "hdr.h" 指令?
我在 Win 10 / Msys2 下工作。
我的意思是在src/sha1-git.c的编译过程中找到哪个stdint.h,因为:
-
它应该声明
uint32_t,显然它没有这样做,根据我得到的$ make -V=1 /bin/sh ../../libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=\"aircrack-ng\" -DPACKAGE_TARNAME=\"aircrack-ng\" -DPACKAGE_VERSION=\"1.5.2\" -DPACKAGE_STRING=\"aircrack-ng\ 1.5.2\" -DPACKAGE_BUGREPORT=\"https://forum.aircrack-ng.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"aircrack-ng\" -DVERSION=\"1.5.2\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DLT_OBJDIR=\".libs/\" -D_REVISION=\"1.5.2\" -DHAVE_OPENSSL_CRYPTO_H=1 -DHAVE_OPENSSL_CMAC_H=1 -DHAVE_OPENSSL_CMAC_H=1 -DHAVE_SQLITE3_H=1 -DHAVE_SQLITE3=1 -DHAVE_SQLITE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_PTHREAD_PRIO_INHERIT=1 -D_REENTRANT=1 -DHAVE___MINGW_ALIGNED_MALLOC=1 -DCACHELINE_SIZE=64 -DINTEL_ASM=1 -DCACHELINE_SIZE=64 -I. -I../.. -I../../src/include -I../../src -DCYGWIN -DMSYS2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_FORTIFY_SOURCE=2 -pthread -Wall -O3 -std=gnu99 -fno-strict-aliasing -Wpointer-arith -Wstrict-overflow=2 -Wstrict-prototypes -fvisibility=hidden -Wno-unused-but-set-variable -Wno-array-bounds -mconsole -mwindows -DMSYS2 -MT libaircrack_crypto_la-sha1-git.lo -MD -MP -MF .deps/libaircrack_crypto_la-sha1-git.Tpo -c -o libaircrack_crypto_la-sha1-git.lo `test -f 'sha1-git.c' || echo './'`sha1-git.c libtool: compile: gcc -DPACKAGE_NAME=\"aircrack-ng\" -DPACKAGE_TARNAME=\"aircrack-ng\" -DPACKAGE_VERSION=\"1.5.2\" "-DPACKAGE_STRING=\"aircrack-ng 1.5.2\"" -DPACKAGE_BUGREPORT=\"https://forum.aircrack-ng.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"aircrack-ng\" -DVERSION=\"1.5.2\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DLT_OBJDIR=\".libs/\" -D_REVISION=\"1.5.2\" -DHAVE_OPENSSL_CRYPTO_H=1 -DHAVE_OPENSSL_CMAC_H=1 -DHAVE_OPENSSL_CMAC_H=1 -DHAVE_SQLITE3_H=1 -DHAVE_SQLITE3=1 -DHAVE_SQLITE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_PTHREAD_PRIO_INHERIT=1 -D_REENTRANT=1 -DHAVE___MINGW_ALIGNED_MALLOC=1 -DCACHELINE_SIZE=64 -DINTEL_ASM=1 -DCACHELINE_SIZE=64 -I. -I../.. -I../../src/include -I../../src -DCYGWIN -DMSYS2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_FORTIFY_SOURCE=2 -pthread -Wall -O3 -std=gnu99 -fno-strict-aliasing -Wpointer-arith -Wstrict-overflow=2 -Wstrict-prototypes -fvisibility=hidden -Wno-unused-but-set-variable -Wno-array-bounds -mconsole -mwindows -DMSYS2 -MT libaircrack_crypto_la-sha1-git.lo -MD -MP -MF .deps/libaircrack_crypto_la-sha1-git.Tpo -c sha1-git.c -DDLL_EXPORT -DPIC -o .libs/libaircrack_crypto_la-sha1-git.o sha1-git.c: In function 'blk_SHA1_Final': sha1-git.c:328:21: error: 'uint32_t' undeclared (first use in this function); did you mean 'wint_t'? padlen[0] = htonl((uint32_t)(ctx->size >> 29));
编辑
- 我的Msys2的子目录树下有不少
stdint.h,作为候选。我应该能够通过检查编译命令行、列出包含目录的顺序等“手动”跟踪包含stdint.h,并且我之前做过几次。 但我的意思是自动执行此操作,以避免错误。
PS:由于我在 Msys2 下,我(递归地)更改了所有出现的
#include <arpa/inet.h>
经过
#include <winsock.h>
在src/*.h 和src/*.c。
在文件src/sha1-git.c 我添加了
#include <stdint.h>
之后(插入第 43 行)获取uint32_t。
PS2:还有一个文件src/aircrack-crypto/sha1-git.c 没有
#include <stdint.h>。
该文件的编译是问题所在。我在另一个文件中添加了#include ... 并继续编译。
PS3:我的意思是完成这项工作,所以也许这个特定 OP 的答案只是朝着目标前进了一步,但还不够......
编辑 2 已确认。
在不得不执行make V=1 CFLAGS="-I/usr/include" LDFLAGS="-L/usr/lib"(否则编译common.c时找不到sys/wait.h)后,我得到了
.../MSYS2Portable/App/msys32/mingw64/x86_64-w64-mingw32/include/winsock.h:309:34: error: conflicting types for 'gethostname'
WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen);
^~~~~~~~~~~
In file included from .../MSYS2Portable/App/msys32/usr/include/unistd.h:4,
from common.c:42:
.../MSYS2Portable/App/msys32/usr/include/sys/unistd.h:300:6: note: previous declaration of 'gethostname' was here
int gethostname (char *__name, size_t __len);
^~~~~~~~~~~
make[2]: *** [Makefile:713: libaircrack_util_la-common.lo] Error 1
mingw64/x86_64-w64-mingw32/include 中的文件似乎与usr/include 中的文件不一致。
而且mingw64/x86_64-w64-mingw32/include中没有sys/wait.h,所以我还要在搜索路径中添加usr/include,给我带来麻烦。
我可能会放弃在Msys2下编译,我会得到一个vbox。
【问题讨论】:
-
使用 GCC,
-H选项列出了包含的标头,并指示了嵌套级别。您需要指定您正在使用的编译器;适用于 GCC 的可能适用于 Clang,但可能不适用于其他编译器。 -
它是 GCC,在带有
./configure的包上。我通过make V=1获得了编译期间使用的命令行。我不确定如何在这里申请-H。 -
试试
./configure CC='gcc -H'。不要永久使用它,但它会使 C 编译器设置为包含-H。 -
FWIW,根据当前来源(我用谷歌搜索了该项目),sha1-git.c 似乎根本没有引用 stdint.h。对我来说看起来像一个程序员错误,可能依赖于通过 string.h 或 arpa/inet.h(在 sha1-git.h 中)的传递包含。您确定它是否包含 stdint.h ?您的问题似乎取决于您已经确定了这一点。否则我认为您应该与开发人员联系。
-
Aaaaaand it's been fixed on master since the last release, 1.5.2(commit;不幸的是,才一个月后)