交叉编译libACE

1. 下载

访问ACE的官网http://download.dre.vanderbilt.edu/

下载ACE.tar.gz2 ,链接http://download.dre.vanderbilt.edu/previous_versions/ACE-6.2.4.tar.bz2

关于需要使用的sunxi交叉编译器,见http://blog.csdn.net/sakaue/article/details/19403025

2. 准备

执行命令,设置ACE_ROOT环境变量

export ACE_ROOT=/home/sakaue/ace/ACE_wrappers
cd ~/ACE_wrappers/ace/
cp ./config-linux.h ./config.h
cd ../include/makeinclude/
ln -s ./platform_linux.GNU ./platform_macros.GNU

修改Makefile中的编译器为sunxi的arm-linux-gnueabihf-*,Vi打开 include/makeinclude/platform_g++_common.GNU,原文为:

ifeq ($(insure),1)
	CC  = insure
	CXX = insure
else
	ifneq ($(CROSS_COMPILE),)
		CROSS-COMPILE = 1
		# Build using the cross-tools
		ifneq ($($CROSS_COMPILE_POSTFIX),)
			CC  = ${CROSS_COMPILE}gcc{$CROSS_COMPILE_POSTFIX}
			CXX = ${CROSS_COMPILE}g++{$CROSS_COMPILE_POSTFIX}
			AR  = ${CROSS_COMPILE}ar{$CROSS_COMPILE_POSTFIX}
		else
			CC  = ${CROSS_COMPILE}gcc
			CXX = ${CROSS_COMPILE}g++
			AR  = ${CROSS_COMPILE}ar
		endif
		# Cross-linker requires this for linked in shared libs that depend
		# themselves on other shared libs (not directly linked in)
		LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib
		ifneq (,$(HOST_ROOT))
			TAO_IDLFLAGS += -g $(HOST_ROOT)/bin/ace_gperf
			TAO_IDL = $(HOST_ROOT)/bin/tao_idl
			TAO_IDL_DEP = $(TAO_IDL)
			TAO_IDL3_TO_IDL2 = $(HOST_ROOT)/bin/tao_idl3_to_idl2
			TAO_IDL3_TO_IDL2_DEP = $(TAO_IDL3_TO_IDL2)
			TAO_IDL3_TO_XMI = $(HOST_ROOT)/bin/tao_idl3_to_xmi
			TAO_IDL3_TO_XMI_DEP = $(TAO_IDL3_TO_XMI)
			# make sure to use the target compiler, not the cross-compiler
			# as preprocessor for the cross-compiled idl tools
			TAO_IDL_PREPROCESSOR = gcc
		endif
	endif
endif
修改为

CROSS_COMPILE:=arm-linux-gnueabihf-

#ifeq ($(insure),1)
#	CC  = insure
#	CXX = insure
#else
	ifneq ($(CROSS_COMPILE),)
		CROSS-COMPILE = 1
		# Build using the cross-tools
		ifneq ($($CROSS_COMPILE_POSTFIX),)
			CC  = ${CROSS_COMPILE}gcc{$CROSS_COMPILE_POSTFIX}
			CXX = ${CROSS_COMPILE}g++{$CROSS_COMPILE_POSTFIX}
			AR  = ${CROSS_COMPILE}ar{$CROSS_COMPILE_POSTFIX}
		else
			CC  = ${CROSS_COMPILE}gcc
			CXX = ${CROSS_COMPILE}g++
			AR  = ${CROSS_COMPILE}ar
		endif
		# Cross-linker requires this for linked in shared libs that depend
		# themselves on other shared libs (not directly linked in)
		LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib
		ifneq (,$(HOST_ROOT))
			TAO_IDLFLAGS += -g $(HOST_ROOT)/bin/ace_gperf
			TAO_IDL = $(HOST_ROOT)/bin/tao_idl
			TAO_IDL_DEP = $(TAO_IDL)
			TAO_IDL3_TO_IDL2 = $(HOST_ROOT)/bin/tao_idl3_to_idl2
			TAO_IDL3_TO_IDL2_DEP = $(TAO_IDL3_TO_IDL2)
			TAO_IDL3_TO_XMI = $(HOST_ROOT)/bin/tao_idl3_to_xmi
			TAO_IDL3_TO_XMI_DEP = $(TAO_IDL3_TO_XMI)
			# make sure to use the target compiler, not the cross-compiler
			# as preprocessor for the cross-compiled idl tools
			TAO_IDL_PREPROCESSOR = gcc
		endif
	endif
#endif
3. 编译

执行make,编译了一阵后出现错误:

.shobj/MEM_Acceptor.o:(.rodata+0x0): multiple definition of `typeinfo name for ACE_Singleton<ACE_Based_Pointer_Repository, ACE_RW_Thread_Mutex>'
.shobj/Based_Pointer_Repository.o:(.rodata+0x0): first defined here
.shobj/MEM_Acceptor.o:(.data.rel.ro+0x0): multiple definition of `typeinfo for ACE_Singleton<ACE_Based_Pointer_Repository, ACE_RW_Thread_Mutex>'
.shobj/Based_Pointer_Repository.o:(.data.rel.ro+0x0): first defined here
.shobj/MEM_Connector.o:(.rodata+0x0): multiple definition of `typeinfo name for ACE_Singleton<ACE_Based_Pointer_Repository, ACE_RW_Thread_Mutex>'
.shobj/Based_Pointer_Repository.o:(.rodata+0x0): first defined here
.shobj/MEM_Connector.o:(.data.rel.ro+0x0): multiple definition of `typeinfo for ACE_Singleton<ACE_Based_Pointer_Repository, ACE_RW_Thread_Mutex>'
.shobj/Based_Pointer_Repository.o:(.data.rel.ro+0x0): first defined here
  ...
推测是ace/config-g++-common.h中的宏定义

ACE_EXPORT_SINGLETON_DECLARATION

ACE_EXPORT_SINGLETON_DECLARE

造成的,修改ace/config.h,在其中增加

#define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1
或者,在include/makeinclude/platform_macros.GNU中增加
no_hidden_visibility=1
注意,该语句必须加在include $(ACE_ROOT)/include/makeinclude/platform_linux_common.GNU之前,如

# -*- Makefile -*-
# $Id: platform_linux.GNU 97130 2013-05-13 17:36:26Z mesnier_p $
 
no_hidden_visibility=1

include $(ACE_ROOT)/include/makeinclude/platform_linux_common.GNU

执行

make clean
make
OK,顺利通过



你可能感兴趣的:(交叉编译libACE)