与其他项目集成时,库会引发编译错误

时间:2016-03-31 19:54:48

标签: c++ linux makefile

我正在开发一个项目,我使用boost :: interprocess来创建共享内存,当我单独编译代码并创建一个客户端时,它工作正常:

Makefile for build .a:

$(info ETLIB_ROOT=$(ETLIB_ROOT) )
include $(ETLIB_ROOT)/.gmake_prologue

$(info BOOST_ROOT=$(BOOST_ROOT))
$(info BOOST_INC=$(BOOST_INC))

OBJDIR=obj
SRC=src
INCLUDE=include
LIB=lib

$(LIB)/libmetricsStore.a: $(OBJDIR)/MetricsStore.o
        ar rcs $@ $^

$(OBJDIR)/MetricsStore.o: $(SRC)/MetricsStore.cpp
        g++ -g -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I$(INCLUDE) -c $(SRC)/MetricsStore.cpp -o $(OBJDIR)/MetricsStore.o


include $(ETLIB_ROOT)/.gmake_epilogue

测试客户端的Makefile:

   include .gmake_prologue
OBJDIR=.
SRC=.
INCLUDE=../metricsstore/include

$(info BOOST_LIB=$(BOOST_LIB))
$(info BOOST_INC=$(BOOST_INC))

client: $(OBJDIR)/client.o
        g++ $(OBJDIR)/client.o -o client  -L$(BOOST_LIB)  -lboost_filesystem-gcc44 -lboost_filesystem-gcc44-mt  -L/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/boost_shared_mem/metricsstore/lib -lmetricsStore -lrt

$(OBJDIR)/client.o: $(SRC)/client.cpp
        g++  -I$(BOOST_INC) -I $(INCLUDE) -c $(SRC)/client.cpp -o $(OBJDIR)/client.o

include .gmake_epilogue

以上两个工作正常,测试客户端正确构建。

测试客户端的gmake -n输出如下:

LIBDIR=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB
LIBDIR in prolouge=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB 
BOOST_ROOT in prolouge=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53 
BOOST_INC in prolouge=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include 
CCFLAGS in prolouge=-g  -mfpmath=sse -msse3  -I. -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include   
BOOST_LIB=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/lib
BOOST_INC=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include
g++  -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I ../metricsstore/include -c ./client.cpp -o ./client.o
g++ ./client.o -o client  -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/lib  -lboost_filesystem-gcc44 -lboost_filesystem-gcc44-mt  -L/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/boost_shared_mem/metricsstore/lib -lmetricsStore -lrt

但是,当我在另一个现有项目中尝试相同的选项时,我会收到以下错误:我无法理解并修复:

    /app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/os_file_functions.hpp: In function 'bool boost::interprocess::ipcdetail::open_or_create_directory(const char*)':
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/os_file_functions.hpp:681: error: expected unqualified-id before 'do'
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/os_file_functions.hpp:682: error: 'info' was not declared in this scope
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/tmp_dir_helpers.hpp: In function 'void boost::interprocess::ipcdetail::create_tmp_and_clean_old(std::string&)':
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/tmp_dir_helpers.hpp:135: error: expected unqualified-id before 'do'
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/tmp_dir_helpers.hpp:136: error: 'info' was not declared in this scope

我已阅读以下链接并尝试了不同的方法,但无济于事:

http://www.drdobbs.com/tools/debugging-makefiles/197003338

新项目的Makefile如下所示:

include .gmake_prologue

INCS += \
       -I$(EXTLIB_ROOT)/one_market_data/one_tick/linux/include \
       -I$(EXTLIB_ROOT)/Linux-glibc-2.3-x86_64/include \
       -I$(EXTLIB_ROOT)/pico \
       -I$(EXTLIB_ROOT)/proto \
       -I$(EXTLIB_ROOT)/google \
       -I$(BOOST_INC) \
       -I$(ETLIB_ROOT)/boost_shared_mem/metricsstore/include \
       $(JMS_INCS)


ETLIBS = \
         $(ETLIB_ROOT)/Util/libUtil.a \
         $(ETLIB_ROOT)/FIXLib/src/libFIXLib.a

LIBS = \
       $(ETLIBS) \
       $(JMS_LIBS_DYNAMIC) \
       -L$(EXTLIB_ROOT)/one_market_data/one_tick/linux/lib -lonetick \
       -L$(EXTLIB_ROOT)/proto/lib -lprotobuf \
       -L$(EXTLIB_ROOT)/poco-1.4.3p1/lib/Linux/x86_64 -lPocoFoundation -lPocoNet \
       -L$(BOOST_LIB) -lboost_filesystem-gcc44 \
       -L$(BOOST_LIB) -lboost_filesystem-gcc44-mt \
       -L$(ETLIB_ROOT)/boost_shared_mem/metricsstore/lib -lmetricsStore \
       -dynamic -lnsl -lm -ldl -lpthread -lrt

OBJS1 = \
       ConfigReader.o \
       proto/common/pricedistribution.pb.o \
       proto/fxecn/fxvenue.pb.o \
       AppBase.o \
       SocketFeedPublisher.o

以上是Makefile的gmake -n输出:

