使用MinGW构建自适应通信环境(ACE)

时间:2017-03-13 12:28:36

标签: c++ mingw32 ace

我正在http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ACE-INSTALL.html#mingw中使用MinGW以下步骤构建自适应通信环境(ACE)6.4.2。我使用Windows10 64位操作系统。我是构建C ++项目的新手。

我从https://sourceforge.net/projects/mingw/files/安装了MinGW。我相信它是32位版本。我使用MinGW安装管理器下载所有软件包。

我从http://download.dre.vanderbilt.edu/下载了ACE 6.4.2并解压缩到E:/dependencies/ACE-6.4.2

enter image description here

MinGW的根级文件夹结构如下所示。 enter image description here

我将E:/ dependencies / MinGW / bin和E:/dependencies/MinGW/msys/1.0/bin包含在系统变量path中。

我做了以下步骤:

  1. 打开MSYS shell。将PATH环境变量设置为MinGW的bin目录:

    export PATH=/e/dependencies/MinGW/bin:$PATH

  2. 添加了指向ACE包装器源树根的ACE_ROOT环境变量:

    export ACE_ROOT=/e/dependencies/ACE-6.4.2/ACE_wrappers

  3. config.h目录中创建了一个名为$ACE_ROOT/ace的文件,其中包含: #include "ace/config-win32.h"

  4. platform_macros.GNU目录中创建了一个名为$ACE_ROOT/include/makeinclude的文件,其中包含:

    include $(ACE_ROOT)/include/makeinclude/platform_mingw32.GNU INSTALL_PREFIX=/e/dependencies/ACE-6.4.2-install

  5. MSYS shell中,

    cd $ACE_ROOT/ace make

  6. 我所理解的是g++中的MinGW将被使用。

    错误日志

    make[3]: Entering directory 'e:/dependencies/ACE-6.4.2/ACE_wrappers/ace'
    
    GNUmakefile: /e/dependencies/ACE-6.4.2/ACE_wrappers/ace/GNUmakefile.ACE MAKEFLAGS=w
    
    g++ -Wnon-virtual-dtor -O3 -g -mthreads -mtune=pentiumpro -fno-strict-aliasing -Wall -W -Wpointer-arith -pipe -DACE_HAS_CUSTOM_EXPORT_MACROS=0 -Wno-unknown-pragmas   -Ie:/dependencies/ACE-6.4.2/ACE_wrappers -DACE_NO_INLINE -I.. -DACE_BUILD_DLL  -c  -o .shobj/Local_Name_Space.o Local_Name_Space.cpp
    In file included from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/os_include/os_sched.h:25:0,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/OS_NS_Thread.h:30,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Thread_Mutex.h:29,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Log_Category.h:18,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc.h:22,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc_T.h:16,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space.h:18,
                     from Local_Name_Space.cpp:1:
    e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/os_include/os_time.h:56:16: error: redefinition of 'struct timespec'
     typedef struct timespec
                    ^
    In file included from e:\dependencies\mingw\include\sys\time.h:3:0,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/os_include/sys/os_time.h:28,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/os_include/sys/os_resource.h:25,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/os_include/sys/os_wait.h:26,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/os_include/os_stdlib.h:27,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Basic_Types.h:54,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Log_Msg.h:26,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Log_Category.h:17,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc.h:22,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc_T.h:16,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space.h:18,
                     from Local_Name_Space.cpp:1:
    e:\dependencies\mingw\include\time.h:102:8: error: previous definition of 'struct timespec'
     struct timespec
            ^
    In file included from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space_T.cpp:15:0,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space_T.h:259,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space.h:126,
                     from Local_Name_Space.cpp:1:
    e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/OS_NS_unistd.h:322:45: warning: 'useconds_t' is deprecated [-Wdeprecated-declarations]
                          useconds_t interval = 0);
                                                 ^
    In file included from e:\dependencies\mingw\include\wchar.h:66:0,
                     from e:\dependencies\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:44,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/ace_wchar.h:43,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/config-lite.h:33,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/ACE_export.h:10,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc.h:16,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc_T.h:16,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space.h:18,
                     from Local_Name_Space.cpp:1:
    e:\dependencies\mingw\include\sys\types.h:221:23: note: declared here
     typedef unsigned long useconds_t __MINGW_ATTRIB_DEPRECATED;
                           ^
    In file included from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space_T.cpp:15:0,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space_T.h:259,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space.h:126,
                     from Local_Name_Space.cpp:1:
    e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/OS_NS_unistd.h:322:45: warning: 'useconds_t' is deprecated [-Wdeprecated-declarations]
                          useconds_t interval = 0);
                                                 ^
    e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/OS_NS_unistd.h:322:45: warning: 'useconds_t' is deprecated [-Wdeprecated-declarations]
    e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/OS_NS_unistd.h:326:78: warning: 'useconds_t' is deprecated [-Wdeprecated-declarations]
                          const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
                                                                                  ^
    In file included from e:\dependencies\mingw\include\wchar.h:66:0,
                     from e:\dependencies\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:44,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/ace_wchar.h:43,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/config-lite.h:33,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/ACE_export.h:10,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc.h:16,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Malloc_T.h:16,
                     from e:/dependencies/ACE-6.4.2/ACE_wrappers/ace/Local_Name_Space.h:18,
                     from Local_Name_Space.cpp:1:
    e:\dependencies\mingw\include\sys\types.h:221:23: note: declared here
     typedef unsigned long useconds_t __MINGW_ATTRIB_DEPRECATED;
                           ^
    e:/dependencies/ACE-6.4.2/ACE_wrappers/include/makeinclude/rules.local.GNU:188: recipe for target '.shobj/Local_Name_Space.o' failed
    make[3]: *** [.shobj/Local_Name_Space.o] Error 1
    make[3]: Leaving directory 'e:/dependencies/ACE-6.4.2/ACE_wrappers/ace'
    GNUmakefile:45: recipe for target 'ACE' failed
    make: *** [ACE] Error 2
    

    最终,我必须使用QT Creator使用ACE进行应用程序开发。我只能找到MinGw 32位版本的QT版本。这就是为什么我选择MinGW 32位来构建ACE。

