c - 使用Visual Studio(2017)构建Apache APR 1.7,IF_NAMESIZE未定义

标签 c windows visual-studio-2013 visual-studio-2017 apr

尝试在Windows和Visual Studio上构建APR 1.7,尝试了2017年和2013年。

建立项目(Debug | x86)或编译时dso.c如果收到以下错误消息:

1>dso.c
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2143: syntax error: missing ')' before '*'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2143: syntax error: missing '{' before '*'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2059: syntax error: ')'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2061: syntax error: identifier 'apr_winapi_pfn_if_indextoname'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2059: syntax error: ';'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2513: ' ': no variable declared before '='
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2065: 'apr_winapi_pfn_if_indextoname': undeclared identifier
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): warning C4047: '=': 'int' differs in levels of indirection from 'int *(__cdecl *)(NET_IFINDEX,PCHAR)'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2146: syntax error: missing ';' before identifier 'apr_load_dll_func'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2100: illegal indirection
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2064: term does not evaluate to a function taking 1207 arguments
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): warning C4033: 'apr_winapi_if_indextoname' must return a value

我已经成功构建了1.65版(应用了http://letcoderock.blogspot.com/2017/09/build-log4cxx-trunk-on-windows-by.htmlApache Cross Compilation Error ./gen_test_char: cannot execute binary file的提示后)

比较两个版本的apr_arch_misc.h,我注意到DLL_IPHLPAPI是枚举apr_dlltoken_e的新功能,而Intelisense则在提示
APR_DECLARE_LATE_DLL_FUNC(DLL_IPHLPAPI, PCHAR, NETIOAPI_API_, if_indextoname, 0, (
    NET_IFINDEX InterfaceIndex,
    PCHAR       InterfaceName),
    (InterfaceIndex, InterfaceName));

与“期待一个')'”。
如果已将NETIOAPI_API_更改为WINAPI。不知道这是否正确,但是现在可以编译文件了(使用gen_test_char.exe运行上述技巧之后)。

但是之后,我遇到了下一个问题:
1>sockaddr.c
1>network_io\unix\sockaddr.c(144): error C2065: 'IF_NAMESIZE': undeclared identifier
1>network_io\unix\sockaddr.c(144): error C2057: expected constant expression
1>network_io\unix\sockaddr.c(144): error C2466: cannot allocate an array of constant size 0
1>network_io\unix\sockaddr.c(144): error C2133: 'scbuf': unknown size
1>network_io\unix\sockaddr.c(1274): error C2065: 'IF_NAMESIZE': undeclared identifier

我已经成功在Linux/cygwin中用gcc构建了apr。我已经研究了IF_NAMESIZE的预处理器替代品,在这里它被44替代。但是我找不到定义或设置的位置。

有谁知道如何解决这个问题?以上对WINAPI的更改正确吗?

最佳答案

只需使用cmake即可构建Visual Studio解决方案:


cmake -G "Visual Studio 15 2017" -A x64.sln ist正确设置并构建了解决方案,并且没有错误。甚至gen_test_char.exe也已构建。

也许apr项目应该使cmake的构建说明在其站点上更加突出。

关于c - 使用Visual Studio(2017)构建Apache APR 1.7,IF_NAMESIZE未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58560249/

相关文章:

c - 如何在c/c++程序中使用Winpcap库跟踪LoopBack接口(interface)?

python - 理解 np.all 并获取删除的索引时缺少元素

c - 用空格分隔字符串并将其存储在指针数组中

c - 从文件中检索丢失的条目

c++ - 来自 CreateWindow/CreateDialog 的 HWND 是否可以从另一个线程获取消息?

windows - 有没有办法在 Windows 7/8 中关闭 Windows 显示驱动程序模型 (WDDM)?

javascript - typescript 运行时错误

c++ - Visual Studio 2013 中的 OpenGL

c# - 适用于 Windows XP 的 visual studio 2013 安装程序

添加 Mongoose Embedded 后无法弄清楚如何构建 C 应用程序