尝试在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.html或Apache 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/