如何在 Ace Root 中为 MingW-64 构建没有 MakeFile 的 ACE
Posted
技术标签:
【中文标题】如何在 Ace Root 中为 MingW-64 构建没有 MakeFile 的 ACE【英文标题】:How to build ACE for MingW-64 no MakeFile in Ace Root 【发布时间】:2015-04-25 04:05:39 【问题描述】:我正在尝试在 Windows 上为 Mingw GCC 64 位构建 ACE 库。指令here 声明如下:
将 MinGW 工具(包括 MinGW 开发工具包)安装到公共目录中,例如 c:/mingw
。
将 MSYS 工具安装到一个公共目录中,例如 c:/msys
。
打开一个 MSYS shell。设置你的 PATH
环境变量,以便你的 MinGW 的 bin 目录是第一个:
% export PATH=/c/mingw/bin:$PATH
添加一个ACE_ROOT
环境变量指向您的ACE 包装源代码树的根:
% export ACE_ROOT=/c/work/mingw/ACE_wrappers
从现在开始,我们将 ACE 源代码树的根目录称为$ACE_ROOT
。
在$ACE_ROOT/ace
目录中创建一个名为 config.h 的文件,其中包含:
#include "ace/config-win32.h"
在$ACE_ROOT/include/makeinclude
目录中创建一个名为platform_macros.GNU 的文件,其中包含:
include $(ACE_ROOT)/include/makeinclude/platform_mingw32.GNU
在上面的文本中,不要用实际目录替换$(ACE_ROOT)
,GNU make 会从你之前定义的环境变量中获取值。
如果您缺少 Winsock 2,请添加该行
winsock2 = 0
在上一个之前。
如果您想安装 ACE(使用“make install”)并希望生成所有 .pc 文件,请在 platform_macros.GNU 中设置安装前缀。
INSTALL_PREFIX=/c/ACE
头文件将安装到$INSTALL_PREFIX/include
,文档和构建系统文件将安装到$INSTALL_PREFIX/share
,库将安装到$INSTALL_PREFIX/lib
。设置INSTALL_PREFIX
后,将启用RPATH
。要禁用RPATH
(例如,如果$INSTALL_PREFIX/$INSTALL_LIB
已经是共享库的系统已知位置),请通过将install_rpath=0
添加到platform_macros.GNU 来将make 宏install_rpath 设置为0。
这里的问题:
在 MSYS shell 中,切换到 $ACE_ROOT/ace
目录并运行 make:
% cd $ACE_ROOT/ace
% make
现在我注意到ACE_ROOT/ace
中没有 MakeFile,即 C:\mingw64\Other\ACE_wrappers\ace
我从here 下载了我的 ACE 资料。 关于我可能做错了什么的任何建议?我是不是下载错了?
【问题讨论】:
【参考方案1】:您似乎下载了仅源代码发行版,请下载完整的软件包,其中还包括 GNU makefile,请参阅 http://download.dre.vanderbilt.edu/
【讨论】:
【参考方案2】:ACE 带有GNUmakefile
-s 的完整版,
在 MSYS 你给make -f GNUmakefile
编辑 1 尽管许多平台和编译器都支持构建 64 位二进制文件,但 ACE 团队并未为 MINGW 提供它。有事要做……
编辑 2 以下脚本应该对 MingW-64 中的 64 位二进制文件进行配置
#! /bin/bash
#
# Configure ACE/TAO for 32/64 bit build with MINGW64
#
# Precondition:
# This script is located in the parent folder of ACE_Wrappers
# File access permissions in ACE_Wrappers allow editing of files (sed):
# Easyest, delivered full ACE/TAO ZIP was extracted using Windows Explorer.
# When extracting with 7z, it will correctly preserve access rights and
# they need to be granted for the user, explicitly
#
# Postcondition:
# ACE is configured for MINGW build
# Script is involutoric
#
# Author: Sam Ginrich
# No warranty of any kind!
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
#
# Definition of Setup parameters
# these are entered into configuration files, if not already there, never modified!
#
#
#buildbits= # does nothing
#buildbits=32 # configure 32-bit build
#buildbits=64 # configure 64-bit build
buildbits=64
#winsock2=0 # configure parameter to exclude winsock2 library
#winsock2=1 # configure parameter to include winsock2 library
#winsock2= # does nothing, same effect as winsock2=1
winsock2=
# Issue with header "$ACE_ROOT/ace/OS_NS_stdlib.h"
# In some MINGW installation, the compiler is confused with a defined 'rand_r' macro
# This takes effect when building TAO, not ACE
#
#rand_r_issue= # does nothing, suggested initial value
#rand_r_issue=1 # modifies "$ACE_ROOT/ace/OS_NS_stdlib.h" to #undef-ine macro 'rand_r',
# before impact, suggested when issue occurs
rand_r_issue=
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "ACE/TAO Build Target Values"
echo ""
echo "buildbits=$buildbits"
echo "winsock2=$winsock2"
echo "rand_r_issue=$rand_r_issue"
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""
echo "STEP: Enter ACE_Wrappers and define locations"
cd ./ACE_Wrappers
# Check, whether we arrives there ...
if [ ! -f "./ACE-INSTALL.html" ]; then
echo "ACE_Wrappers missing or invalid ... STOP"
exit 1
fi
export ACE_ROOT=$PWD
export TAO_ROOT=$ACE_ROOT/TAO
# Set C-Config Header for Windows
echo '#include "ace/config-win32.h"' > ace/config.h
# Set Platform MINGW
pl_macro=$ACE_ROOT/include/makeinclude/platform_macros.GNU
pl_mingw='$(ACE_ROOT)/include/makeinclude/platform_mingw32.GNU'
echo "include $pl_mingw" > $pl_macro
if [ "$buildbits" != "" ];
then
echo "------------------------------------------------------------"
echo ""
echo "STEP: Provide support for 64-bit build in 'platform_g++_common.GNU'"
pl_gpp=$ACE_ROOT/include/makeinclude/platform_g++_common.GNU
donetag2=" FLAGS_C_CC += -m64"
marker2="CCFLAGS += -Wnon-virtual-dtor"
buildbitsSwitch="ifeq (\$(buildbits),32)\n FLAGS_C_CC += -m32\n LDFLAGS += -m32\nendif\nifeq (\$(buildbits),64)\n FLAGS_C_CC += -m64\n LDFLAGS += -m64\nendif"
case `grep -Fx "$donetag2" "$pl_gpp" >/dev/null; echo $?` in
0)
echo "File $pl_gpp already modified "
;;
1)
# anyway store a copy
cp $pl_gpp /tmp
echo "copy of original $pl_gpp stored in \\tmp"
echo "insert compiler switches for buildbits rule"
sed -i "s/$marker2/$marker2\n\n$buildbitsSwitch/g" $pl_gpp
;;
*)
echo "Error scanning file $pl_gpp"
;;
esac
echo "------------------------------------------------------------"
echo ""
pl_mingw=$ACE_ROOT/include/makeinclude/platform_mingw32.GNU
echo "STEP: Set parameter for 64-bit build in $pl_mingw"
donetag3="buildbits =.*"
marker3="mingw32 = 1"
buildbitsDef="# 32\/64-bit build\n# parameter 'buildbits' is applied in platform_gnuwin32_common.GNU\nbuildbits = $buildbits"
case `grep -Ex "$donetag3" "$pl_mingw" >/dev/null; echo $?` in
0)
echo "File $pl_mingw already modified "
echo "Verify value! "
grep "buildbits =" $pl_mingw
;;
1)
# anyway store a copy
cp $pl_mingw /tmp
echo "copy of original $pl_mingw stored in \\tmp"
echo "insert buildbits=$buildbits"
sed -i "s/$marker3/$marker3\n\n$buildbitsDef/g" $pl_mingw
;;
*)
echo "Error scanning file $pl_mingw"
;;
esac
fi
if [ "$winsock2" != "" ];
then
echo "------------------------------------------------------------"
echo ""
#pl_mingw=$ACE_ROOT/include/makeinclude/platform_mingw32.GNU
echo "STEP: Winsock lack control"
donetag4="winsock2 =.*"
marker4=$marker3
winsockDef="winsock2 = $winsock2"
# $donetag4 is regular expression, -E
case `grep -Ex "$donetag4" "$pl_mingw" >/dev/null; echo $?` in
0)
echo "File $pl_mingw already modified "
echo Verify Value!
grep "winsock2 =" $pl_mingw
;;
1)
# anyway store a copy
cp $pl_mingw /tmp
echo "copy of original $pl_mingw stored in \\tmp"
echo insert $winsockDef
sed -i "s/$marker4/$marker4\n\n$winsockDef/g" $pl_mingw
;;
*)
echo "Error scanning file $pl_mingw"
;;
esac
fi
if [ "$rand_r_issue" == "1" ];
then
echo "------------------------------------------------------------"
echo ""
echo "STEP: Handle issue with defined C-macro rand_r"
onsll=$ACE_ROOT/ace/OS_NS_stdlib.h
donetag1="//#rand_undefined"
case `grep -Fx "$donetag1" "$onsll" >/dev/null; echo $?` in
0)
echo "File $onsll already modified"
;;
1)
# anyway store a copy
cp $onsll /tmp
echo "copy of original $pl_gpp stored in \\tmp"
echo "insert '#undef rand_r'"
sed -i 's/#if !defined (ACE_LACKS_RAND_R)/\/\/#rand_undefined\n#undef rand_r\n#if !defined (ACE_LACKS_RAND_R)/g' $onsll
;;
*)
echo "Error scanning file $onsll"
;;
esac
fi
echo "============================================================"
echo ""
echo "Content of "$ACE_ROOT/ace/config.h" is"
cat "ace/config.h"
echo ""
echo Content of "$pl_macro" is
cat $pl_macro
echo "-------------------------------------------------------------"
echo ""
echo ""
echo ""
echo "Suggested BUILD STEPS:"
echo ""
echo ""
echo "# 1. Define context"
echo "export ACE_ROOT=$PWD"
echo "export TAO_ROOT=$ACE_ROOT/TAO"
echo ""
echo "# 2. Build ACE"
echo 'cd $ACE_ROOT/ace'
echo "make -f GNUmakefile"
echo ""
echo "# 3. Verify ACE"
echo 'cd $ACE_ROOT/tests'
echo "make -f GNUmakefile"
echo "perl run_test.pl"
echo "#NOTE: Windows Firewall will ask for permission for each upcoming server instance"
echo ""
echo "# 4. Build TAO"
echo 'cd $TAO_ROOT'
echo "make -f GNUmakefile"
echo ""
echo "# 5. Basic TAO verification"
echo 'cd $TAO_ROOT/tests'
echo "make -f GNUmakefile"
echo 'cd $TAO_ROOT/tests/Param_Test'
echo "perl run_test.pl"
【讨论】:
以上是关于如何在 Ace Root 中为 MingW-64 构建没有 MakeFile 的 ACE的主要内容,如果未能解决你的问题,请参考以下文章