How to compile DPDK application such as examples to support C++? - 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

Related

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.

How to solve compile error in gRPC generated files?

I am creating client-server application, using gRPC. So far I was not using TLS encryption. Now I want to enable it, and strangely I get this error. It seems, at least to me, that this is a linker error. What would be best ways to solve it?
CLion doesn't highlight anything, so I assumed everything was syntactically OK, but when compiling I got that error.
/usr/bin/ld: CMakeFiles/projectname.dir/main.cpp.o: in function `grpc::SslServerCredentials(grpc::SslServerCredentialsOptions const&)':
/home/username/projectname/third_party/grpc/include/grpcpp/security/server_credentials.h:60: undefined reference to `grpc_impl::SslServerCredentials(grpc::SslServerCredentialsOptions const&)'
collect2: error: ld returned 1 exit status
This is a makefile that I use to generate C++ code from gRPC specification:
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
SYSTEM ?= $(HOST_SYSTEM)
CXX = g++
CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++11
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\
-lgrpc++_reflection\
-ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl
endif
PROTOC = protoc
GRPC_CPP_PLUGIN = grpc_cpp_plugin
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
PROTOS_PATH = ./
vpath %.proto $(PROTOS_PATH)
%.grpc.pb.cc: %.proto
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
%.pb.cc: %.proto
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=. $<
clean:
rm -f *.o *.pb.cc *.pb.h
Then problem was solved like this:
I had to chage grpc++_unsecure to grpc++ under target_link_libraries in CMakeLists.txt cmake build configuration file.
I had forgotten/not thought about this at first.
target_link_libraries(bita_server
pqxx
sodium
protobuf::libprotobuf
# grpc++_unsecure
grpc++
SQLiteCpp
sqlite3
pthread
dl
${_PROTOBUF_LIBPROTOBUF}
)
In CMakeLists.txt under grpc folder, there are many target_link_libraries. which one to edit in order to include the change.

Issue Linking Box2D application on OS X

I have an SDL game I have been working on as my first somewhat real project. I decided to introduce Box2D physics as I was not happy with the collision detection. So I installed it to /usr/local/lib/Box2D and in the folder is Box2D.h and supporting folders. I am using MacVim to code on OSX 10.9.2 to develop, and clang++ compiler from the command line.
In my game code I am just trying to create a simple world to test things out:
#include <Box2D/Box2D.h>
.......
world = new b2World(b2Vec2(0.0,9.81));
My make command finds the library, but errors out trying to build.
$ make clean && make
rm -rf obj bin
clang++ -Wall -c -std=c++11 -I/usr/local/lib src/Ball.cpp -o obj/Ball.o
clang++ -Wall -c -std=c++11 -I/usr/local/lib src/Game.cpp -o obj/Game.o
clang++ -Wall -c -std=c++11 -I/usr/local/lib src/Paddle.cpp -o obj/Paddle.o
clang++ -Wall -c -std=c++11 -I/usr/local/lib src/TextureManager.cpp -o obj/TextureManager.o
clang++ -Wall -c -std=c++11 -I/usr/local/lib src/main.cpp -o obj/main.o
clang++ -framework SDL2 -framework SDL2_image -F /Library/Frameworks -L/usr/local/lib/Box2D obj/Ball.o obj/Game.o obj/Paddle.o obj/TextureManager.o obj/main.o -o bin/game
Undefined symbols for architecture x86_64:
"b2World::b2World(b2Vec2 const&)", referenced from:
Game::init() in Game.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [game] Error 1
And here is my Makefile. Box2D is in /usr/local/lib/Box2D/Box2D.h. I am pretty sure my issue is somewhere in the Makefile.
CXX = clang++
CXXFLAGS = -Wall -c -std=c++11 -I/usr/local/lib
SDL = -framework SDL2 -framework SDL2_image
LDFLAGS = $(SDL) -F /Library/Frameworks -L/usr/local/lib/Box2D
SRC_DIR = src
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
OBJ_DIR = obj
OBJECTS = $(subst $(SRC_DIR)/, $(OBJ_DIR)/, $(patsubst %.cpp, %.o, $(SOURCES)))
#$(warning $(OBJECTS))
BIN_DIR = bin
EXE = game
# run these no matter what
.PHONY: all clean run
all: $(EXE)
$(EXE): $(OBJECTS)
#mkdir -p $(BIN_DIR)
$(CXX) $(LDFLAGS) $(OBJECTS) -o $(BIN_DIR)/$(EXE)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
#mkdir -p $(OBJ_DIR)
$(CXX) $(CXXFLAGS) $< -o $#
clean:
rm -rf obj bin
run:
./$(BIN_DIR)/$(EXE)
It does not appear that you ever actually link the Box2D library anywhere? You use -L to specify directories to search while linking, but I don't see a -l option to actually link the Box2D library (whatever it's called).
Your output line seems to bear this out:
clang++ -framework SDL2 -framework SDL2_image -F /Library/Frameworks -L/usr/local/lib/Box2D obj/Ball.o obj/Game.o obj/Paddle.o obj/TextureManager.o obj/main.o -o bin/game
You need to get -lbox2d (or whatever the correct name for the Box2D library is) in there.

Rendering using OpenSG

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

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.