I am working on a project where I am using boost::interprocess to create shared memory, when I compile the code in isolation and create a client it works fine:
Makefile for building .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 for the test client:
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
The above two work fine and the test client gets built properly.
The gmake -n output of the test client is the following:
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
However, when I try the same options with another existing project I get errors like following which I am not able to understand and fix:
/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
I have read the following link and tried different things but to no avail:
http://www.drdobbs.com/tools/debugging-makefiles/197003338
The Makefile of the new project looks like the following:
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
Here is the gmake -n output of the above Makefile:
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 machine details:
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 version used 1.53
I have tried all that I could, but could not solve the problem can someone please help me understand how would I debug this.
EDIT
Block that throws the error:
/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
Thanks and Regards,
-Deb
Related
I am trying to compile a cuda code that I have received from Github (https://github.com/exafmm/exafmm-alpha).
The Makefile.include contains:
.SUFFIXES: .cxx .cu .f90 .o
.PHONY: docs
CUDA_INSTALL_PATH = /usr/local/cuda
#DEVICE = cpu
DEVICE = gpu
CXX = mpicxx -g -O3 -lstdc++ -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include
NVCC = nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include
FC = mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
FCC = mpif90 -c -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
LFLAGS = -D$(DEVICE) -lstdc++ -ldl -lm
LFLAGS += -lmpi_cxx
LFLAGS += -lpthread
ifeq ($(DEVICE),gpu)
LFLAGS += -lcudart
endif
OBJECT = ../kernel/$(DEVICE)Laplace.o ../kernel/$(DEVICE)BiotSavart.o\
../kernel/$(DEVICE)Stretching.o ../kernel/$(DEVICE)Gaussian.o\
../kernel/$(DEVICE)CoulombVdW.o
.cxx.o:
$(CXX) -c $? -o $# $(LFLAGS)
.cu.o:
$(NVCC) -c $? -o $# $(LFLAGS)
.f90.o:
$(FC) -c $? -o $#
And the Makefile is:
include ../Makefile.include
lib_parallel_ij: parallel_wrapper_ij.o $(OBJECT)
ar -cr libfmm.a parallel_wrapper_ij.o $(OBJECT)
ranlib libfmm.a
test_parallel_ij: test_parallel_ij.o
make lib_parallel_ij
$(FC) $? -L. -lfmm $(LFLAGS)
mpirun -np 2 ./a.out
When I tried to compile the code, I get the following errors.
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include -c test_parallel_ij.f90 -o test_parallel_ij.o
make lib_parallel_ij
make[1]: Entering directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpicxx -g -O3 -lstdc++ -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c parallel_wrapper_ij.cxx -o parallel_wrapper_ij.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuLaplace.cu -o ../kernel/gpuLaplace.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuBiotSavart.cu -o ../kernel/gpuBiotSavart.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
../kernel/gpuBiotSavart.cu(542): warning #177-D: variable "SQRT4PI" was declared but never referenced
../kernel/gpuBiotSavart.cu(548): warning #550-D: variable "r" was set but never used
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuStretching.cu -o ../kernel/gpuStretching.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuGaussian.cu -o ../kernel/gpuGaussian.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuCoulombVdW.cu -o ../kernel/gpuCoulombVdW.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
ar -cr libfmm.a parallel_wrapper_ij.o ../kernel/gpuLaplace.o ../kernel/gpuBiotSavart.o ../kernel/gpuStretching.o ../kernel/gpuGaussian.o ../kernel/gpuCoulombVdW.o
ranlib libfmm.a
make[1]: Leaving directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include test_parallel_ij.o -L. -lfmm -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
./libfmm.a(gpuLaplace.o): In function `LaplaceL2P_GPU(int*, int*, double*, double*)':
tmpxft_0000397c_00000000-6_gpuLaplace.cudafe1.cpp:(.text+0xc2): undefined reference to `__cudaPopCallConfiguration'
....
./libfmm.a(gpuLaplace.o): In function `Kernel::LaplaceL2P()':
tmpxft_0000397c_00000000-6_gpuLaplace.cudafe1.cpp:(.text+0x3e06): undefined reference to `__cudaPushCallConfiguration'
....
./libfmm.a(gpuCoulombVdW.o): In function `__sti____cudaRegisterAll()':
tmpxft_00003a87_00000000-6_gpuCoulombVdW.cudafe1.cpp:(.text.startup+0x189): undefined reference to `__cudaRegisterFatBinaryEnd'
....
I tried to find the installation of cuda:
whereis cuda
cuda: /usr/lib/cuda /usr/include/cuda.h /usr/local/cuda
I could not fix the error, can anyone give any hint to fix it?
Thank you.
I am trying yo build a Makefile for a project that uses the soplex library (which also depends on libz and libgmp).
So I have this little Makefile:
SOPLEXPATH =../../lib/soplex-3.0.0/lib/
SOPLEXINCLUDE =../../lib/soplex-3.0.0/src/
SOPLEXDEP =../../lib/soplex-3.0.0/src/
CC = g++
CPPFLAGS = -g -std=c++0x -O3 -I $(SOPLEXINCLUDE)
#CPPFLAGS += -DNDEBUG
CPPFLAGS += -pg -ggdb
CPPFLAGS += -Wall -Werror=return-type
LIBS = -L $(SOPLEXPATH) -lz -lgmp -lsoplex
SRCS = $(wildcard ./src/core/*.cpp)
OBJS = $(addsuffix .o, $(basename $(SRCS)))
DEPS = $(addsuffix .d, $(basename $(SRCS)))
all : kea
kea : $(OBJS)
$(CC) $(CPPFLAGS) $(LIBS) -o bin/kea-core $(OBJS)
clean :
rm -f bin/kea-core $(OBJS) $(DEPS) *~
-include $(DEPS)
%.d: %.c
#$(CC) -MM -MT $(subst .d,.o,$#) -MT $# $(CPPFLAGS) $< > $#
And all seems to compile to object files (.o) correctly, but then the linker complains about not finding the function soplex::SoPlex::SoPlex() (the constructor of SoPlex):
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -c -o src/core/ecircuit.o src/core/ecircuit.cpp
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -c -o src/core/solver_soplex.o src/core/solver_soplex.cpp
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -c -o src/core/main.o src/core/main.cpp
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -L ../../lib/soplex-3.0.0/lib/ -lz -lgmp -lsoplex -o bin/kea-core ./src/core/ecircuit.o ./src/core/solver_soplex.o ./src/core/main.o
./src/core/solver_soplex.o: In function `SolvSoplex::SolvSoplex(ECircuit&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >&, SolvSoplex::Mode)':
/home/diego/Projects/kea-landscape-tool/src/core/solver_soplex.cpp:9: undefined reference to `soplex::SoPlex::SoPlex()'
/home/diego/Projects/kea-landscape-tool/src/core/solver_soplex.cpp:9: undefined reference to `soplex::SoPlex::~SoPlex()'
collect2: error: ld returned 1 exit status
Makefile:20: recipe for target 'kea' failed
make: *** [kea] Error 1
Since all the .o files are created I tried to compile by hand doing:
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -Wall -Werror=return-type -pg -ggdb -L/home/diego/Projects/kea-landscape-tool/../../lib/soplex-3.0.0/lib/ -lsoplex -lz -lgmp -o bin/kea-core src/core/main.o src/core/ecircuit.o src/core/solver_soplex.o
And it failed with the same error.
then I tried switching the position of the -L and -l.. flags like this, and it compiled: g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -Wall -Werror=return-type -pg -ggdb -o bin/kea-core src/core/main.o src/core/ecircuit.o src/core/solver_soplex.o -L/home/diego/Projects/kea-landscape-tool/../../lib/soplex-3.0.0/lib/ -lsoplex -lz -lgmp
Seeing that, I tried to change the rule in the Makefile as follows:
kea : $(OBJS)
$(CC) $(CPPFLAGS) -o bin/kea-core $(OBJS) $(LIBS)
But it just failed miserably triggering about 100 errors all inside soplex.cpp (as in, it depends on -lgmp and -lz, but it could not find them? Too long to paste here)
I am pretty confused, any idea on how to fix this?
thanks.
Try putting the $LIBS at the end of the command.
Change this:
LIBS = -L $(SOPLEXPATH) -lz -lgmp -lsoplex
Into this:
LIBS = -L $(SOPLEXPATH) -lsoplex -lgmp -lz
You always need to put B after A, if A calls functions in B. With static libraries as least.
The main makefile is this, as you can see it calls to two other makefiles in the subdirs: comm and bc.
I know that I don't use makefile shortcuts like treating all cpp files at once but please don't pay attention to that right now.
In comm/makefile there is a rule to make comm/build/Communication.o but somehow I don't know how to tell that fact to the main makefile.
CPPFLAGS=-g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc
LDFLAGS=-g -L/usr/lib/x86_64-linux-gnu/ -lQt5Core -lboost_system -lpthread -lboost_thread
all: comm/bin/party bc/bin/bctest bin/protocol
comm/bin/party:
cd comm && $(MAKE)
bc/bin/bctest:
cd bc && $(MAKE)
bin/protocol:build/main.o \
build/TrustedParty.o \
build/Player.o \
build/utils.o \
comm/build/Communication.o \
comm/build/FileParser.o \
comm/build/Party.o \
comm/build/PeerConnection.o \
comm/build/ServerModule.o \
comm/build/Utilities.o \
bc/build/BooleanCircuit.o \
bc/build/Gate.o \
bc/build/Wire.o
g++ -Wall $^ -o bin/protocol $(LDFLAGS)
build/main.o:src/main.cpp
g++ $(CPPFLAGS) -fPIC src/main.cpp -o build/main.o
build/TrustedParty.o:src/TrustedParty.cpp
g++ $(CPPFLAGS) src/TrustedParty.cpp -o build/TrustedParty.o
build/Player.o:src/Player.cpp
g++ $(CPPFLAGS) src/Player.cpp -o build/Player.o
build/utils.o:src/utils.cpp
g++ $(CPPFLAGS) src/utils.cpp -o build/utils.o
clean:
rm -fr build/* bin/*
rm -fr comm/build/* bin/*
rm -fr bc/build/* bin/*
When I run make it returns
16:15:03 **** Build of configuration Default for project bmr ****
make all
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc -fPIC src/main.cpp -o build/main.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/TrustedParty.cpp -o build/TrustedParty.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/Player.cpp -o build/Player.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/utils.cpp -o build/utils.o
make: *** No rule to make target `comm/build/Communication.o', needed by `bin/protocol'. Stop.
16:15:11 Build Finished (took 7s.821ms)
Assuming the comm/Makefile knows how to build that target correctly (make build/Communication.o in the comm directory works); then if you really want to get this to work correctly (and you might not want to, see Recursive Make Considered Harmful for why) you need to tell the toplevel make what to do in this situation.
Something like this:
comm/build/%.o:
#$(MAKE) -C comm $(patsubst comm/%,%,$#)
I have been provided the following Makefile to compile my project. It seems to be written in pretty old-fashioned style, and although I am reading the official GNU Make manual I am not able to fix it. The project itself seems to correctly compile all the .o files, as it creates all of them in my working directory: main.o model.o param.o
# //////////////// NOMBRE DEL PROYECTO ///////////////////
#
P=project
#
EXE=$(P)
OBJS=main.o model.o param.o head.h
ADDLIBS=-D.
ADDINCFLAGS=-I.
SRCDIR=/root/projects/project
##########
CXX=g++
CXXFLAGS=-O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -I$(COININCDIR)
CXXLINKFLAGS=-Wl,--rpath -Wl,/installed/CoinAll/lib
CC=gcc
CFLAGS=-03 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall
COININCDIR=/installed/CoinAll/include/coin
COINLIBDIR=/installed/CoinAll/lib
LIBS=-L$(COINLIBDIR) -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm \
`cat $(COINLIBDIR)/cgl_addlibs.txt` \
`cat $(COINLIBDIR)/clp_addlibs.txt` \
`cat $(COINLIBDIR)/coinutils_addlibs.txt`
# LIBS=-L$(COINLIBDIR) -lClp -lCoinUtils \
# -lm `cat $(COINLIBDIR)/coinutils_addlibs.txt`
INCL=-I`$(COININCDIR)`$(ADDINCFLAGS)
all: $(EXE)
.SUFFIXES: .cpp .c .o .obj
$(EXE): $(OBJS)
bla=;
for file in $(OBJS); do bla="$$bla ` $$file`"; done; \
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $# $$bla $(ADDLIBS) $(LIBS)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.cpp.obj:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `if test -f '$<'; then '$<'; else '$(SRCDIR)/$<'; fi`
.c.o:
$(CC) $(CFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.c.obj:
$(CC) $(CFLAGS) $(INCL) -c -o $# `if test -f '$<'; then '$<'; else '$(SRCDIR)/$<'; fi`
This is the error message I am getting, although, as I said, the .o files are created in the directory, but it doesn't seem to find them to link them into my executable.
/bin/sh: 1: main.o: not found
/bin/sh: 1: model.o: not found
/bin/sh: 1: param.o: not found
/bin/sh: 1: head.h: not found
collect2: error: ld returned 1 exit status
make: *** [project] Error 1
Note: this is the complete output I get:
g++ -O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -I/installed/CoinAll/include/coin -I`/installed/CoinAll/include/coin`-I. -c -o main.o `test -f 'main.cpp' || echo '/root/projects/project'`main.cpp
/bin/sh: 1: /installed/CoinAll/include/coin: Permission denied
main-farmer.cpp: In function ‘int main()’:
main-farmer.cpp:19:17: warning: variable ‘tiempo0’ set but not used [-Wunused-but-set-variable]
g++ -O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -I/installed/CoinAll/include/coin -I`/installed/CoinAll/include/coin`-I. -c -o model.o `test -f 'model.cpp' || echo '/root/projects/project/'`model.cpp
/bin/sh: 1: /installed/CoinAll/include/coin: Permission denied
g++ -O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -I/installed/CoinAll/include/coin -I`/installed/CoinAll/include/coin`-I. -c -o param.o `test -f 'param.cpp' || echo '/root//projects/project/'`param.cpp
/bin/sh: 1: /installed/CoinAll/include/coin: Permission denied
bla=;
for file in main.o model.o param.o head.h; do bla="$bla ` $file`"; done; \
g++ -Wl,--rpath -Wl,/installed/CoinAll/lib -O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -I/installed/CoinAll/include/coin -o farmer $bla -D. -L/installed/CoinAll/lib -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm `cat /installed/CoinAll/lib/cgl_addlibs.txt` `cat /installed/CoinAll/lib/clp_addlibs.txt` `cat /installed/CoinAll/lib/coinutils_addlibs.txt`
/bin/sh: 1: main.o: not found
/bin/sh: 1: model.o: not found
/bin/sh: 1: param.o: not found
/bin/sh: 1: head.h: not found
collect2: error: ld returned 1 exit status
make: *** [project] Error 1
In the for loop the following bit is incorrect.
` $$file`
It is incorrect since the .o files are not executables to be run for their output.
This makefile is quite terrible, you were correct about that.
Similar to the above issue.
This line is incorrect unless $(COININCDIR) is a command to run.
INCL=-I\`$(COININCDIR)\`$(ADDINCFLAGS)
This mistake is the cause of the /bin/sh: 1: /installed/CoinAll/include/coin: Permission denied errors.
Additionally, unless $(ADDINCFLAGS) is intended to be attached to the value of $(COININCDIR) (which it almost certainly isn't) a space is needed between the two variables.
I have a project that is a library that links against libresolv,
It works fine on recent distros: Ubuntu 10.x Fedora 13, Mandriva
2010.1 but on Centos 5.x I get the following errors
glibc installed is: glibc-2.5-18.el5_1.1
g++ -DHAVE_CONFIG_H -I. -I./include -I/usr/include/postgresql -O3
-ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0 -MT testUpLog.o -MD
-MP -MF .deps/testUpLog.Tpo -c -o testUpLog.o testUpLog.cc
mv -f .deps/testUpLog.Tpo .deps/testUpLog.Po
/bin/sh ./libtool --tag=CXX --mode=link g++ -O3 -ansi -Wall
-Wno-deprecated -D_FORTIFY_SOURCE=0 -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql -o testUpLog testUpLog.o libUpTools.la -lpq
-lmysqlclient -lssl -lpthread
libtool: link: g++ -O3 -ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0
-o .libs/testUpLog testUpLog.o -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql ./.libs/libUpTools.so -lpq -lmysqlclient -lssl
-lpthread
./.libs/libUpTools.so: undefined reference to `__ns_name_uncompress'
./.libs/libUpTools.so: undefined reference to `__ns_initparse'
./.libs/libUpTools.so: undefined reference to `__ns_parserr'
collect2: ld returned 1 exit status
make[1]: *** [testUpLog] Error 1
make[1]: Leaving directory `/tmp/UpTools-8.5.3'
make: *** [check-am] Error 2
library.la file contains:
dlname='libUpTools.so.0'
library_names='libUpTools.so.0.0.0 libUpTools.so.0 libUpTools.so'
old_library='libUpTools.a'
inherited_linker_flags=''
dependency_libs=' -L/usr/lib64 -L/lib64 -L/usr/lib64/mysql -lpq
-lmysqlclient -lssl -lpthread'
weak_library_names=''
current=0
age=0
revision=0
installed=no
shouldnotlink=no
dlopen=''
dlpreopen=''
libdir='/usr/lib'
You can read configure.ac on
http://pastebin.com/hs5q21Rq
Thanks in advance
If libUpTools uses functions lib libresolv, you need to say so:
libUpTools_la_LIBADD = -lresolv (of course -lresolv may be replaced by variables determined by configure etc.)
That way, -lresolv will end up in the .la file and also in the .so file (if you chose to build it) that you can run ldd on for verification.