0

我正在尝试使用 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
    };
};
4

2 回答 2

1

好吧,你显然是在重新定义WIN32你的enum. WIN32在 Windows 平台上预定义。

编辑: 您的日志中实际上有 2 个错误:

WIN32重新定义config.h,该库实际上会指导您如何进行每个平台的配置:

// unset WIN32 for cygwin environment
#cmakedefine CYGWIN
#ifdef CYGWIN
#  undef WIN32
#endif

@MichaelBurr 回答中指出了第二个问题。

于 2012-11-21T07:16:47.727 回答
1

问题是枚举名称之一s3connection.h与 Win32 SDK 中的宏名称冲突。在 Win32 中,DELETE是用于处理 ACL(访问控制列表)的宏。处理此问题的最佳方法可能是:

#undef DELETE

在包含 Windows 标头之后和包含libaws标头之前的某个位置。

要么这样,要么修改枚举名称(以及可能使用它们的任何地方),这样就不会发生冲突。

请记住,这表明libaws可能没有直接在 Windows 目标上进行太多使用/测试,因此您可能需要支付更多费用才能成为先驱。使用 Cygwin 而不是 MinGW 可能会更好,因为它看起来libaws至少在 Cygwin 平台上完成了一些工作。

于 2012-11-21T07:47:07.460 回答