我正在尝试使用mingw编译器在Windows上编译libaws。在libaws(https://sourceforge.net/projects/libaws/)代码中,我试试这个:
C:/la/include/libaws/config.h:2:0: warning: "WIN32" redefined [enabled by default]
<built-in>:0:0: note: this is the location of the previous definition
In file included from C:/tools/libaws-0.9.2/src/canonizer.h:23:0,
from C:\tools\libaws-0.9.2\src\s3\s3connection.cpp:25:
C:/tools/libaws-0.9.2/src/s3/s3connection.h:62:9: error: expected identifier before '(' token
C:/tools/libaws-0.9.2/src/s3/s3connection.h:62:9: error: expected '}' before '(' token
C:/tools/libaws-0.9.2/src/s3/s3connection.h:62:9: error: expected unqualified-id before numeric constant
C:/tools/libaws-0.9.2/src/s3/s3connection.h:62:9: error: expected ')' before numeric constant
C:/tools/libaws-0.9.2/src/s3/s3connection.h:70:5: error: expected unqualified-id before 'public'
C:/tools/libaws-0.9.2/src/s3/s3connection.h:109:19: error: 'ActionType' was not declared in this scope
C:/tools/libaws-0.9.2/src/s3/s3connection.h:109:43: error: expected primary-expression before 'const'
C:/tools/libaws-0.9.2/src/s3/s3connection.h:110:19: error: expected primary-expression before 'const'
C:/tools/libaws-0.9.2/src/s3/s3connection.h:110:51: error: expected primary-expression before 'aExpiration'
C:/tools/libaws-0.9.2/src/s3/s3connection.h:129:5: error: expected unqualified-id before 'private'
C:/tools/libaws-0.9.2/src/s3/s3connection.h:135:51: error: 'ActionType' has not been declared
C:/tools/libaws-0.9.2/src/s3/s3connection.h:139:40: error: variable or field 'setRequestMethod' declared void
C:/tools/libaws-0.9.2/src/s3/s3connection.h:139:40: error: 'ActionType' was not declared in this scope
C:/tools/libaws-0.9.2/src/s3/s3connection.h:154:5: error: expected unqualified-id before 'public'
C:/tools/libaws-0.9.2/src/s3/s3connection.h:161:1: error: expected declaration before '}' token
C:/tools/libaws-0.9.2/src/s3/s3connection.h:143:7: warning: 'size_t aws::s3::getS3Data(void*, size_t, size_t, void*)' declared 'static' but never defined [-Wunused-function]
C:/tools/libaws-0.9.2/src/s3/s3connection.h:146:7: warning: 'size_t aws::s3::setCreateBucketData(void*, size_t, size_t, void*)' declared 'static' but never defined [-Wunused-function]
C:/tools/libaws-0.9.2/src/s3/s3connection.h:149:7: warning: 'size_t aws::s3::setPutData(void*, size_t, size_t, void*)' declared 'static' but never defined [-Wunused-function]
C:/tools/libaws-0.9.2/src/s3/s3connection.h:152:7: warning: 'size_t aws::s3::getHeaderData(void*, size_t, size_t, void*)' declared 'static' but never defined [-Wunused-function]
src\CMakeFiles\aws.dir\build.make:561: recipe for target 'src/CMakeFiles/aws.dir/s3/s3connection.cpp.obj' failed
mingw32-make[2]: *** [src/CMakeFiles/aws.dir/s3/s3connection.cpp.obj] Error 1
CMakeFiles\Makefile2:1006: recipe for target 'src/CMakeFiles/aws.dir/all' failed
mingw32-make[1]: *** [src/CMakeFiles/aws.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
C:\la>
发生这种情况的地方是在一个班级
class S3Connection {
enum ActionType {
// VALUES
};
};
答案 0 :(得分:1)
好吧,您显然正在WIN32
内重新定义enum
。 WIN32
是在Windows平台上预定义的。
修改强> 您的日志中实际上有2个错误:
在WIN32
中重新定义 config.h
,该库实际上指导您如何进行每个平台的配置:
// unset WIN32 for cygwin environment
#cmakedefine CYGWIN
#ifdef CYGWIN
# undef WIN32
#endif
第二个问题在@MichaelBurr回答中指出。
答案 1 :(得分:1)
问题是s3connection.h
中的一个枚举名称与Win32 SDK中的宏名称冲突。在Win32中,DELETE
是用于处理ACL(访问控制列表)的宏。处理这个问题的最佳方法可能是:
#undef DELETE
在包含Windows标头之后以及包含libaws
标头之前的某处。
或者修改枚举名称(以及它们可能被使用的任何地方),这样就没有冲突。
请记住,这表明libaws
可能没有直接在Windows目标上使用/测试,因此您可能需要支付更多费用才能成为先锋。使用Cygwin而不是MinGW可能会更好运,因为看起来libaws
至少在Cygwin平台上完成了一些工作。