i have a small problem with OpenCL/OpenGL interoperability in my code
here's my makefile
LIBS = -lm -lOpenCL -lGAL -lGLEW -lglut -lGLU -lpthread
CFLAGS = -Wall -g
OBJECTS = main.o environment.o input.o animate.o buddhabrot.o buddhacl.o cmodules/timer.o
all: prognonmpi
prognonmpi: $(OBJECTS)
LIBRARY_PATH=/usr/lib/arm-linux-gnueabi/ c++ $(CFLAGS) -o prognonmpi $(OBJECTS) $(LIBS)
%.o: %.cpp $(LIBS)
clean:
rm -f *.o prog cmodules/*.o
the code just comiles fine, but i get a linker error with the following message
LIBRARY_PATH=/usr/lib/arm-linux-gnueabi/ c++ -Wall -g -o prognonmpi main.o environment.o input.o animate.o buddhabrot.o buddhacl.o cmodules/timer.o -lm -lOpenCL -lGAL -lGLEW -lglut -lGLU -lpthread
main.o: In function `displayFunc()':
main.cpp:(.text+0xdda): undefined reference to `clEnqueueAcquireGLObjects'
main.cpp:(.text+0xe12): undefined reference to `clEnqueueReleaseGLObjects'
main.o: In function `initOpenGLBuffers(int, int)':
main.cpp:(.text+0x136a): undefined reference to `clCreateFromGLBuffer'
collect2: ld returned 1 exit status
make: *** [prognonmpi] Error 1
the code compiles very fine on my notebook with the lins, using -lGL instead of -lGAL, seesm -lGAL is ARM specific.
on the ARM machine i get the above mentioned error.
Any suggestions what is missing on my ARM-machine?
using Ubuntu as OS
Related
I am trying to compile this app using its makefile on WSL. But I get the following error:
g++ -g -Wall -ansi pendulumSystem.o TimeStepper.o particleSystem.o ClothSystem.o simpleSystem.o camera.o main.o vecmath/src/Vector3f.o vecmath/src/Vector2f.o vecmath/src/Matrix3f.o vecmath/src/Matrix4f.o vecmath/src/Vector4f.o vecmath/src/Quat4f.o vecmath/src/Matrix2f.o -o a3 -L. -lRK4 -lglut -lGL -lGLU
/usr/bin/ld: ./libRK4.a(RK4.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0##CXXABI_1.3' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ./libRK4.a(RK4.o): relocation R_X86_64_PC32 against symbol `_Znwm##GLIBCXX_3.4' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:15: a3] Error 1
I tried editing my makefile to include the flag like below, but it still gives me the same error message.
INCFLAGS = -I vecmath/include
INCFLAGS += -I /usr/include/GL
LINKFLAGS = -L. -lRK4 -lglut -lGL -lGLU
CFLAGS = -g -Wall -ansi -fPIE
CC = g++
SRCS = $(wildcard *.cpp)
SRCS += $(wildcard vecmath/src/*.cpp)
OBJS = $(SRCS:.cpp=.o)
PROG = a3
all: $(SRCS) $(PROG)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $# $(LINKFLAGS)
.cpp.o:
$(CC) $(CFLAGS) $< -c -o $# $(INCFLAGS)
depend:
makedepend $(INCFLAGS) -Y $(SRCS)
clean:
rm $(OBJS) $(PROG)
Could it be that the provided libRK4.a file was not compiled with the -fPIE flag?
I am trying to receive on my PC(linux mint), a streaming from the camera of a DJI phantom 4 using OpenCV.
The example I am following is : https://developer.dji.com/guidance-sdk/documentation/tutorials/index.html (I am following the linux part)
I copied the Copy libDJI_guidance.so in /usr/local/lib and I checked, it is there.
The makefile is :
#define a compiler
CXX = g++
#define target name
TARGET = main
#define dependencies of target
OBJECTS = main.o DJI_utility.o
#define the Include and Library path
CFLAGS = -g -Wall -I/usr/local/include -I../../../include
LDFLAGS = -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 `pkg-config --cflags --libs opencv`
$(TARGET) : $(OBJECTS)
$(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
main.o : main.cpp DJI_utility.h
$(CXX) $(CFLAGS) -c main.cpp DJI_utility.h
DJI_utility.o : DJI_utility.cpp DJI_utility.h
$(CXX) $(CFLAGS) -c DJI_utility.cpp DJI_utility.h
clean:
rm -rf *.o *.gch *.avi $(TARGET)
But when i excute a make in the command line i get:
g++ -o main main.o DJI_utility.o -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 `pkg-config --cflags --libs opencv`
/usr/bin/ld: skipping incompatible /usr/local/lib//libDJI_guidance.so when searching for -lDJI_guidance
/usr/bin/ld: skipping incompatible /usr/local/lib/libDJI_guidance.so when searching for -lDJI_guidance
/usr/bin/ld: skipping incompatible //usr/local/lib/libDJI_guidance.so when searching for -lDJI_guidance
/usr/bin/ld: cannot find -lDJI_guidance
/usr/bin/ld: cannot find -lusb-1.0
collect2: error: ld returned 1 exit status
Makefile:12: recipe for target 'main' failed
make: *** [main] Error 1
The project is located in:
~/Documents/studies_SRT/SRT5/TX_drone/Guidance-SDK/demo/guidance_track
The output of an ls is:
DJI_guidance.h DJI_utility.cpp DJI_utility.h DJI_utility.h.gch DJI_utility.o main.cpp main.o Makefile
Thank you.
You seem to have downloaded library files for the wrong architecture. If you're on a 64-bit system, download the 64-bit version of the libraries.
I am developing a little program with pocketsphinx (speech to text - library).
On Windows i was using Code::Blocks as development environment and i had success to build a program.
Now i try to port my program to Linux and i am having little problems to link against pocketsphinx.
This is the Makefile:
CC = g++
CFLAGS = -Wall -std=c++11
LDFLAGS = -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx
OBJ = obj/Application.o obj/Main.o obj/Recorder.o
all: $(OBJ)
$(CC) -L/usr/local/lib -o bin/Eve $(OBJ) -s -lsphinxbase -lpocketsphinx
obj/Main.o: src/Main.cpp
$(CC) $(CFLAGS) $(LDFLAGS) -c src/Main.cpp -o obj/Main.o
obj/Application.o: src/Application.cpp src/Application.hpp
$(CC) $(CFLAGS) $(LDFLAGS) -c src/Application.cpp -o obj/Application.o
obj/Recorder.o: src/Recorder.cpp src/Recorder.hpp
$(CC) $(CFLAGS) $(LDFLAGS) -c src/Recorder.cpp -o obj/Recorder.o
It is the same which i was using on Windows, i just adjusted the file path.
I am receiving the following error:
$ make
g++ -Wall -std=c++11 -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx -c src/Application.cpp -o obj/Application.o
g++ -Wall -std=c++11 -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx -c src/Main.cpp -o obj/Main.o
g++ -Wall -std=c++11 -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx -c src/Recorder.cpp -o obj/Recorder.o
g++ -L/usr/local/lib -o bin/Eve obj/Application.o obj/Main.o obj/Recorder.o -s -lsphinxbase -lpocketsphinx
obj/Recorder.o: In function `Recorder::Recorder()':
Recorder.cpp:(.text+0x1c0): undefined reference to `ad_open_sps'
Recorder.cpp:(.text+0x20d): undefined reference to `ad_read'
Recorder.cpp:(.text+0x215): undefined reference to `cont_ad_init'
obj/Recorder.o: In function `Recorder::~Recorder()':
Recorder.cpp:(.text+0x2f3): undefined reference to `cont_ad_close'
Recorder.cpp:(.text+0x303): undefined reference to `ad_close'
obj/Recorder.o: In function `Recorder::recognizeFromMicrophone()':
Recorder.cpp:(.text+0x37a): undefined reference to `ad_start_rec'
Recorder.cpp:(.text+0x395): undefined reference to `cont_ad_calib'
Recorder.cpp:(.text+0x3f0): undefined reference to `cont_ad_read'
Recorder.cpp:(.text+0x4e6): undefined reference to `cont_ad_read'
Recorder.cpp:(.text+0x5b5): undefined reference to `ad_stop_rec'
Recorder.cpp:(.text+0x5d8): undefined reference to `ad_read'
Recorder.cpp:(.text+0x5f4): undefined reference to `cont_ad_reset'
collect2: error: ld returned 1 exit status
make: *** [all] Fehler 1
I don't think that it is a name mangling problem, since i built the lib on my own using the provided Makefile.
What can i do to link against the lib without errors?
EDIT: I figured out how to make it work. I simply modified the rule of the target "all" to this:
$(CC) -static -L/usr/local/lib -o bin/Eve $(OBJ) -s -lpocketsphinx -lsphinxbase -lsphinxad -lpthread
Functions like ad_read are defined in libsphinxad library, you need to add it to your linker command line:
g++ -static -L/usr/local/lib -o bin/Eve obj/Application.o obj/Main.o obj/Recorder.o \
-lpocketsphinx -lsphinxbase -libsphinxad
Please note that the order of libraries is important.
While compiling my project using OpenGL and wxWidgets under ubuntu 14.04, i got this error (to link the .o):
cc GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt -o GUI
/usr/bin/ld: GUI.o: référence au symbole non défini «__cxa_pure_virtual##CXXABI_1.3»
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [GUI] Erreur 1
I installed all the libraries (freeglut3, freeglut3 -dev, ...)
here is my makefile:
CXX=g++-4.8
CXXFLAGS += `wx-config --cxxflags` -std=c++11
CXXFLAGS += -g
LDLIBS += `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt
TARGETS=GUI
all:: $(TARGETS)
Fenetre.o : Fenetre.cc Fenetre.h
GUI.o : GUI.cc GUI.h
Vue_OpenGL.o : Vue_OpenGL.cc Vue_OpenGL.h
Vecteur.o: Vecteur.cc Vecteur.h
Systeme.o: Systeme.cc Systeme.h GenerateurAleatoire.h
Particule.o: Particule.cc Particule.h
GLArgon.o: GLArgon.cc GLArgon.h
GLNeon.o: GLNeon.cc GLNeon.h
Enceinte.o: Enceinte.h Enceinte.cc
GUI : GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o
You must use c++, not cc, to link the C++ programs. To do this, you need to define the recipe for linking explicitly instead of relying on the implicit one, i.e.
GUI.o: $(OBJECTS)
$(CXX) -o $# $(LDFLAGS) $(OBJECTS) $(LIBS)
I am a university student trying to setup my home desktop with Ubuntu 13.10 for OpenGL development. I have installed all of these libraries. Our first assignment was to write a simple program and a generic makefile that would work for the rest of the semester. This worked perfectly in the Computer Labs on campus.
My main.c file:
# include <GL/glut.h>
void display();
int main (int argc, char ** argv)
{
glutInit(&argc , argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowSize(640 , 480) ;
glutCreateWindow("Practical 1");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void display()
{
glClearColor(0.0 , 0.0 , 1.0 , 1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glFlush();
glutSwapBuffers();
}
And my makefile:
STUDENT_NUMBER = 1234567890
TASK = practical
NUMBER =1
OBJECTS=$(addsuffix .o,$(basename $(shell ls *.C)))
WARNING_FLAGS = -Wall -Wextra -Weffc++ -Winit -self -Wmissing -include -dirs -Wswitch -default -Wswitch -enum -Wunused -parameter -Wstrict -overflow=5 -Wfloat -equal -Wshadow -Wc++0x -compat -Wconversion -Wsign -conversion-Wmissing -declarations -Wstrict -null -sentinel -Woverloaded -virtual -Wsign -promo -Werror -pedantic -Wcast -qual
FORMATTING_FLAGS = -fno -pretty -templates -fmessage -length=80 -fdiagnostics -show -option
CFLAGS = ${WARNING_FLAGS} ${FORMATTING_FLAGS} g -std=c++0x -pipe -frepo
LDLIBS = -lGL -lglut -lGLEW -lGLU -lX11 -lXi -lm -lrt -lpng
LDFLAGS =
CC = g++
TARGET = main
all: ${OBJECTS}
${CC} ${LDFLAGS} ${LDLIBS} $^ -o ${TARGET}
%.o: %.c
${CC} ${CFLAGS} -c ${LDFLAGS} $< -o $#
makefile.dep: *.[Ch]
for i in *.C; do gcc -MM "$${i}"; done > $#
include makefile.dep
clean:
rm ${OBJECTS} *.rpo *.gch makefile.dep ${TARGET}
tar:
make clean; tar -cvjf ${STUDENT_NUMBER}_${TASK}_${NUMBER}.tar.bz2 *
When trying to compile on my home desktop I get these erors:
g++ -lGL -lglut -lGLEW -lGLU -lX11 -lXi -lm -lrt -lpng main.o -o main
main.o: In function `main':
main.C:(.text+0x1e): undefined reference to `glutInit'
main.C:(.text+0x28): undefined reference to `glutInitDisplayMode'
main.C:(.text+0x37): undefined reference to `glutInitWindowSize'
main.C:(.text+0x41): undefined reference to `glutCreateWindow'
main.C:(.text+0x4b): undefined reference to `glutDisplayFunc'
main.C:(.text+0x50): undefined reference to `glutMainLoop'
main.o: In function `display()':
main.C:(.text+0x76): undefined reference to `glClearColor'
main.C:(.text+0x80): undefined reference to `glClear'
main.C:(.text+0x85): undefined reference to `glFlush'
main.C:(.text+0x8a): undefined reference to `glutSwapBuffers'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
I think I might be missing some library or something.
As explained in this question, you need to specify the dependant libraries in after the objects that reference them in your linker command:
g++ main.o -lGL -lglut -lGLEW -lGLU -lX11 -lXi -lm -lrt -lpng -o main
I'm not an expert on makefile syntax, but I think changing the 'all' section of your makefile like this might work:
all: ${OBJECTS}
${CC} ${LDFLAGS} $^ ${LDLIBS} -o ${TARGET}