我正在使用MinGW构建适应性通信环境(ACE) 6.4.2,下面是ROOT/ACE/ACE-INSTALL.html#mingw中的步骤。我使用Windows10 64位操作系统。我对构建C++项目非常陌生。
我从https://sourceforge.net/projects/mingw/files/安装了https://sourceforge.net/projects/mingw/files/。我相信这是一个32位版本。我使用MinGW安装管理器下载所有软件包。
我从http://download.dre.vanderbilt.edu/下载了ACE6.4.2并解压缩到E:/依赖/ ACE - 6.4.2

MinGW的根级文件夹结构如下所示。

我包括E:/依赖项/MinGW/bin和E:/依赖项/MinGW/msys/1.0/bin到系统变量path。
我做了以下步骤:
MSYS shell。将PATH环境变量设置为MinGW的bin目录:
export PATH=/e/dependencies/MinGW/bin:$PATHACE_ROOT环境变量:
export ACE_ROOT=/e/dependencies/ACE-6.4.2/ACE_wrappersconfig.h的$ACE_ROOT/ace目录中创建了一个名为#include "ace/config-win32.h"的文件platform_macros.GNU目录中创建了一个名为$ACE_ROOT/include/makeinclude的文件,其中包括:
include $(ACE_ROOT)/include/makeinclude/platform_mingw32.GNU INSTALL_PREFIX=/e/dependencies/ACE-6.4.2-installMSYS外壳中,
cd $ACE_ROOT/ace make据我所知,将使用MinGW中的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来使用ACE进行应用程序开发。我只能找到MinGw 32位版本的QT构建。这就是为什么我选择MinGW 32位来构建ACE。
发布于 2017-12-25 13:35:32
我在重新定义timespec时遇到了同样的问题。我将tdm-gcc-5.1.0-3与git-bash结合使用。在我的例子中,问题是timespec是在pthread.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的方法是行不通的。一般说来,这不是一个好的解决办法.
如果您使用的都是从mingw安装的msys + mingw-get,那么您将在time.h中定义timespec。解决方案类似:
// 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。您可能会发现特定的宏适合您的问题。
另外,在使用tdm和git-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而mingw和msys提供了成功的构建。
发布于 2018-05-16 18:45:18
我做过同样的事情,也遇到过同样的错误。据我所知,这是一个开放源码。但是,需要更新指令,或者至少指定用于生成的版本。在config.h文件中添加“# ACE_HAS_POSIX_TIME 1”确实修复了错误。struct在mingw/include/time.h中定义。(我的g++.exe在6.3.0版)。如果未定义ACE_HAS_POSIX_TIME,则$ACE_ROOT/ace/os_include/os_time.h将再次尝试定义它,因此出现错误。
发布于 2020-05-07 14:04:49
在您的示例中,您可以遵循错误消息:
ace/os_include/os_time.h:56:16: error: redefinition of 'struct timespec'
typedef struct timespec如果您在该行中打开文件,that将被一个#(如果定义为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_Thttps://stackoverflow.com/questions/42763665
复制相似问题