I don't know why, but at each new version of CGAL, the procedure to compile completely changes. So, it's not even possible to recompile old piece of code (6 months old) because it doesn't work like that anymore.
I'm frankly very tired of redoing all the makefile of my projects that use CGAL each time. This time, for libcgal8, I don't find any simple substitute. Here's the makefile I was normally using:
ifndef CGAL_MAKEFILE
CGAL_MAKEFILE = /usr/local/cgal/share/cgal/cgal.mk
endif
include $(CGAL_MAKEFILE)
LIBPATH = \
$(CGAL_LIBPATH)
LDFLAGS = \
$(LONG_NAME_PROBLEM_LDFLAGS) \
$(CGAL_LDFLAGS)
COMP=-frounding-math -fopenmp -std=c++0x -l json -L$(LIBPATH) $(LDFLAGS)
EXEC=../crender
all: main.o
g++ -fPIC main.o $(EXEC) $(COMP)
main.o: main.cpp ../common/common.hpp
g++ -c main.cpp $(COMP) -o main.o
So, what do I have to change to make it work again ? If possible, a solution that will survive to the future changes of CGAL.
If it can help, here's the kind of error that I get:
In function CGAL::Gmpq_rep::Gmpq_rep()':
main.cpp:(.text._ZN4CGAL8Gmpq_repC2Ev[_ZN4CGAL8Gmpq_repC5Ev]+0x14): undefined reference to__gmpq_init'
And I get these kind of errors for other functions like "__gmpg_add", "__gmpq_sub" and "__gmpq_mul."
SOLUTION:
You need to add "-lgmp" in the compilation instruction. It's sad that it's not done by default by the makefile provided by CGAL!
(Answered in the comments and in an Edit. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
You need to add "-lgmp" in the compilation instruction. It's sad that it's not done by default by the makefile provided by CGAL!
#sloriot Added:
Since January 2009 (release 3.4), CGAL is using cmake as build system. Since then, all include/link compiler flags are provided through the cmake mechanism (CGALConfig.cmake).
As mentioned above, now CGAL uses cmake as build system. While compiling CGAL example with cmake, I encountered similar problem. Solution is to add and link GMP library. Here is how its done for cmake: Cmake basic library linking problem
This is my makefile for linux and mac os x (no using cmake):
CPP := g++
OPCJE := -W -Wall -pedantic -O0 -Wno-c++11-extensions
BIBLIOTEKI := -lboost_math_c99 -lboost_thread -lm -lCGAL -lmpfr -lgmp
PISZ := echo -e
UNAME_S := $(shell uname -s)
on Mac os X some library are different name (brew install)
ifeq ($(UNAME_S),Darwin)
BIBLIOTEKI = -lboost_math_c99 -lboost_thread-mt -lm -lcgal -lmpfr -lgmp
PISZ = echo
endif
all source
SRC = $(wildcard *.cpp)
OBJ = $(addsuffix .o, $(basename $(SRC)))
BIN_DIR = ./bin
W_ZRODLA = $(wildcard *.cpp)
PROGRAMY = ${W_ZRODLA:%.cpp=$(BIN_DIR)/%}
$(BIN_DIR)/%: %.cpp
#mkdir -p ./bin
$(CPP) $(OPCJE) $< -o $# $(BIBLIOTEKI)
wszystkie: $(PROGRAMY)
#echo
clean:
rm -f ./bin/*
mem: 01
valgrind -v --tool=memcheck --leak-check=full ./01
Related
So I am using nvidia's deepstream sdk and trying to modify the makefile of one of the sample examples given as I wish to link and add my own libraries. This is the makefile being employed where I am setting the path of the CUSTOM_LIB to point to the location of my library. The issue is the project gets compiled successfully but during run time, its unable to find the custom library. I performed ldd on the executable generated and there also it was showing the library as 'not found'. I think it's something to do with rpath but I am not sure about that.
APP:= sample
TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -)
NVDS_VERSION:=4.0
LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/
ifeq ($(TARGET_DEVICE),aarch64)
CFLAGS:= -DPLATFORM_TEGRA
endif
CUDA_VER:=10.0
CC:=g++
SRCS:= $(wildcard ../src/*.c)
#SRCS+= $(wildcard ../../apps-common/src/*.c)
#SRCS+=
INCS:= $(wildcard ../include/*.h)
PKGS:= gstreamer-1.0 gstreamer-video-1.0 x11 opencv
OBJS:= $(SRCS:.c=.o)
CFLAGS+= -I../include -I/usr/include -I$(CUSTOM_LIB)/include -I/usr/local/cuda-10.0/targets/aarch64-linux/include/ -I/usr/include/jsoncpp -DDS_VERSION_MINOR=0 -DDS_VERSION_MAJOR=4 -fpermissive -Wnarrowing
LIBS+= -L$(LIB_INSTALL_DIR) -L/usr/lib/aarch64-linux-gnu -L$(CUSTOM_LIB)/lib -L/usr/lib/aarch64-linux-gnu/ -lcurl -letlic -letolm -lssl -lcrypto -llogger -lpthread -lsqlite3 -ljsoncpp -lnvdsgst_meta -lnvbufsurface -lnvbufsurftransform -lnvds_meta -lnvdsgst_helper -lnvds_utils -lm -L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart \
-lgstrtspserver-1.0 -Wl,-rpath,$(LIB_INSTALL_DIR)
CFLAGS+= `pkg-config --cflags $(PKGS)`
LIBS+= `pkg-config --libs $(PKGS)`
all: $(APP)
debug: CXXFLAGS += -DDEBUG -g
debug: CFLAGS += -DDEBUG -g
debug: $(APP)
%.o: %.c $(INCS) Makefile
$(CC) -c -o $# $(CFLAGS) $<
$(APP): $(OBJS) Makefile
$(CC) -o $(APP) $(OBJS) $(LIBS)
clean:
rm -rf $(OBJS) $(APP)
You need to set rpath to a colon-separated list of directories where your libraries are found. You only add LIB_INSTALL_DIR but not CUSTOM_LIB_DIR. Generally everything you pass to -L you need to pass to -rpath too, unless there is a specific reason not to. For example, if you are building a package that has more than a single library and you are going to install in a standard place like /usr/lib, you don't have to add the directory where libraries temporarily live to -rpath. If you are going to install to a non-standard directory, add that directory.
I have a makefile that I need to modify to include the path to libraries.I am trying to run program given to me by someone else. I'm really confused on how the makefile works and don't understand what the previous lines are.
These are the directions given to me to modify the makefile:
Change the lines:
INCS = -I"../../LIB/libpca/include"
LIBS = -L"../../LIB/libpca/build" -lpca -larmadillo
in the Makefile to represent the folder where you installed the libpca and armadillo libraries.
Now I now what my new paths are:
Desktop/PCA-CD/Libraries
but I don't understand what is is that I really need to change.
Here is what the makefile looks like:
PROG = CD
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
CXX = clang++ -stdlib=libc++
else
CXX = g++
endif
FLAGS = -O0 -g3 -Wall -std=c++0x -pthread
INCS = -I"../../LIB/libpca/include"
LIBS = -L"../../LIB/libpca/build" -lpca -larmadillo
SRCS = CD.cpp
RM = rm -f
all :
$(CXX) $(FLAGS) $(INCS) $(SRCS) $(LIBS) -o $(PROG)
# $(CXX) $(FLAGS) $(SRCS) -o $(PROG)
clean :
$(RM) $(PROG)
Thanks for any help provided.
I think they're suggesting to change the line:
INCS = -I"../../LIB/libpca/include"
LIBS = -L"../../LIB/libpca/build" -lpca -larmadillo
to
INCS = -I"Desktop/PCA-CD/Libraries/include"
LIBS = -L"Desktop/PCA-CD/Libraries/build" -lpca -larmadillo
Notice that Desktop/PCA-CD/Libraries is a relative path, and assumes that the library is stored in the subdirectory of the build directory. From your build directory, try running ls Desktop/PCA-CD/Libraries/build, to confirm it is right path. If it's not, replace it with the absolute path of the directory where you installed the library.
I'm trying to set up an OpenMP project using Clang (3.7.0) on my laptop running Linux Mint.
Now I've read that OpenMP is not supported right away so I followed the tutorial https://clang-omp.github.io/ to integrate OpenMP into Clang.
I've cloned the source code, set the environment variables and set the -fopenmp flag to my project, but I still get the error:
fatal error: 'omp.h' file not found
when building.
My guess is that I have set the environment variables wrong. Is there a way to check if I have put them in the right place? I have just copied them in the .bashrc file.
When I run locate omp.h I get:
/usr/include/re_comp.h
/usr/include/linux/ppp-comp.h
/usr/include/linux/seccomp.h
/usr/include/net/ppp-comp.h
/usr/include/openssl/comp.h
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/omp.h
/usr/lib/perl/5.18.2/CORE/regcomp.h
/usr/src/linux-headers-3.13.0-24/arch/arm/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/microblaze/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/mips/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/powerpc/include/uapi/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/s390/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/sh/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/sparc/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/arch/x86/include/asm/seccomp.h
/usr/src/linux-headers-3.13.0-24/include/linux/ppp-comp.h
/usr/src/linux-headers-3.13.0-24/include/linux/seccomp.h
/usr/src/linux-headers-3.13.0-24/include/net/ipcomp.h
/usr/src/linux-headers-3.13.0-24/include/uapi/linux/ppp-comp.h
/usr/src/linux-headers-3.13.0-24/include/uapi/linux/seccomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/seccomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/crypto/pcomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/inet/ipcomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/inet6/ipcomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/isdn/ppp/bsdcomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/ppp/bsdcomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/config/xfrm/ipcomp.h
/usr/src/linux-headers-3.13.0-24-generic/include/linux/ppp-comp.h
/usr/src/linux-headers-3.13.0-24-generic/include/linux/seccomp.h
Here is my makefile:
# Requires the following project directory structure:
# /bin
# /obj
# /src
# Use 'make remove' to clean up the whole project
# Name of target file
TARGET = main
CXX = clang++
CFLAGS = -std=c++11 \
-Weverything -Wall -Wextra -Wold-style-cast -Wpointer-arith -Wcast-qual \
-Wno-missing-braces -Wempty-body -Wno-error=uninitialized \
-Wno-error=deprecated-declarations -Wno-c++98-compat \
-pedantic-errors -pedantic \
-Os -fopenmp
LINKER = clang++ -o
LFLAGS = -Wall -Weverything -pedantic
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
RM = rm -f
$(BINDIR)/$(TARGET): $(OBJECTS)
#$(LINKER) $# $(LFLAGS) $(OBJECTS)
#echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
#$(CXX) $(CFLAGS) -c $< -o $#
#echo "Compiled "$<" successfully!"
.PHONEY: prepare
prepare:
mkdir -p bin
mkdir -p obj
.PHONEY: clean
clean:
#$(RM) $(OBJECTS)
#echo "Cleanup complete!"
#$(RM) tmp_file-*
#echo "Temporary files removed!"
.PHONEY: remove
remove: clean
#$(RM) $(BINDIR)/$(TARGET)
#echo "Executable removed!"
.PHONEY: run
run:
./bin/$(TARGET)
OpenMP is well supported in Clang 3.7, but you might need to enable it see here.
OpenMP 3.1 is fully supported, but disabled by default. To enable it,
please use the -fopenmp=libomp command line option.
Also see Status of supported OpenMP constructs for more precision.
So you don't have to clone the clang-omp project any more.
What build system do you use for your project and what errors do you get when you compile?
If you use Makefile: do not forget to add the -fopenmp flag.
If you use CMake: you should also look for right OpenMP flags with the FindOpenMP module and add them accordingly.
If you still get the include error, then your omp.h header file may not be in the Clang default search path. So you should try to include the one that comes with GCC and add -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include/.
So in your case you should add this line:
CFLAGS = -std=c+11 [etc...]
CFLAGS += -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include/
LINKER = [etc...]
'omp.h' is a C header that comes with the "Mint" libgcc-[version]-dev (RPM-based OSes have this header in a different package, e.g. libgomp-*).
Example libgcc-4.8-dev: /usr/lib/gcc/x86_64-linux-gnu/4.8/include/omp.h
Solution: Install the version for your default GCC: gcc --version
libgcc-dev
In case the context is a build of Clang from source - one solution is to:
Ensure the openmp subproject is built by adding it to LLVM_ENABLE_PROJECTS at CMake invocation
Build that subproject with cmake --build . --target omp
Copy the generated omp.h from build/projects/openmp/runtime/src/omp.h to build/lib/clang/10.0.0/include, which is in the newly-built Clang's default search path.
I previously used the "add GCC's path to omp.h to every build command" approach, but I found this easier.
I am trying to work through the following http://www.cs.columbia.edu/~keenan/Projects/DGPDEC/paper.pdf. The following source files are used to illustrate what is going on https://github.com/dgpdec/course. Now I cannot get it to work. Here is what I tried:
First I went into the folder 'basecode', edited the Makefile to have the right include and library paths. Then I want to make but it gives me the error
'ostream’ in namespace ‘std’ does not name a type
I looked for this error online but I could not find a solution to the problem. In the included file libddg_userguide.pdf it says that I should edit the Makefile in root libddg folder but I don't know which folder that is. I am sorry for the kind of nooby question but I am really stuck and have been trying for a long time. Here is the Makefile I used (in the Basecode folder) for reference:
##########################################################################################
# Specify library locations here (add or remove "#" marks to comment/uncomment lines for your platform)
# Linux
DDG_INCLUDE_PATH = -I/usr/include/ -I/usr/local/include -I/usr/include/suitesparse
DDG_LIBRARY_PATH = -L/usr/lib -L/usr/local/lib
DDG_BLAS_LIBS = -llapack -lblas -lgfortran
DDG_SUITESPARSE_LIBS = -lspqr -lcholmod -lmetis -lcolamd -lccolamd -lcamd -lamd -lm
DDG_OPENGL_LIBS = -lglut -lGL -lGLU -lX11
########################################################################################
TARGET = ddg
CC = g++
LD = g++
CFLAGS = -O3 -Wall -Werror -ansi -pedantic $(DDG_INCLUDE_PATH) -I./include -I./src
LFLAGS = -O3 -Wall -Werror -ansi -pedantic $(DDG_LIBRARY_PATH)
LIBS = $(DDG_OPENGL_LIBS) $(DDG_SUITESPARSE_LIBS) $(DDG_BLAS_LIBS)
########################################################################################
## !! Do not edit below this line
HEADERS := $(wildcard include/*.h)
SOURCES := $(wildcard src/*.cpp)
OBJECTS := $(addprefix obj/,$(notdir $(SOURCES:.cpp=.o)))
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(LD) $(OBJECTS) -o $(TARGET) $(CFLAGS) $(LFLAGS) $(LIBS)
obj/%.o: src/%.cpp ${HEADERS}
$(CC) -c $< -o $# $(CFLAGS)
clean:
rm -f $(OBJECTS)
rm -f $(TARGET)
rm -f $(TARGET).exe
Thanks in advance for any help!
It means there is a bug in the code: a header's missing because someone made an assumption.
Your particular toolchain does not satisfy that assumption.
Find the problematic file (you didn't say which it is) and add #include <ostream> to it.
(course/Connection/include/DenseMatrix.h appears to be one such file; there may be others.)
N.B. I must say that, despite the bug, overall this is incredibly good C++ code for a University course. I'm impressed.
Well, after 3 hours of researching, I'm about to go insane, so I figure it's time to pass it off to some new eyes.
CXXFLAGS = -g -Wall
OBJS = main.o
PROG = test
INCLUDES = -I /usr/include/mysql -I /usr/local/include
LIBS = -L /usr/lib/mysql -l libmysqlclient.so.15.0.0 -L /usr/local/lib -l libmysqlpp.so.3.1.0
all: $(PROG)
${PROG}: $(OBJS)
$(CXX) $(INCLUDES) -o $(PROG) $(OBJS) $(LIBS)
clean:; $(RM) -f $(PROG) core *.o
There's something wrong with the include paths, because I get errors that mysql_version.h does not exist when it clearly does exist in /usr/include/mysql.
Checking the first part out of the ouput, it says
g++ -g -Wall -c -o main.o main.cpp
which makes me think that I've formatted something in the Makefile wrong (due to the extra spaces and lack of include/library paths). However, I've looked at dozens of manuals and articles on Makefiles and the g++ options and... no progress.
I assume this should be a simple fix. Please, please help (do you sense my despair?).
On another note, do you think specifying the library specifically is necessary? I had this stuff running in XCode just fine, but I'm trying to migrate the code to my web server... the Makefile has stopped all progress, and I figure it's something I should learn from.
In your makefile, you have added your include directives to the linking stage, not the compiling stage.
The lines
${PROG}: $(OBJS)
$(CXX) $(INCLUDES) -o $(PROG) $(OBJS) $(LIBS)
Say to make the program in ${PROG} from object files in ${OBJS} by calling the compiler in ${CXX} passing the include folders (along with your other arguments). Instead, for your variable section, do this:
INCLUDES = -I /usr/include/mysql -I /usr/local/include
CXXFLAGS = -g -Wall ${INCLUDES}
OBJS = main.o
PROG = test
LIBS = -L /usr/lib/mysql -l libmysqlclient.so.15.0.0 -L /usr/local/lib -l libmysqlpp.so.3.1.0
This way your CXXFLAGS (which are used for the compile stage) should now pickup your include directives.