I'm using a developement board that has its own libraries. I have installed ROS on it and now I need to use publish/subscribe by including its libraries to the CMakeLists.txt of the package. I have to also note that I use Eclipse for compilation, so the CMakeLists.txt is in that form. Here is the Makefile of hardware library that I want to use in CMakeLists.txt:
DIR=$(shell pwd)/../
INCS = -I.\
-I$(DIR) \
-I$(DIR)/hardware \
-I$(DIR)/hardware/environment \
-I$(DIR)/hardware/environment/cores \
-I$(DIR)/hardware/environment/cores/environment \
-I$(DIR)/hardware/environment/variants \
-I$(DIR)/hardware/environment/variants/sunxi \
-I$(DIR)/libraries \
-I$(DIR)/libraries/Serial \
-I$(DIR)/libraries/SPI \
-I$(DIR)/libraries/Wire \
-I$(DIR)/libraries/LiquidCrystal \
-I$(DIR)/Basibos/include LIBS=../libenvironment.a TARGET=../output/test
OBJS = BasibosAnaProgram
all:
#mkdir -p $(TARGET)
for i in $(OBJS); do echo "$(CXX) $(INCS) $$i.cpp -o $(TARGET)/$$i $(LIBS)"; done
#for i in $(OBJS); do $(CXX) $(INCS) $$i.cpp -o $(TARGET)/$$i $(LIBS); done
clean:
#for i in $(OBJS); do rm -f $(TARGET)/$$i; done
And here is the example CMakeLists.txt that Makefile should be included:
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_library(${PROJECT_NAME} src/Basibos.cpp)
rosbuild_add_library(${PROJECT_NAME} src/HedefeGitme.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Konum.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Robot.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Sonar.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Zaman.cpp)
rosbuild_add_library(${PROJECT_NAME} src/XMLAyiklayici.cpp)
rosbuild_add_executable(srctest RobotKontrol.cpp)
target_link_libraries(srctest ${PROJECT_NAME})
I'm stuck and can't go forward without help. Any help will be greately appreciated. Thanks in advance
Source: http://www.ros.org/wiki/rosbuild/CMakeLists
You have to add the source files in following fashion:
rosbuild_add_library(XmlRpc src/XmlRpcClient.cpp
src/XmlRpcDispatch.cpp
src/XmlRpcServer.cpp
src/XmlRpcServerConnection.cpp
src/XmlRpcServerMethod.cpp
src/XmlRpcSocket.cpp
src/XmlRpcSource.cpp
src/XmlRpcUtil.cpp
src/XmlRpcValue.cpp)
Related
I am trying to create a makefile using the help of this thread, I changed the code provided a little bit since I have many *.c files that need to be compiled.
this the project hierarchy:
/coap
Makefile
/src
/src
/coap
/imc
*.h files
/src
*.c files
/system
/imc
client.h
/src
client.c
**makefile**
/files
sdk.sh
I made the first makefile and it seems to work fine, but my problem is with the second one written in bold.
Here, I provide the changes that I made:
program_NAME := coap
program_C_SRCS += \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/address.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/async.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/block.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_asn1.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_cache.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_debug.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_event.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_gnutls.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_hashkey.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_io.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_mbedtls.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_notls.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_openssl.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_prng.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_session.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_tcp.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_time.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/coap_tinydtls.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/encode.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/mem.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/net.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/option.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/pdu.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/resource.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/str.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/subscribe.c \
/home/iat2/Projects/XXXX/package/coap/src/src/coap/src/uri.c
program_C_OBJS := ${program_C_SRCS:.c=.o}
program_OBJS := $(program_C_OBJS)
program_INCLUDE_DIRS :=/home/iat2/Projects/XXXX/package/coap/src/src/coap/imc
program_LIBRARY_DIRS :=
program_LIBRARIES := router
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
.PHONY: all clean distclean
all: $(program_NAME)
$(program_NAME): $(program_OBJS)
$(LINK.cc) $(program_OBJS) -o $(program_NAME)
clean:
#- $(RM) $(program_NAME)
#- $(RM) $(program_OBJS)
distclean: clean
When I try to compile, the log file output is:
fatal error: sys/random.h: No such file or directory
#include <sys/random.h>
and it can't recognize some of the openssl functions written in the coap_openssl.c file.
When I use the Makefile in the examples folder of Pythia8185 I get an error (ME below!):
ME: This is mymain.cc
#include "Pythia8/Pythia.h" // Include Pythia headers.
using namespace Pythia8; // Let Pythia8:: be implicit.
int main() { // Begin main program.
// Set up generation.
Pythia pythia; // Declare Pythia object
pythia.readString("Top:gg2ttbar = on"); // Switch on process.
pythia.readString("Beams:eCM = 7000."); // 7 TeV CM energy.
pythia.init(); // Initialize; incoming pp beams is default.
// Generate event(s).
pythia.next(); // Generate an(other) event. Fill event record.
return 0;
} // End main program with error-free return.
This is the Makefile before edit:
#
# Examples Makefile.
#
# M. Kirsanov 07.04.2006
# Modified 18.11.2006
# 26.03.2008 CLHEP dependency removed
SHELL = /bin/sh
-include config.mk
ifeq (x$(PYTHIA8LOCATION),x)
PYTHIA8LOCATION=..
endif
-include $(PYTHIA8LOCATION)/config.mk
# Location of directories.
TOPDIR=$(shell \pwd)
INCDIR=include
SRCDIR=src
LIBDIR=lib
LIBDIRARCH=lib/archive
BINDIR=bin
# Libraries to include if GZIP support is enabled
ifeq (x$(ENABLEGZIP),xyes)
LIBGZIP=-L$(BOOSTLIBLOCATION) -lboost_iostreams -L$(ZLIBLOCATION) -lz
endif
# There is no default behaviour, so remind user.
all:
#echo "Usage: for NN = example number: make mainNN"
# Create an executable for one of the normal test programs
main00 main01 main02 main03 main04 main05 main06 main07 main08 main09 main10 \
main11 main12 main13 main14 main15 main16 main17 main18 main19 main20 \
main21 main22 main23 main24 main25 main26 main27 main28 main29 main30 \
main31 main32 main33 main34 main35 main36 main37 main38 main39 main40 \
main80: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -llhapdfdummy $(LIBGZIP)
#ln -fs $(BINDIR)/$#.exe $#.exe
# Create an executable linked to HepMC (if all goes well).
# Owing to excessive warning output -Wshadow is not used for HepMC.
ifneq (x$(HEPMCLOCATION),x)
main41 main42: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8tohepmc.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -Wno-shadow -I$(PYTHIA8LOCATION)/$(INCDIR) -I$(HEPMCLOCATION)/include \
$#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -llhapdfdummy $(LIBGZIP) \
-lpythia8tohepmc \
-L$(HEPMCLOCATION)/lib -lHepMC
#ln -fs $(BINDIR)/$#.exe $#.exe
else
main41 main42:
#echo ERROR, this target needs HepMC, variable HEPMCLOCATION
endif
# Create an executable that links to LHAPDF
main51 main52 main53 main54: $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 $(LIBGZIP) \
-L$(LHAPDFLOCATION) $(LHAPDFLIBNAME) \
$(FLIBS)
#ln -fs $(BINDIR)/$#.exe $#.exe
# Create an executable that links to LHAPDF and HepMC
main61 main62 main85 main86 main87 main88: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8tohepmc.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -Wno-shadow -I$(PYTHIA8LOCATION)/$(INCDIR) -I$(HEPMCLOCATION)/include \
$#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -lpythia8tohepmc $(LIBGZIP) \
-L$(LHAPDFLOCATION) $(LHAPDFLIBNAME) \
-L$(HEPMCLOCATION)/lib -lHepMC \
$(FLIBS)
#ln -fs $(BINDIR)/$#.exe $#.exe
# Create an executable that links to Fastjet
# Owing to excessive warning output -Wshadow is not used for Fastjet.
# (Fixed as of Fastjet 3.0.1, so will be modified eventually.)
ifneq (x$(FASTJETLOCATION),x)
main71 main72: $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a
#mkdir -p $(BINDIR)
# Note: $(CXXFLAGS) is after Fastjet flags as Fastjet includes
# optimisation/debug flags which may be unwanted (e.g. -g -O2)
$(CXX) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc \
`$(FASTJETLOCATION)/bin/fastjet-config --cxxflags --plugins` \
$(CXXFLAGS) -Wno-shadow \
-o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -llhapdfdummy $(LIBGZIP) \
-L$(FASTJETLOCATION)/lib \
`$(FASTJETLOCATION)/bin/fastjet-config --libs --plugins`
#ln -fs $(BINDIR)/$#.exe $#.exe
#rm -f $#.o
else
main71 main72:
#echo ERROR, this target needs Fastjet, variable FASTJETLOCATION
endif
# Create an executable that links to Fastjet, HepMC and LHApdf
# Owing to excessive warning output -Wshadow is not used for Fastjet.
# (Fixed as of Fastjet 3.0.1, so will be modified eventually.)
ifneq (x$(FASTJETLOCATION),x)
main81 main82 main83 main84: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8tohepmc.a
#mkdir -p $(BINDIR)
# Note: $(CXXFLAGS) is after Fastjet flags as Fastjet includes
# optimisation/debug flags which may be unwanted (e.g. -g -O2)
$(CXX) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc \
`$(FASTJETLOCATION)/bin/fastjet-config --cxxflags --plugins` \
$(CXXFLAGS) -Wno-shadow \
-I$(PYTHIA8LOCATION)/$(INCDIR) -I$(HEPMCLOCATION)/include \
-o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 \
-L$(LHAPDFLOCATION) $(LHAPDFLIBNAME) \
-lpythia8tohepmc \
-L$(HEPMCLOCATION)/lib -lHepMC \
-L$(FASTJETLOCATION)/lib \
-L$(LHAPDFLOCATION)/lib \
`$(FASTJETLOCATION)/bin/fastjet-config --libs --plugins`
#ln -fs $(BINDIR)/$#.exe $#.exe
#rm -f $#.o
else
main81 main82 main83 main84:
#echo ERROR, this target needs Fastjet, variable FASTJETLOCATION
endif
# Clean up: remove executables and outdated files.
.PHONY: clean
clean:
rm -rf $(BINDIR)
rm -rf *.exe
rm -f *~; rm -f \#*; rm -f core*
After edit I add mymain: just after main80 and then I write make mymain and get the error as follows:
I edit the Makefile and add mymain to the list:
# Create an executable for one of the normal test programs
main00 main01 main02 main03 main04 main05 main06 main07 main08 main09 main10 \
main11 main12 main13 main14 main15 main16 main17 main18 main19 main20 \
main21 main22 main23 main24 main25 main26 main27 main28 main29 main30 \
main31 main32 main33 main34 main35 main36 main37 main38 main39 main40 \
main80 mymain: \
as suggested in the worksheet example page 4.
Then when I write make mymain in the Terminal I get the following error:
*** No rule to make target `../lib/archive/libpythia8.a', needed by `mymain'. Stop.
It should be noted that everything worked fine yesterday, I really don't know how to proceed. I deleted all pythia folders and untarred them again but the problem remains. Anyone know what the solution might be? I'm on a MacBook.
Is there a way to uninstall something like pythia completely and reinstall it? It seems some file in some cache is the problem
I am in the process of converting out previous build system (Makefiles) to CMake. I am trying to specify the Linker and Linker Flags for CMake and am not sure if I am using the correct syntax/variables. I have included my original Makefile (which compiles and genreates the executable) but when attempting to do the smae with CMake I am getting errors.
Here is the error:
Linking CXX executable discoveryService
/home/projects/OMAP- L137/timesys/SDK/omapl137_evm/toolchain/bin/../../toolchain/lib/crt1.o: In function `_start':
(.text+0x34): undefined reference to `main'
collect2: ld returned 1 exit status
make[2]: *** [arm/communications/discoveryService] Error 1
make[1]: *** [arm/communications/CMakeFiles/discoveryService.dir/all] Error 2
make: *** [all] Error 2
The original Makefile used three flags -lpthread -lc & -o If I am understanding correctly the -o just means to name the executable a specific name so with CMake *ADD_EXECUTABLE* I shouldn't need that since we specify the name of the executable there. I have included my 2 CMakeLists and the original Makefile for reference and any help is greatly appreciated since this has stumped me for the second day now..
Top Level CMakeList
INCLUDE(CMakeForceCompiler)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(633)
#this one is important
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
SET(FACTORY_CURRENT /home/projects/OMAP-L137/timesys/factory-current)
SET(DSPLINK_PATH ${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink- 1_65_01/DSPLink-1_65_01)
SET(DSPLINK_PACKAGE_DIR ${FACTORY_CURRENT}/${DSPLINK_PATH})
SET(TOOLCHAIN_LOC ${FACTORY_CURRENT}/build_armv5l-timesys-linux- uclibcgnueabi/toolchain/bin)
#read file into variable 'defines'
file(READ ${CMAKE_SOURCE_DIR}/arm/dsplink_config/dsplink_defines.txt defines)
#turn space separation into CMake list
string(REPLACE " " ";" defines "${defines}")
ADD_DEFINITIONS(${defines})
# specify the cross compiler
SET(CMAKE_C_COMPILER ${TOOLCHAIN_LOC}/armv5l-timesys-linux-uclibcgnueabi-g++ "-lpthread -lc")
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_LOC}/armv5l-timesys-linux-uclibcgnueabi-g++ "lpthread -lc")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -c ")
SET(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
#specify the linker
SET(CMAKE_C_LINK_EXECUTABLE "/OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin/armv5l- timesys-linux-uclibcgnueabi-g++ -lpthread -lc")
SET(CMAKE_CXX_LINK_EXECUTABLE "/OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin/armv5l-timesys-linux-uclibcgnueabi-g++ -lpthread -lc")
SET(CMAKE_LINKER "/OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin/armv5l-timesys-linux-uclibcgnueabi-g++ -lpthread -lc")
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /home/projects/OMAP-L137/timesys/factory-current)
SET(PROJECT_SOURCE_DIR /home/chrisk/633/)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/bin)
SET(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
ADD_SUBDIRECTORY(arm)
Second Level CMakeList:
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/arm/framework ${CMAKE_SOURCE_DIR}/arm/flagDictionary
${CMAKE_SOURCE_DIR}/arm/logging ${CMAKE_SOURCE_DIR}/dsp/include ${CMAKE_SOURCE_DIR}/arm/modbus ${CMAKE_SOURCE_DIR}/arm/expat)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux- uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(/home/projects/OMAP-L137/timesys/factory-20120925-633/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(/home/projects/OMAP-L137/timesys/factory-20120925-633/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/sys/Linux)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/sys/Linux)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/sys/Linux/2.6.18)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/src/samples/loop)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/src/samples/loop/Linux)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/src/samples/loop/Linux/2.6.18)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/BUILD/INCLUDE/USER)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink- 1_65_01/dsplink/gpp/export/INCLUDE/Linux/OMAPL1XX/internal)
INCLUDE_DIRECTORIES(${FACTORY_DIR}/build_armv5l-timesys-linux-uclibcgnueabi/toolchain/include)
SET(communications_SOURCES
discoveryService.cpp
httpService.cpp
modbusRTUService.cpp
modbusService.cpp
streamingService.cpp
trendMap.cpp
trendService.cpp
tripBuffer.cpp
tripReader.cpp
)
ADD_LIBRARY(communications ${communications_SOURCES})
SET(SET_TARGET_PROPERTIES(libcommunications.a PROPERTIES LINK_FLAGS "-lpthread -lc" ))
SET(SET_TARGET_PROPERTIES(libcommunications.a PROPERTIES LINKER_LANGUAGE CXX))
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/arm/flagDictionary ${CMAKE_SOURCE_DIR}/arm/framework ${CMAKE_SOURCE_DIR}/arm/communications
${DSPLINK_PACKAGE_DIR}/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/ "-lpthread -lc")
ADD_EXECUTABLE(discoveryService discoveryService.cpp)
TARGET_LINK_LIBRARIES(discoveryService flagDictionary framework communications dsplink.lib)
Original Makefile:
$(shell ../../build_environment.sh)
BIN = ../../build/bin
TMP = build
BUILD_DEF = -DBUILD=$(BUILD_VERSION) -DBUILD_DATE=$(BUILD_DATE)
# these files are captured from the DSPLink Sample build directory (and the named changed)
# they contain the appropriate includes and flags to build a dsplink application.
DSPLINK_INCLUDES = $(shell cat ../dsplink_config/dsplink_includes.txt)
DSPLINK_FLAGS = $(shell cat ../dsplink_config/dsplink_flags.txt)
DSPLINK_DEFINES = $(shell cat ../dsplink_config/dsplink_defines.txt)
DSPLINK_LIBS = $(DSPLINK_PACKAGE_DIR)/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/dsplink.lib
#Our project variables
INCLUDE= -I. -I../framework -I../flagDictionary -I../logging -I../../dsp/include - I../modbus -I../expat
TOOLCHAIN = /OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin
#TOOLCHAIN = ${FACTORY_DIR}/build_armv5l-timesys-linux-uclibcgnueabi/toolchain/bin
PLATFORM=armv5l-timesys-linux-uclibcgnueabi
#Compile Options
CC=$(TOOLCHAIN)/$(PLATFORM)-g++
LINKER=$(TOOLCHAIN)/$(PLATFORM)-g++
CFLAGS+=$(BUILD_DEF) $(INCLUDE)
DEBUG =
#list of things to compile.
FW_BUILD_DIR=../framework/build
LOG_BUILD_DIR=../logging/build
XML_BUILD_DIR=../expat/build
MODBUS_BUILD_DIR=../modbus/build
FLAG_DICT_BUILD_DIR=../flagDictionary/build
CORE_FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/application.o \
$(FW_BUILD_DIR)/arguments.o \
$(FW_BUILD_DIR)/com.o \
$(FW_BUILD_DIR)/memoryManagerBase.o \
$(FW_BUILD_DIR)/memoryManager.o \
$(FW_BUILD_DIR)/lockManager.o \
$(FW_BUILD_DIR)/stopWatch.o \
$(FW_BUILD_DIR)/controlCom.o \
$(FW_BUILD_DIR)/status.o \
$(FW_BUILD_DIR)/paths.o \
$(LOG_BUILD_DIR)/subsystemLogMasks.o \
$(LOG_BUILD_DIR)/logger.o
# removed utils.o from CORE
NET_FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/message.o \
$(FW_BUILD_DIR)/chunk.o \
$(FW_BUILD_DIR)/multicastSocket.o \
$(FW_BUILD_DIR)/serverSocket.o \
$(FW_BUILD_DIR)/socket.o \
$(FW_BUILD_DIR)/tcpReader.o
CONF_FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/configuration.o \
$(FW_BUILD_DIR)/editConfig.o \
$(FW_BUILD_DIR)/parseConfig.o \
$(FW_BUILD_DIR)/xpath.o \
$(XML_BUILD_DIR)/xmlparse.o \
$(XML_BUILD_DIR)/xmlrole.o \
$(XML_BUILD_DIR)/xmltok.o
MODBUS_OBJECTS= $(MODBUS_BUILD_DIR)/modbus.o \
$(MODBUS_BUILD_DIR)/modbusFacade.o
MODBUS_RTU_OBJECTS= $(MODBUS_BUILD_DIR)/modbus.o \
$(MODBUS_BUILD_DIR)/rtuFacade.o
FLAG_DICT_OBJECTS= $(FLAG_DICT_BUILD_DIR)/flagEntry.o \
$(FLAG_DICT_BUILD_DIR)/flagDictionary.o
OBJECTS = discoveryService.o \
httpService.o \
modbusService.o \
streamingService.o \
trendMap.o \
trendService.o \
tripBuffer.o \
modbusRTUService.o \
tripReader.o
EXES = discoveryService httpService modbusService streamingService trendService tripReader modbusRTUService cmprXfr
all: $(OBJECTS) $(EXES)
.c.o:
mkdir -p build
$(CC) -c $(CFLAGS) $(DSPLINK_INCLUDES) $(DSPLINK_FLAGS) $(DSPLINK_DEFINES) $(DEBUG) -o $(TMP)/$# $<
.cpp.o:e
mkdir -p build
$(CC) -c $(CFLAGS) $(DSPLINK_INCLUDES) $(DSPLINK_FLAGS) $(DSPLINK_DEFINES) $(DEBUG) -o $(TMP)/$# $<
discoveryService: $(FRAMEWORK_OBJECTS) discoveryService.o
$(LINKER) -lpthread -lc -o $(BIN)/$# $(DSPLINK_LIBS) build/discoveryService.o $(FLAG_DICT_OBJECTS) $(CORE_FRAMEWORK_OBJECTS) $(NET_FRAMEWORK_OBJECTS) $(CONF_FRAMEWORK_OBJECTS)
Again, any and all help/suggestions will be greatly appreciated!
I have the following 3 makefiles which have been generated by some other programmer. I have included my code in between which I have marked with a begin and end. The code intends to include the libspatial index library. The other programmer has the hierarchy root directory---->tools--->r
MakeFile1 corresponds to r, MakeFile2 corresponds to tools and MakeFile3 corresponds to root
Now when I include the library I get the error that
make all
make: *** No rule to make target `bin//home/NP/rtree/spatialindex-src-1.8.0/src/storagemanager/DiskStorageManager.cc', needed by `bin/rdf3xload'. Stop.
I am unable to understand as to what mistake did I make. Can someone be kind enough to help me out.
MakeFile 1
src_tools_r:= \
tools/r/r.cpp \
tools/r/Sorter.cpp \
tools/r/StringLookup.cpp \
tools/r/TempFile.cpp \
/home/NP/rtree/spatialindex-src-1.8.0/src/storagemanager/DiskStorageManager.cc
#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR = /usr/local/lib
CPPFLAGS = -I. \
-I$(COURSE_DIR)
LDFLAGS = -L. \
-L$(COURSE_DIR) \
-R $(LIB_DIR):$(COURSE_DIR)
LDLIBS = -lspatialindex
#Code which I wrote in order to include my library --end
$(PREFIX)r$(EXEEXT): $(addprefix $(PREFIX),$(src_tools_r:.cpp=$(OBJEXT)) $(src_infra:.cpp=$(OBJEXT)) $(src_rts:.cpp=$(OBJEXT)) $(src_cts:.cpp=$(OBJEXT)))
$(buildexe)
MakeFile2
include tools/r/MakeFile1
src_tools:= \
$(src_tools_r) \
#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR = /usr/local/lib
CPPFLAGS = -I. \
-I$(COURSE_DIR)
LDFLAGS = -L. \
-L$(COURSE_DIR) \
-R $(LIB_DIR):$(COURSE_DIR)
LDLIBS = -lspatialindex
#Code which I wrote in order to include my library --end
**MakeFile3
# Include platform dependent makefiles
ifeq ($(OS),Windows_NT)
include Makefile.nt
else
include Makefile.unix
endif
PREFIX:=bin/
#############################################################################
# Default target
all: $(PREFIX)rd$(EXEEXT) $(PREFIX)r$(EXEEXT) $(PREFIX)rq$(EXEEXT) $(PREFIX)ru$(EXEEXT) $(PREFIX)re$(EXEEXT) $(PREFIX)ro$(EXEEXT)
#############################################################################
# Collect all sources
ifeq ($(LINEEDITOR),1)
src_lineeditor:=lineeditor/LineInput.cpp lineeditor/LineEditor.cpp lineeditor/Terminal.cpp lineeditor/Display.cpp lineeditor/Buffer.cpp
endif
include tools/Make2
source:=$(src_cts) $(src_infra) $(src_rts) $(src_tools) $(src_lineeditor)
#############################################################################
# Dependencies
generatedependencies=$(call nativefile,$(PREFIX)makeutil/getdep) -o$(basename $#).d $(IFLAGS) $< $(basename $#)$(OBJEXT) $(genheaders) $(GENERATED-$<)
ifneq ($(IGNORE_DEPENDENCIES),1)
-include $(addprefix $(PREFIX),$(source:.cpp=.d)) $(addsuffix .d,$(basename $(wildcard $(generatedsource))))
endif
#############################################################################
# Compiling
#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR = /usr/local/lib
CPPFLAGS = -I. \
-I$(COURSE_DIR)
LDFLAGS = -L. \
-L$(COURSE_DIR) \
-R $(LIB_DIR):$(COURSE_DIR)
LDLIBS = -lspatialindex
compile=$(CXX) -c $(TARGET)$(call nativefile,$#) $(CXXFLAGS) $(CXXFLAGS-$(firstword $(subst /, ,$<))) $(IFLAGS) $(IFLAGS-$(firstword $(subst /, ,$<))) $(call nativefile,$<)
$(PREFIX)%$(OBJEXT): %.cpp $(PREFIX)makeutil/getdep$(EXEEXT)
$(checkdir)
$(generatedependencies)
$(compile)
#############################################################################
# Cleanup
clean:
find bin -name '*.d' -delete -o -name '*.o' -delete -o '(' -perm -u=x '!' -type d ')' -delete
#############################################################################
# Executable
$(PREFIX)query: $(addprefix $(PREFIX),$(source:.cpp=$(OBJEXT)))
#Code which I wrote in order to include my library --end
If this is an independent library, it should have its own Makefile and should build alone as well.
If you want to integrate your source into the main build process, you must conform to their structure.
You have
different c++ source suffix .cc vs .cpp
This is easily resolvable by renaming your source files to .cpp.
absolute path /home/NP/rtree/... vs relative path tools/r/...
This would involve moving the entire tree into the main build tree, because the rules expect the directories to be accessible from there.
But I think the best is to have a library Makefile and integrate that into the main build.
Unfortunately, there is no easy answer like change variable X and move line Y. I recommend, sit down with your colleague and resolve this Makefile issue together.
I am trying to implement the non-recursive make solution outlined in the paper "Recursive Make Considered Harmful". I'm currently stuck on getting the *.d dependency files to generate. I've provided the makefile, sample module.mk and error below. Any ideas how I can fix this?
MODULES := \
module1 \
module2
# define compiler
CC = /opt/local/bin/clang++-mp-3.1
# exclude the following warnings for clang
CLANG_NO_WARN = \
-Wno-c++98-compat \
-Wno-weak-vtables \
-Wno-padded \
-Wno-global-constructors \
-Wno-exit-time-destructors
# look for include files in each of the modules
CFLAGS += \
-g -Weverything -Wall -std=c++11 -stdlib=libc++ $(CLANG_NO_WARN) \
-I../ -I/usr/local/include $(patsubst %, -I%, $(MODULES))
# linker flags
LDFLAGS := \
-stdlib=libc++ \
-L/usr/local/boost_1_50_0/stage/lib -L/usr/local/lib
# extra libraries if required (each module will add to this)
LIBS := \
-lboost_program_options \
-lboost_system \
-lglog \
-lpugixml
# source files to be compiled (each module will add to this)
SRCS := \
Main.cpp
# include the descriptions for each module
include $(patsubst %, %/module.mk, $(MODULES))
# determine the object files
OBJS := \
$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
# link the program
prog: $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS) $(LIBS)
# include the C include dependencies
include $(OBJS:.o=.d)
# calculate C include dependencies
%.d: %.cpp
depend.sh `dirname $*.cpp` $(CFLAGS) $*.cpp > $#
----------
#!/bin/sh
# Evaluate dependencies for use by the makefile
echo "Called"
DIR="$1"
shift 1
case "$DIR" in
"" | ".")
$CC -MM -MG "$#" | sed -e 's#ˆ\(.*\)\.o:#\1.d \1.o:#' ;;
*)
$CC -MM -MG "$#" | sed -e "s#ˆ\(.*\)\.o:#$DIR/\1.d \ $DIR/\1.o:#" ;;
esac
------------
# module.mk
SRCS += \
Algo.cpp \
CommandHandler.cpp \
Exchange.cpp \
TCPSocket.cpp \
TradingEngine.cpp
----------
$ make
makefile:68: Main.d: No such file or directory
makefile:68: view_string.d: No such file or directory
makefile:68: Algo.d: No such file or directory
makefile:68: CommandHandler.d: No such file or directory
makefile:68: Exchange.d: No such file or directory
makefile:68: TCPSocket.d: No such file or directory
makefile:68: TradingEngine.d: No such file or directory
makefile:68: Exchange.d: No such file or directory
makefile:68: Requests.d: No such file or directory
makefile:68: TickCapture.d: No such file or directory
makefile:68: types.d: No such file or directory
make: *** No rule to make target `types.d'. Stop.
UPDATE
Finished makefile and sample module.mk
$cat makefile
# executable name
BINARY := my_prog
# clang config
CLANG := /opt/local/bin/clang++-mp-3.1
CLANG_WARNINGS := \
-Wno-c++98-compat \
-Wno-weak-vtables \
-Wno-padded \
-Wno-global-constructors \
-Wno-exit-time-destructors
CLANG_CFLAGS := \
-g -Weverything -Wall -std=c++11 -stdlib=libc++
CLANG_LDFLAGS := \
-stdlib=libc++
# generic compiler config
CC := $(CLANG)
CFLAGS := $(CLANG_WARNINGS) $(CLANG_CFLAGS)
LDFLAGS := $(CLANG_LDFLAGS)
INCS := \
-I../ \
-I/usr/local/include \
$(patsubst %, -I%, $(SUBDIRS))
LIBS := \
-L/usr/local/boost_1_50_0/stage/lib \
-L/usr/local/lib \
-lboost_program_options \
-lboost_system \
-lglog \
-lpugixml
# list subdirectories in which to look for dependencies
# must define SRCS first as subdirs will append to this
# their src files
SRCS := Main.cpp
SUBDIRS := \
module1 \
module2
include $(patsubst %, %/module.mk, $(SUBDIRS))
# derive object files from srcs
OBJS := $(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
# link the program
$(BINARY): $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS) $(LIBS)
# include generated dependency files
DEPS := $(OBJS:.o=.d)
-include $(DEPS)
# generate include dependencies
%.d: %.cpp
./depend.sh `dirname $*.cpp` $(INCS) $*.cpp > $#
# compile
.cpp.o:
$(CC) $(CFLAGS) $(INCS) $< -c -o $#
# clean, obviously
clean:
rm -f $(BINARY)
rm -f $(OBJS)
rm -f $(DEPS)
# et voila!
-----
$cat module1/module.mk
SRCS_PATH := module1
SRCS += \
$(SRCS_PATH)/Algo.cpp \
$(SRCS_PATH)/CommandHandler.cpp \
$(SRCS_PATH)/Exchange.cpp \
$(SRCS_PATH)/TCPSocket.cpp \
$(SRCS_PATH)/TradingEngine.cpp
It looks as if some module adds types.cpp to SRCS, even though no such source file exists.
As for the warnings, the first time you run this makefile, the dependency files (foo.d) do not yet exist, so Make complains that it can't include them. It's not a problem, and the warnings won't appear in subsequent runs when those files do exist beforehand. To supress the warnings entirely, change include to -include.