BOOST_ROOT in prolouge=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53 
BOOST_INC in prolouge=/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include 
CCFLAGS in prolouge=-g  -mfpmath=sse -msse3  -I. -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include   
/usr/bin/c++ -pthread -fexceptions -DOS_LINUX -D_GNU_SOURCE -D_THREAD_SAFE -DBYTE_ORDER_LSB  -DINBUILT_NEW -DSFC_REPLACES_TIBAPI -g  -mfpmath=sse -msse3  -I. -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/one_market_data/one_tick/linux/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/Linux-glibc-2.3-x86_64/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/pico -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/proto -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/google -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/boost_shared_mem/metricsstore/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/rdgLib -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/EMS_CPP_WRAPPER/ -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/EMS_CLIENT_API/lincsg2-gcc3.0/4_4_1/EMS_CLIENT_API/ -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/EMS_CPP_WRAPPER//../Source/code -DJMS_IO -DRDG_BUILD -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ATHENA_EMS/LCD -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ATHENA_EMS/e4jms/Linux/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/JMSTools     -c -o SocketFeedPublisher.o SocketFeedPublisher.cpp
/usr/bin/c++ -pthread -fexceptions -DOS_LINUX -D_GNU_SOURCE -D_THREAD_SAFE -DBYTE_ORDER_LSB  -DINBUILT_NEW -DSFC_REPLACES_TIBAPI -g   -g  -mfpmath=sse -msse3  -I. -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/one_market_data/one_tick/linux/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/Linux-glibc-2.3-x86_64/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/pico -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/proto -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/google -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/boost_shared_mem/metricsstore/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/rdgLib -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/EMS_CPP_WRAPPER/ -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/EMS_CLIENT_API/lincsg2-gcc3.0/4_4_1/EMS_CLIENT_API/ -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/EMS_CPP_WRAPPER//../Source/code -DJMS_IO -DRDG_BUILD -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ATHENA_EMS/LCD -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ATHENA_EMS/e4jms/Linux/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/JMSTools   -o  SocketFeedPublisher ConfigReader.o AppBase.o SocketFeedPublisher.o  /app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/Util/libUtil.a /app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/FIXLib/src/libFIXLib.a -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/EMS_CLIENT_API/lincsg2-gcc3.0/4_4_1/lib/64 -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/EMS_CLIENT_API/lincsg2-gcc3.0/4_4_1/lib -ltibems64 -lssl -lcrypto -lz -lxml2 -ltibjms64 -ltibemslookup64 -lldap -llber -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/lib/ -lemscppwrapper64_2.2 -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/one_market_data/one_tick/linux/lib -lonetick -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/proto/lib -lprotobuf -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/poco-1.4.3p1/lib/Linux/x86_64 -lPocoFoundation -lPocoNet -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/lib -lboost_filesystem-gcc44 -L/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/lib -lboost_filesystem-gcc44-mt -L/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/boost_shared_mem/metricsstore/lib -lmetricsStore -dynamic -lnsl -lm -ldl -lpthread -lrt

Linux机器详细信息:

Linux usl20037465 2.6.18-308.8.1.el5#1 SMP Fri May 4 16:43:02 EDT 2012 x86_64 x86_64 x86_64 GNU / Linux

Boost版本使用1.53

我已尽力而为,但无法解决问题,请有人帮助我了解我将如何调试此问题。

修改

抛出错误的块:

/usr/bin/c++ -pthread -fexceptions -DOS_LINUX -D_GNU_SOURCE -D_THREAD_SAFE -DBYTE_ORDER_LSB  -DINBUILT_NEW -DSFC_REPLACES_TIBAPI -g  -mfpmath=sse -msse3  -I. -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/one_market_data/one_tick/linux/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/Linux-glibc-2.3-x86_64/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/pico -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/proto -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/google -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/boost_shared_mem/metricsstore/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/rdgLib -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/EMS_CPP_WRAPPER/ -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/EMS_CLIENT_API/lincsg2-gcc3.0/4_4_1/EMS_CLIENT_API/ -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ems_cpp_wrapper/lincsg2-gcc3.0/2_2_0/EMS_CPP_WRAPPER//../Source/code -DJMS_IO -DRDG_BUILD -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ATHENA_EMS/LCD -I/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/ATHENA_EMS/e4jms/Linux/include -I/app/th/pkgs/omd/rates/development.deb/3.9.7/ETLIB/JMSTools     -c -o SocketFeedPublisher.o SocketFeedPublisher.cpp
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/os_file_functions.hpp: In function 'bool boost::interprocess::ipcdetail::open_or_create_directory(const char*)':
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/os_file_functions.hpp:681: error: expected unqualified-id before 'do'
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/os_file_functions.hpp:682: error: 'info' was not declared in this scope
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/tmp_dir_helpers.hpp: In function 'void boost::interprocess::ipcdetail::create_tmp_and_clean_old(std::string&)':
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/tmp_dir_helpers.hpp:135: error: expected unqualified-id before 'do'
/app/th/pkgs/omd/rates/development.deb/3.9.7/EXTLIB/boost_1_53/include/boost/interprocess/detail/tmp_dir_helpers.hpp:136: error: 'info' was not declared in this scope
gmake: *** [SocketFeedPublisher.o] Error 1

谢谢和问候, -Deb

0 个答案:

没有答案