3 个答案:

答案 0 :(得分:0)

我遇到了与timespec重新定义相同的问题。我正在tdm-gcc-5.1.0-3使用git-bash。就我而言,问题是timespecpthread.h都定义了ace/os_include/os_time.h。解决此问题的一种方法是编辑ace/config.h

// Get 'timespec' explicitly from here. 
#include <pthread.h>

// Tell ACE to do not declare 'timespec'. 
#define ACE_HAS_POSIX_TIME 1

// Tell ACE to declare 'timespec_t' alias.
#define ACE_LACKS_TIMESPEC_T 1

// Default windows config, see ACE install manual.
#include "ace/config-win32.h"

使用HAVE_STRUCT_TIMESPEC的方法在我的案例中不起作用。一般来说,it is not a good solution

如果您使用的mingw + msys都来自mingw-get,那么您将在timespec中定义time.h。解决方案类似:

// Tell ACE to do not declare 'timespec'. 
#define ACE_HAS_POSIX_TIME 1

// Tell ACE to declare 'timespec_t' alias.
#define ACE_LACKS_TIMESPEC_T 1

// Default windows config, see ACE install manual.
#include "ace/config-win32.h"

如果没有帮助,请查看ace/os_include/os_time.h。您可能会发现适合您的问题的特定宏。

作为旁注,我在使用tdmgit-bash时遇到链接错误。看起来很奇怪,我还不知道为什么会这样。例如,

代表ACE-6.3.2

C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../../mingw32/bin/ld.exe: cannot find .: Permission denied
collect2.exe: error: ld returned 1 exit status

代表ACE-6.4.0

g++.exe: error: .shobj/Filecac: No such file or directory

代表ACE-6.4.6

g++.exe: error: .shobj/Co: No such file or directory

虽然mingwmsys提供了成功的构建。

答案 1 :(得分:0)

我做了完全相同的事情并遇到了同样的错误。我知道它是一个开源的。但是,该指令需要更新或至少指定用于进行构建的版本。添加 config.h文件中的“#define ACE_HAS_POSIX_TIME 1”确实修复了错误。 struct timespec在mingw / include / time.h中定义。 (我的g ++。exe版本是6.3.0)。如果未定义ACE_HAS_POSIX_TIME,则$ ACE_ROOT / ace / os_include / os_time.h将尝试再次定义它,因此出现错误。

答案 2 :(得分:0)

在示例中,您可以按照错误消息进行操作:

ace/os_include/os_time.h:56:16: error: redefinition of 'struct timespec'
 typedef struct timespec

如果在该行打开文件,则typedef将被 #if定义的XXX 宏包围,您可以从中看到需要定义或取消定义XXX的宏。对于我来说,例如类似的问题,我必须通过以下方式修改config.h:

#define ACE_HAS_POSIX_TIME 1
#define ACE_LACKS_TIMESPEC_T 1

#include "ace/config-win32.h"
#undef ACE_LACKS_CLOCKID_T