Compiling openGL with GLFW3 program in Ubuntu 15.10 [duplicate] - c++

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 years ago.
I tried building GLFW3 under Ubuntu 15.10 using the tutorial here, and while that seems successful, I can't compile a sample program (provided by GLFW) using the command:
g++ test.cpp -lglfw3 -lGL
I get the following error.
/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_window.c.o): undefined reference to symbol 'XConvertSelection'
/usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I tried including a bunch of different files in the linker, but thes two I have now took away all the other errors except these. I also read that the DSO missing error might indicate the wrong order of linked files, but changing the order doesn't help here. Probably missing some include, but no idea which. If anyone can help, it'd be greatly appreciate. I'm quite new to Linux, so this is beyond my current skills.

You need to get the packages. Run in the right order.
pkg-config --static --libs x11 xrandr xi xxf86vm glew glfw3

Related

undefined reference to 'IMG_Load' and 'IMG_Init' [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 9 months ago.
I've been trying to figure out why those functions are undefined. I have been looking for hours trying to find a solution and haven't found any that worked. The closest one told me to download an earlier version of SDL_image, which worked but then told me SDL.dll was missing, insisting that I would need to use an older version of SDL.
Exact error message:
This is what my Makefile looks like:
g++ main.cpp -Isrc/include -Isrc/include/SDL2 -Iinclude/headers -Lsrc/lib -g -o main -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
This is what my lib folder looks like:
And yes, the include folder does have SDL_image.h
Additional question, I want to put all my .dll files in a bin folder but I don't know what is telling what, where to look for them so I have them all in the src directory:
Whoever comes across this error use the VC development libraries instead of the one for MinGW. For a reason I am not aware of it works.

Compiling: libm.so.6: error adding symbols: DSO missing, already included -lm

I try to compile a library, which works fine on a cluster. However, when I try to compile it locally on my private laptop I get the following error:
/usr/bin/ld: CMakeFiles/zfs.dir/zfsstrctrdblck3d.cpp.o: undefined reference to symbol 'tanhl##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing
So, what I've tried is to google (obviously) and I've found that I have to include -lm flag when compiling with gcc or respectively mpicc. I tried several positions of the flag, but none of them could fix the error. What else can cause this error?
My mpicc version is:
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Thanks in advance,
Max

C++ compile error. G++ gnu [duplicate]

This question already has answers here:
Can I get Unix's pthread.h to compile in Windows?
(5 answers)
Closed 6 years ago.
Hi I am having some issues with my c++ program. I am using g++ gnu and it is on windows 10. here is the error that is showing up:
ld.exe: cannot find -lpthread
collect2.exe: error: ld returned 1 exit status
please help because i can not work out what is going on.
Thanks,
Asher
That is a linker error. Not a compiler error.
It is complaining that it cannot find the pthread library in the library search path. Either it simply isn't there or you need to indicate where it is with the -L option. Or, in case pthread is not needed, remove the -lpthread option so you don't attempt to link to it.

Trying to run OpenGL on Linux, have the necessary libraries but won't run? (C++) [duplicate]

This question already has answers here:
Linker error : undefined reference to symbol 'glOrtho'
(2 answers)
Closed 8 years ago.
I am new to Linux and am currently using Linux Mint. I followed the instructions on this page, however whenever I go to compile the example code (given on the web page), the build fails.
g++ ~/Desktop/test.cpp -lglut gives me the following:
/usr/bin/ld: /tmp/cc3aKYsD.o: undefined reference to symbol 'glOrtho'
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Why does this keep occurring? I apologize for such a beginner question, but this is irritating.
You need to link with the OpenGL library as well:
g++ ~/Desktop/test.cpp -lglut -lGL

Linker error: undefined reference to symbol 'pthread_rwlock_trywrlock##GLIBC_2.2.5'

I've been developing with CentOS, Qt 4.7, and GCC 4.4
I've just installed Red Hat Developer Toolset 1.1 which includes GCC 4.7.2, and at the end of make, I get an error
/usr/bin/ld: ../../bin/Solo: undefined reference to symbol 'pthread_rwlock_trywrlock##GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_rwlock_trywrlock##GLIBC_2.2.5' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
I'm guessing that Qt threads is referencing to that. How can I fix it?
You want to compile with -pthread which does more than just link with libpthread:
Adds support for multithreading with the pthreads library. This
option sets flags for both the preprocessor and linker.
You just need to add CONFIG += thread to your .pro file.
Read the note: try to add /lib64/libpthread.so.0 into Makefile (-lpthread after gcc command, or /lib64/libpthread.so.0 after ld (or after gcc -shared)), or something like LIB += -lpthread if there's such definition somewhere.
See also: Adding external library into Qt Creator project and http://www.qtcentre.org/threads/39144-How-to-add-a-lib-to-a-qt-project
Btw, post your Makefile, so somebody will be able to point to exact line.
In my little laptop Linux (where I have a mixed bag of libraries),
I just had to add
LDFLAGS=-lpthread
AT THE END of the configure command arguments.
After that, make did its job perfectly (With the existing libraries).
I received similar 'Linker error: undefined reference to symbol' errors attempting to compile and install Python-3.7.2 on FreeBSD 12.
/usr/bin/ld: error: undefined symbol: _Py_GetGlobalVariablesAsDict
/usr/bin/ld: error: undefined symbol: _PyCoreConfig_AsDict
/usr/bin/ld: error: undefined symbol: _PyMainInterpreterConfig_AsDict
Resolved by passing LDFLAGS=-lpthread directly to make of lang/python37 or by adding to /etc/make.conf.
If using portmaster to install/update use -m to pass the arguement to make e.g.portmaster -a -m 'LDFLAGS=-lpthread'