Rendering using OpenSG - c++

I have a bit of a situation here. I am trying to work with OpenSG. I downloaded the package and installed it as it was instructed in the INSTALL file. Then i installed its system dependent libraries as well. Now i tried to build its tutorial and it shows errors. It says glut is not configured but i enabled the glut library while i configured it and have installed all the dependent packages and libraries as well. I dont understand what the issue is.
The errors shown while trying to make OpenSG tutorial is as follows:
ani#anilap:~/OpenSG/Tutorials$ make
g++ Warning GLUT not configured, ignoring request -D_GNU_SOURCE -DQT_CLEAN_NAMESPACE -D_OSG_HAVE_CONFIGURED_H_ -DQT_NO_XINERAMA -DQT_NO_XRENDER -DQT_NO_XFTFREETYPE -DQT_NO_XKB - DQT_NO_SM_SUPPORT -DQT_NO_IMAGEIO_MNG -DQT_NO_IMAGEIO_JPEG -DQT_NO_STYLE_AQUA - DQT_NO_STYLE_MAC -DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_COMPACT -ansi -use_readonly_const -ftemplate-depth-100 -g -DOSG_DEBUG -I/usr/local/include 01hello.cpp Warning GLUT not configured, ignoring request -g -L/usr/local/lib/dbg -lOSGWindowX -lOSGSystem -lOSGBase - lGLU -lGL -lXmu -lXi -lXt -lX11 -lpthread -ldl -lm -L/usr/X11R6/lib -o 01hello
g++: Warning: No such file or directory
g++: GLUT: No such file or directory
g++: not: No such file or directory
g++: configured,: No such file or directory
g++: ignoring: No such file or directory
g++: request: No such file or directory
g++: Warning: No such file or directory
g++: GLUT: No such file or directory
g++: not: No such file or directory
g++: configured,: No such file or directory
g++: ignoring: No such file or directory
g++: request: No such file or directory
In file included from /usr/include/c++/4.4/ext/hash_map:60,
from /usr/local/include/OpenSG/OSGWindow.h:53,
from /usr/local/include/OpenSG/OSGGeometry.h:48,
from /usr/local/include/OpenSG/OSGSimpleGeometry.h:49,
from 01hello.cpp:19:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
01hello.cpp: In function ‘int main(int, char**)’:
01hello.cpp:48: error: ‘GLUTWindowPtr’ was not declared in this scope
01hello.cpp:48: error: expected ‘;’ before ‘gwin’
01hello.cpp:49: error: ‘gwin’ was not declared in this scope
make: *** [01hello] Error 1
ani#anilap:~/OpenSG/Tutorials$
If anyone could help me find a solution to this I would be really grateful.
The makefile for the tutorial is as follows:
# trivial makefile for OpenSG tutorials
# use debug or opt libs?
LIBTYPE ?= dbg
# set the path to the installed osg-config executable here
# if you don't set it, the makefile tries to guess
# e.g. if you installed in /usr/local:
# OSGCONFIG := /usr/local/bin/osg-config
# *****************************************************
# you shouldn't have to change anything after this line
# *****************************************************
# try to guess the OSGCONFIG path
OSGCONFIG := notset
# use OSGPOOL if set
OSGPOOL ?= ..
# try to get configured information first, will not work if more
# than one system is configured from one dir. Just for the 1.0
OSGINSTALLPREFIX := notset
PREFIXSUFFIX := $(shell $(OSGPOOL)/CommonConf/config.guess)
-include .prefix.$(PREFIXSUFFIX)
ifneq ($(OSGINSTALLPREFIX),notset)
OSGCONFIG := $(OSGINSTALLPREFIX)/bin/osg-config
endif
ifneq ($(OSGROOT),)
OSGCONF := $(wildcard $(OSGROOT)/bin/osg-config)
ifneq ($(OSGCONF),)
OSGCONFIG := $(OSGCONF)
endif
endif
# if configure info wasn't found, maybe a Builds/* install?
ifeq ($(OSGCONFIG),notset)
INSTALLROOT := $(wildcard ../Builds/$(shell ../CommonConf/config.guess)-*)
OSGCONF := $(wildcard $(INSTALLROOT)/bin/osg-config)
ifneq ($(OSGCONF),)
OSGCONFIG := $(OSGCONF)
endif
endif
# maybe we can find it in the path?
ifeq ($(OSGCONFIG),notset)
OSGCONF := \
$(shell if which osg-config >/dev/null 2>&1; then which osg-config; fi )
OSGCONF := $(strip $(OSGCONF))
ifneq ($(OSGCONF),)
OSGCONFIG := $(OSGCONF)
endif
endif
# ok, give up
ifeq ($(OSGCONFIG),notset)
$(error Can't find osg-config, please configure the Makefile or \
add it to your PATH)
endif
### System dependencies ###############################################
# Set the system we're running on
SYSTEM := $(shell uname)
# which extension to be used for executables
EXEEXT :=
# which extension to be used for executables
ADDLIB :=
# be very careful with these lines. There needs to be a space after the Unix
# lines and nothing after the win lines!!
ifeq ($(SYSTEM),IRIX)
CCOUT := -o
LDOUT := -o
LINK :=
ADDLIB := X
endif
ifeq ($(SYSTEM),IRIX64)
CCOUT := -o
LDOUT := -o
LINK :=
ADDLIB := X
endif
ifeq ($(SYSTEM),Linux)
CCOUT := -o
LDOUT := -o
LINK :=
ADDLIB := X
endif
ifeq ($(findstring WIN,$(SYSTEM)),WIN)
OS := WIN32
CCOUT := -Fo
LDOUT := /out:
LINK := -link
EXEEXT :=.exe
endif
ifeq ($(SYSTEM),HP-UX)
CCOUT := -o
LDOUT := -o
LINK :=
ADDLIB := X
endif
ifeq ($(SYSTEM),Darwin)
CCOUT := -o
LDOUT := -o
LINK :=
endif
# Var settings
ifeq ($(findstring WIN,$(SYSTEM)),WIN)
CC = "$(shell $(OSGCONFIG) --compiler)"
else
CC = $(shell $(OSGCONFIG) --compiler)
endif
CCFLAGS = $(shell $(OSGCONFIG) --cflags --$(LIBTYPE) Base System $(ADDLIB) GLUT)
LDFLAGS = $(LINK) $(shell $(OSGCONFIG) --libs --$(LIBTYPE) Base System $(ADDLIB) GLUT)
# all tutorials in this directory
TUTS := $(wildcard [0-9][0-9]*.cpp)
PROGS := $(TUTS:.cpp=$(EXEEXT))
ifeq ($(findstring WIN,$(SYSTEM)),WIN)
TUTS := $(filter-out %X.cpp, $(TUTS))
endif
# program dependencies
default: $(PROGS)
# make rules
.PHONY: clean Clean
clean:
rm -f *.o
rm -f *.obj
rm -rf ii_files
rm -f *.pdb
rm -f *.ilk
rm -f *.idb
Clean: clean
rm -f $(PROGS)
%.o: %.cpp
$(CC) -c $(CCFLAGS) $<
%: %.o
$(CC) $(LDOUT)$# $< $(LDFLAGS)
%$(EXEEXT): %.cpp
$(CC) $(CCFLAGS) $< $(LDFLAGS) $(LDOUT)$#
When I tried to configure and compile opensg again and tried to make the tutorial it showed the following error which is slightly different from the previous error. I had encountered this error before but it had changed. The error:
ani#anilap:~/OpenSG/Tutorials$ make
g++ -D_GNU_SOURCE -DQT_CLEAN_NAMESPACE -DOSG_WITH_GLUT -DOSG_WITH_TIF -DOSG_WITH_JPG -DOSG_WITH_PNG -D_OSG_HAVE_CONFIGURED_H_ -DQT_NO_XINERAMA -DQT_NO_XRENDER -DQT_NO_XFTFREETYPE -DQT_NO_XKB -DQT_NO_SM_SUPPORT -DQT_NO_IMAGEIO_MNG -DQT_NO_IMAGEIO_JPEG -DQT_NO_STYLE_AQUA -DQT_NO_STYLE_MAC -DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_COMPACT -ansi -use_readonly_const -ftemplate-depth-100 -g -DOSG_DEBUG -DOSG_WITH_GLUT -DOSG_WITH_TIF -DOSG_WITH_JPG -DOSG_WITH_PNG -I/usr/local/include 01hello.cpp -g -L/usr/local/lib/dbg -lOSGWindowGLUT -lOSGWindowX -lOSGSystem -lOSGBase -ltiff -ljpeg -lpng -lz -lglut -lGLU -lGL -lXmu -lXi -lXt -lX11 -lpthread -ldl -lm -L/usr/X11R6/lib -o 01hello
In file included from /usr/include/c++/4.4/ext/hash_map:60,
from /usr/local/include/OpenSG/OSGWindow.h:53,
from /usr/local/include/OpenSG/OSGGeometry.h:48,
from /usr/local/include/OpenSG/OSGSimpleGeometry.h:49,
from 01hello.cpp:19:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
/usr/bin/ld: cannot find -lXmu
collect2: ld returned 1 exit status
make: *** [01hello] Error 1
ani#anilap:~/OpenSG/Tutorials$
17-03-2011
The new errors that i encountered while I tried to make the tutorial after installing the missing library:
ani#anilap:~/OpenSG$ cd Tutorials/
ani#anilap:~/OpenSG/Tutorials$ make
g++ -D_GNU_SOURCE -DQT_CLEAN_NAMESPACE -DOSG_WITH_GLUT -DOSG_WITH_TIF
-DOSG_WITH_JPG - DOSG_WITH_PNG -D_OSG_HAVE_CONFIGURED_H_ -DQT_NO_XINERAMA -DQT_NO_XRENDER -DQT_NO_XFTFREETYPE -DQT_NO_XKB -DQT_NO_SM_SUPPORT -DQT_NO_IMAGEIO_MNG -DQT_NO_IMAGEIO_JPEG -DQT_NO_STYLE_AQUA -DQT_NO_STYLE_MAC -DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_COMPACT -ansi -use_readonly_const -ftemplate-depth-100 -g -DOSG_DEBUG -DOSG_WITH_GLUT -DOSG_WITH_TIF -DOSG_WITH_JPG -DOSG_WITH_PNG -I/usr/local/include 18opengl_slave.cpp -g -L/usr/local/lib/dbg -lOSGWindowGLUT -lOSGWindowX -lOSGSystem -lOSGBase -ltiff -ljpeg -lpng -lz -lglut -lGLU -lGL -lXmu -lXi -lXt -lX11 -lpthread -ldl -lm -L/usr/X11R6/lib -o 18opengl_slave
In file included from /usr/include/c++/4.4/ext/hash_map:60,
from /usr/local/include/OpenSG/OSGWindow.h:53,
from /usr/local/include/OpenSG/OSGGeometry.h:48,
from /usr/local/include/OpenSG/OSGSimpleGeometry.h:49,
from 18opengl_slave.cpp:21:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use
-Wno-deprecated.
18opengl_slave.cpp:70: error: ‘<anonymous>’ has incomplete type
18opengl_slave.cpp:70: error: invalid use of ‘GLvoid’
18opengl_slave.cpp: In function ‘GLvoid InitGL(GLsizei, GLsizei)’:
18opengl_slave.cpp:70: error: too few arguments to function ‘GLvoid LoadGLTextures(<type error>)’
18opengl_slave.cpp:92: error: at this point in file
18opengl_slave.cpp: At global scope:
18opengl_slave.cpp:310: error: ‘<anonymous>’ has incomplete type
18opengl_slave.cpp:310: error: invalid use of ‘GLvoid’
18opengl_slave.cpp: In function ‘int main(int, char**)’:
18opengl_slave.cpp:486: error: invalid conversion from ‘GLvoid (*)(<type error>)’ to ‘void (*)()’
18opengl_slave.cpp:486: error: initializing argument 1 of ‘void glutDisplayFunc(void (*)())’
make: *** [18opengl_slave] Error 1
ani#anilap:~/OpenSG/Tutorials$

Look at this line:
/usr/bin/ld: cannot find -lXmu
That means that you miss a library on your system. The name of that library is libxmu. You need to install the development package for it. If you are using ubuntu, you can do it using the following command:
apt-get install libxmu-dev

Related

How to compile DPDK application such as examples to support C++?

How should I modify Makefiles of DPDK to support c++ compilation? I tried by adding CFLAGS += -lstdc++ to the Makefile of the helloworld example but it seems not working. Is there a more standard way to do that?
Edited:
I'm using the makefile of helloworld example in DPDK 20.08 with some small modifications. I'm building it on ubuntu 20.04 ,and which is not cross-compilation. The DPDK is built with dpdk-setup script and not meson. The makefile is
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# binary name
APP = rss_helper
# all source are stored in SRCS-y
# SRCS-y := main.c
SRCS-y := test.cpp
# Build using pkg-config variables if possible
ifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
all: shared
# all: static
.PHONY: shared static
shared: build/$(APP)-shared
ln -sf $(APP)-shared build/$(APP)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) $(SRCS-y) -o $# $(LDFLAGS) $(LDFLAGS_SHARED)
build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) $(SRCS-y) -o $# $(LDFLAGS) $(LDFLAGS_STATIC)
build:
#mkdir -p $#
.PHONY: clean
clean:
rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
test -d build && rmdir -p build || true
else
ifeq ($(RTE_SDK),)
$(error "Please define RTE_SDK environment variable")
endif
# Default target, detect a build directory, by looking for a path with a .config
RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config)))))
include $(RTE_SDK)/mk/rte.vars.mk
CPPFLAGS += -O3
CPPFLAGS += $(WERROR_FLAGS)
CPPFLAGS += -DALLOW_EXPERIMENTAL_API
CPPFLAGS += -lstdc++
include $(RTE_SDK)/mk/rte.extapp.mk
endif
I changed the name of the source file and flags. The source file test.cpp contains only iostream header and an empty main function (just for test). There are two errors:
can't find the test.cpp with cpp on. It works find when replace test.cpp in makefile with test.c while keeping the actual source file name as test.cpp.
LD rss_helper
gcc: error: test.cpp: No such file or directory
make[1]: *** [/home/syk/dpdk-20.08/mk/rte.app.mk:456: rss_helper] Error 1
make: *** [/home/syk/dpdk-20.08/mk/rte.extapp.mk:15: all] Error 2
Error for LD like below
g++ -O3 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wpointer-arith -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wdeprecated -Wno-missing-field-initializers -Wimplicit-fallthrough=2 -Wno-format-truncation -Wno-address-of-packed-member -DALLOW_EXPERIMENTAL_API -lstdc++ -c -o test.o /home/syk/loadbalancing/rss_helper_demo/test.cpp
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wold-style-definition’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wnested-externs’ is valid for C/ObjC but not for C++
LD rss_helper
/usr/bin/ld: test.o: in function `_GLOBAL__sub_I_main':
test.cpp:(.text.startup+0x20): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: test.cpp:(.text.startup+0x27): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/syk/dpdk-20.08/mk/rte.app.mk:456: rss_helper] Error 1
make: *** [/home/syk/dpdk-20.08/mk/rte.extapp.mk:15: all] Error 2
I tried to resolve it by added -lstdc++ but still had it.
Edited-2:
The source file:
#include <iostream>
#include <rte_eal.h>
using namespace std;
class A{
int a;
};
int
main(void){
return 0;
}
It can't include iostream and rte_eal either.
there are 2 possible ways to solve this issue
set environment set CC=g++. Then execute make
edit Makefile to add CC = g++
with these changes I am able build and run the sample code.
linux-vdso.so.1 (0x00007fff0a3e6000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1389440000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f138904f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1388cb1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f13899cb000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1388a99000)
and
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=6e3fb6ed5f48b8f66fe4c05118f7b6bf6a9a1235, not stripped
You need to modify the makefile inorder to adapt C++:
You need to change CFLAGS to CPPFLAGS
See below reference example:
ifeq ($(RTE_SDK),)
$(error "Please define RTE_SDK environment variable")
endif
# Default target, can be overriden by command line or environment
RTE_TARGET ?= x86_64-native-linuxapp-gcc
include $(RTE_SDK)/mk/rte.vars.mk
# binary name
APP = dpdkrecv
# all source are stored in SRCS-y
SRCS-y := main.c syncshm.c cqf.cpp countingquotientfilter.cpp murmurhash3.cpp
CPPFLAGS += -O3 -mbmi2
CFLAGS += $(WERROR_FLAGS)
include $(RTE_SDK)/mk/rte.extapp.mk
Please share the Makefile,
I am adding
#include algorithm
dpdk ver: dpdk-stable-18.11.2 ,
build with
sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=install

math.h not found when using llvm

I'm trying to build a python wrapper using the following Makefile:
CC=/usr/local/opt/llvm/bin/clang
OS_NAME=$(shell uname -s)
ifeq ($(OS_NAME),Linux)
LAPACKLDFLAGS=/usr/lib64/atlas/libsatlas.so # single-threaded blas
#LAPACKLDFLAGS=/usr/lib64/atlas/libtatlas.so # multi-threaded blas
#BLAS_THREADING=-D MULTITHREADED_BLAS # remove this if wrong
endif
ifeq ($(OS_NAME),Darwin) # Mac OS X
LAPACKLDFLAGS=-framework Accelerate # for OS X
endif
LAPACKCFLAGS=-Dinteger=int $(BLAS_THREADING)
STATICLAPACKLDFLAGS=-fPIC -Wall -g -fopenmp -static -static-libstdc++ /home/lear/douze/tmp/jpeg-6b/libjpeg.a /usr/lib64/libpng.a /usr/lib64/libz.a /usr/lib64/libblas.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortran.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libquadmath.a # statically linked version
CFLAGS= -fPIC -Wall -g -std=c++11 $(LAPACKCFLAGS) -fopenmp -DUSE_OPENMP -O3
LDFLAGS=-fPIC -Wall -g -ljpeg -lpng -fopenmp
CPYTHONFLAGS=-I/usr/include/python2.7
SOURCES := $(shell find . -name '*.cpp' ! -name 'deepmatching_matlab.cpp')
OBJ := $(SOURCES:%.cpp=%.o)
HEADERS := $(shell find . -name '*.h')
all: deepmatching
.cpp.o: %.cpp %.h
$(CC) -o $# $(CFLAGS) -c $+
deepmatching: $(HEADERS) $(OBJ)
$(CC) -o $# $^ $(LDFLAGS) $(LAPACKLDFLAGS)
deepmatching-static: $(HEADERS) $(OBJ)
$(CC) -o $# $^ $(STATICLAPACKLDFLAGS)
python: $(HEADERS) $(OBJ)
# swig -python $(CPYTHONFLAGS) deepmatching.i # not necessary, only do if you have swig compiler
/usr/local/opt/llvm/bin/clang $(CFLAGS) -c deepmatching_wrap.c $(CPYTHONFLAGS)
/usr/local/opt/llvm/bin/clang -shared $(LDFLAGS) $(LAPACKLDFLAGS) deepmatching_wrap.o $(OBJ) -o _deepmatching.so $(LIBFLAGS)
clean:
rm -f $(OBJ) deepmatching *~ *.pyc .gdb_history deepmatching_wrap.o _deepmatching.so deepmatching.mex???
Previously, CC was set to g++, however, when I tried to build it like this, I'd get "ERROR: clang: error: unsupported option '-fopenmp".
Now I installed "brew install llvm" as this comes with the -fopenmp option. The unsupported error is resolved for now, but now the compiler doesn't seem to find a header file:
(base) MacBook-Pro-van-Brent:deepmatching BrentDeHauwere$ make python
/usr/local/opt/llvm/bin/clang -o hog.o -fPIC -Wall -g -std=c++11 -Dinteger=int -fopenmp -DUSE_OPENMP -O3 -I/usr/local/opt/llvm/include -c hog.cpp
In file included from hog.cpp:18:
In file included from ./std.h:20:
/usr/local/opt/llvm/bin/../include/c++/v1/math.h:300:15: fatal error: 'math.h' file not found
#include_next <math.h>
^~~~~~~~
1 error generated.
make: *** [hog.o] Error 1
I've tried setting options (I might have set them incorrectly) like -L/usr/local/opt/llvm/lib and -I/usr/local/opt/llvm/include, but no result so far. Any idea how I could point the compiler to the right direction for the header files?
Try running xcode-select —install in your terminal. This installs the xcode command line tools which should also install system headers files (as part of the macos sdk) and set your system include paths.

Makefile unable to link libraries during runtime

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.

Linking Boost::system library with OpenNI makefile

I'm trying to use the C++ Boost library to write some depth data I get form my Kinect to the serial port. In order to do this I need to link the appropriate libraries with this pre-written Makefile. I wrote a basic program using boost/asio to get a feel for the libraries and in order to compile I had to link to the boost_system library located in /usr/local/lib and include the header files from /usr/local/include/boost. I figured to use it in my OpenNI code I'd just have to make the same connection from this Makefile instead.
# take this file's dir
COMMON_CPP_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
include $(COMMON_CPP_MAKE_FILE_DIR)CommonDefs.mak
# define a function to figure .o file for each source file (placed under intermediate directory)
SRC_TO_OBJ = $(addprefix ./$(INT_DIR)/,$(addsuffix .o,$(notdir $(basename $1))))
# create a list of all object files
OBJ_FILES = $(call SRC_TO_OBJ,$(SRC_FILES_LIST))
# define a function to translate any source file to its dependency file (note that the way we create
# dep files, as a side affect of compilation, always puts the files in the INT_DIR with suffix .d)
SRC_TO_DEP = $(addprefix ./$(INT_DIR)/,$(addsuffix .d,$(notdir $(basename $1))))
# create a list of all dependency files
DEP_FILES = $(call SRC_TO_DEP,$(SRC_FILES_LIST))
# older version of gcc doesn't support the '=' symbol in include dirs, so we replace it ourselves with sysroot
INC_DIRS_FROM_SYSROOT = $(patsubst =/%,$(TARGET_SYS_ROOT)/%,$(INC_DIRS))
# append the -I switch to each include directory
INC_DIRS_OPTION = $(foreach dir,$(INC_DIRS_FROM_SYSROOT),-I$(dir)) -I/usr/local/include/boost
# append the -L switch to each library directory
LIB_DIRS_OPTION = $(foreach dir,$(LIB_DIRS),-L$(dir)) -L$(OUT_DIR) -L/usr/local/lib
# append the -l switch to each library used
USED_LIBS_OPTION = $(foreach lib,$(USED_LIBS),-l$(lib)) -lboost_system
# append the -D switch to each define
DEFINES_OPTION = $(foreach def,$(DEFINES),-D$(def))
# tell compiler to use the target system root
ifdef TARGET_SYS_ROOT
CFLAGS += --sysroot=$(TARGET_SYS_ROOT)
LDFLAGS += --sysroot=$(TARGET_SYS_ROOT)
endif
# set Debug / Release flags
ifeq "$(CFG)" "Debug"
CFLAGS += -O0 -g
endif
ifeq "$(CFG)" "Release"
CFLAGS += -O2 -DNDEBUG
endif
CFLAGS += $(INC_DIRS_OPTION) $(DEFINES_OPTION)
LDFLAGS += $(LIB_DIRS_OPTION) $(USED_LIBS_OPTION)
# some lib / exe specifics
ifneq "$(LIB_NAME)" ""
OUTPUT_NAME = lib$(LIB_NAME).so
CFLAGS += -fPIC -fvisibility=hidden
ifneq ("$(OSTYPE)","Darwin")
LDFLAGS += -Wl,--no-undefined
OUTPUT_NAME = lib$(LIB_NAME).so
OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -shared
else
LDFLAGS += -undefined error
OUTPUT_NAME = lib$(LIB_NAME).dylib
OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -dynamiclib -headerpad_max_install_names
endif
endif
ifneq "$(EXE_NAME)" ""
OUTPUT_NAME = $(EXE_NAME)
OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS)
endif
ifneq "$(SLIB_NAME)" ""
CFLAGS += -fPIC
OUTPUT_NAME = lib$(SLIB_NAME).a
OUTPUT_COMMAND = $(AR) -cq $(OUTPUT_FILE) $(OBJ_FILES)
endif
define CREATE_SRC_TARGETS
# create a target for the object file (the CXX command creates both an .o file
# and a .d file)
ifneq ("$(OSTYPE)","Darwin")
$(call SRC_TO_OBJ,$1) : $1 | $(INT_DIR)
$(CXX) -MD -MP -MT "$(call SRC_TO_DEP,$1) $$#" -c $(CFLAGS) -o $$# $$<
else
$(call SRC_TO_OBJ,$1) : $1 | $(INT_DIR)
$(CXX) -c $(CFLAGS) -o $$# $$<
endif
endef
#############################################################################
# Targets
#############################################################################
.PHONY: clean-objs clean-defs
include $(COMMON_CPP_MAKE_FILE_DIR)CommonTargets.mak
# create targets for each source file
$(foreach src,$(SRC_FILES_LIST),$(eval $(call CREATE_SRC_TARGETS,$(src))))
# include all dependency files (we don't need them the first time, so we can use -include)
-include $(DEP_FILES)
$(OUTPUT_FILE): $(OBJ_FILES)
$(OUTPUT_COMMAND)
clean-objs:
rm -rf $(OBJ_FILES)
clean-defs:
rm -rf $(DEP_FILES)
clean: clean-objs clean-defs
I added:
-I/usr/local/include/boost
to the INC_DIRS_OPTION
-L/usr/local/lib
to the LIBS_DIRS_OPTION, and
-lboost_system
to the USED_LIBS_OPTION (asio relies on the boost system library for error generation of some sort)
I get this error:
c++ -o ../Bin/x64-Release/Sample-NiSimpleRead ./x64-Release/NiSimpleRead.o -arch i386 -arch x86_64 -L../../Lib -L../Bin/x64-Release -lOpenNI -lboost_system
ld: warning: ignoring file /usr/local/lib/libboost_system.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"boost::system::generic_category()", referenced from:
__GLOBAL__I_a in NiSimpleRead.o
"boost::system::system_category()", referenced from:
__GLOBAL__I_a in NiSimpleRead.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [../Bin/x64-Release/Sample-NiSimpleRead] Error 1
I've tried adding the lib directory to my DYLD_LIBRARY_PATH which did nothing. I've also tried creating some kind of shared (*.so) library, first using the NiSimpleRead.o binary combined with the libboost_system.a file, which brought up a lot of errors. Then tried changing the boost_system.a file by itself, to a .so, which also did nothing. Any advice on this would be great.
Your problem seems to be that you have only 64-bit Boost, and you're trying to make an universal (both 32-bit and 64-bit) binary. Make sure to install dependencies in both 32-bit and 64-bit versions, or throw away this -arch i386 from your build instructions.

How do I link with GLU?

I've just discovered FLTK and I made a makefile for my test. Here is my makefile:
################ template makefile ##############
# We don't know what compiler to use to build fltk on this machine - but fltk-config does...
CC  = $(shell fltk-config --cc)
CXX = $(shell fltk-config --cxx)
# Set the flags for compiler: fltk-config knows the basic settings, then we can add our own...
CFLAGS   = $(shell fltk-config --cflags)
CXXFLAGS = $(shell fltk-config --cxxflags) -I/System/Library/Frameworks/OpenGL.framework/Versions/A/
# We don't know what libraries to link with: fltk-config does...
LINKFLTK = $(shell fltk-config --ldstaticflags)
LINKFLTK_GL = $(shell fltk-config --use-gl --ldstaticflags) -lGLU
LINKFLTK_IMG = $(shell fltk-config --use-images --ldstaticflags)
# Possible steps to run after linking...
STRIP      = strip
POSTBUILD  = fltk-config --post # Required on OSX, does nothing on other platforms, so safe to call
TARGET = CompletedFile
# Define what your target application is called
all: $(TARGET)
# Define how to build the various object files... -snip-
# Now define how to link the final app - let's assume it needs image and OpenGL support
$(TARGET): MyWindow.o main.o
$(CXX) -o $# MyWindow.o main.o $(LINKFLTK_IMG) $(LINKFLTK_GL)
$(STRIP) $#
$(POSTBUILD) $#  # only required on OSX, but call it anyway for portability
############### end #################
(Heres the object file code:)main.o: main.cpp MyWindow.h main.h
$(CXX) -c $< \
$(CXXFLAGS)
MyWindow.o: MyWindow.cpp MyWindow.h
$(CXX) -c $< \
$(CXXFLAGS)
Here is the error it gives me:
In file included from MyWindow.cpp:10:
MyWindow.h:14:20: error: GL/glu.h: No such file or directory
MyWindow.cpp: In member function ‘virtual void MyWindow::draw()’:
MyWindow.cpp:49: error: ‘gluPerspective’ was not declared in this scope
make: * [MyWindow.o] Error 1
(The code is irrelevant)
Depending on the fltk version you are using it has some of it's own openGL headers. I add the following lines to my include libraries:
-lfltk -lfltk_gl -lGL -lGLU
Overkill but it gets the job done.
The compiler can't find your GLU.h header. Adjust your #include or -I switch to point to the right location.