Issues with OpenGL referencing when compiling in Ubuntu terminal [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on compiling a directory of c++ files and headers. I thought that I installed openGL, Glut and Glew properly but I keep getting referencing errors when running it.
Here is what I am doing and the errors that the compiler is sending back to me:
user#Linux-machine:~/Documents/HW$ make
g++ -g framework.o poly_line.o shader_program.o circle.o controller.o main.o scene.o view.o -lGLEW -lglut -lGLU -o HW
framework.cpp:84: error: undefined reference to 'glGetError'
check_gl.h:30: error: undefined reference to 'glGetError'
check_gl.h:43: error: undefined reference to 'glGetError'
poly_line.cpp:23: error: undefined reference to 'glGenBuffers'
poly_line.cpp:28: error: undefined reference to 'glBindBuffer'
poly_line.cpp:29: error: undefined reference to 'glBufferData'
poly_line.cpp:54: error: undefined reference to 'glEnable'
poly_line.cpp:55: error: undefined reference to 'glEnable'
poly_line.cpp:56: error: undefined reference to 'glBlendFunc'
poly_line.cpp:57: error: undefined reference to 'glHint'
poly_line.cpp:59: error: undefined reference to 'glDisable'
poly_line.cpp:60: error: undefined reference to 'glDisable'
poly_line.cpp:68: error: undefined reference to 'glBindBuffer'
poly_line.cpp:69: error: undefined reference to 'glEnableVertexAttribArray'
poly_line.cpp:70: error: undefined reference to 'glVertexAttribPointer'
poly_line.cpp:78: error: undefined reference to 'glDrawArrays'
poly_line.cpp:80: error: undefined reference to 'glDrawArrays'
shader_program.cpp:104: error: undefined reference to 'glCreateProgram'
shader_program.cpp:113: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:115: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:120: error: undefined reference to 'glGetProgramInfoLog'
shader_program.cpp:135: error: undefined reference to 'glGetShaderiv'
shader_program.cpp:137: error: undefined reference to 'glGetShaderiv'
shader_program.cpp:142: error: undefined reference to 'glGetShaderInfoLog'
shader_program.cpp:155: error: undefined reference to 'glDeleteShader'
shader_program.cpp:163: error: undefined reference to 'glDeleteShader'
shader_program.cpp:185: error: undefined reference to 'glCreateShader'
shader_program.cpp:195: error: undefined reference to 'glShaderSource'
shader_program.cpp:200: error: undefined reference to 'glCompileShader'
shader_program.cpp:214: error: undefined reference to 'glAttachShader'
shader_program.cpp:219: error: undefined reference to 'glLinkProgram'
shader_program.cpp:238: error: undefined reference to 'glUseProgram'
shader_program.cpp:249: error: undefined reference to 'glUniform1f'
shader_program.cpp:257: error: undefined reference to 'glUniform1i'
shader_program.cpp:270: error: undefined reference to 'glGetUniformLocation'
shader_program.cpp:290: error: undefined reference to 'glUseProgram'
shader_program.cpp:304: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:308: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:315: error: undefined reference to 'glGetActiveUniform'
view.cpp:28: error: undefined reference to 'glClearColor'
view.cpp:29: error: undefined reference to 'glClear'
collect2: error: ld returned 1 exit status
make: *** [HW] Error 1

You have linked to everything but the kitchen sink in this example, but forgot about the OpenGL library itself.
Add GL to the list of libraries in your Makefile. Also, make sure that you link against it last.

Related

Undefined reference with OpenSSL

Hello I am trying to link against openssl.
This is the compiler: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
I am passing -lssl and -lcrypto to the linker as well.
However, I am getting the below error.
external/openssl/libssl.a(libssl-lib-ssl_lib.o):ssl_lib.c:function SSL_CTX_set_default_verify_store: error: undefined reference to 'X509_LOOKUP_store'
external/openssl/libssl.a(libssl-lib-ssl_lib.o):ssl_lib.c:function ssl_validate_ct: error: undefined reference to 'CT_POLICY_EVAL_CTX_new_ex'
external/openssl/libssl.a(libssl-lib-ssl_lib.o):ssl_lib.c:function SSL_CTX_set_default_verify_paths: error: undefined reference to 'X509_STORE_set_default_paths_ex'
external/openssl/libssl.a(libssl-lib-ssl_lib.o):ssl_lib.c:function SSL_CTX_load_verify_file: error: undefined reference to 'X509_STORE_load_file_ex'
external/openssl/libssl.a(libssl-lib-ssl_lib.o):ssl_lib.c:function SSL_CTX_load_verify_dir: error: undefined reference to 'X509_STORE_load_path'
external/openssl/libssl.a(libssl-lib-ssl_lib.o):ssl_lib.c:function SSL_CTX_load_verify_store: error: undefined reference to 'X509_STORE_load_store_ex'
external/openssl/libssl.a(libssl-lib-tls_srp.o):tls_srp.c:function SSL_srp_server_param_with_username: error: undefined reference to 'SRP_Calc_B_ex'
external/openssl/libssl.a(libssl-lib-tls_srp.o):tls_srp.c:function SSL_set_srp_server_param_pw: error: undefined reference to 'SRP_create_verifier_BN_ex'
external/openssl/libssl.a(libssl-lib-tls_srp.o):tls_srp.c:function srp_generate_server_master_secret: error: undefined reference to 'SRP_Calc_u_ex'
external/openssl/libssl.a(libssl-lib-tls_srp.o):tls_srp.c:function srp_generate_client_master_secret: error: undefined reference to 'SRP_Calc_u_ex'
external/openssl/libssl.a(libssl-lib-tls_srp.o):tls_srp.c:function srp_generate_client_master_secret: error: undefined reference to 'SRP_Calc_x_ex'
external/openssl/libssl.a(libssl-lib-tls_srp.o):tls_srp.c:function srp_generate_client_master_secret: error: undefined reference to 'SRP_Calc_client_key_ex'
external/openssl/libssl.a(libssl-lib-ssl_conf.o):ssl_conf.c:function cmd_ChainCAPath: error: undefined reference to 'X509_STORE_load_path'
external/openssl/libssl.a(libssl-lib-ssl_conf.o):ssl_conf.c:function cmd_VerifyCAFile: error: undefined reference to 'X509_STORE_load_file_ex'
external/openssl/libssl.a(libssl-lib-ssl_conf.o):ssl_conf.c:function cmd_VerifyCAPath: error: undefined reference to 'X509_STORE_load_path'
external/openssl/libssl.a(libssl-lib-ssl_conf.o):ssl_conf.c:function cmd_ChainCAStore: error: undefined reference to 'X509_STORE_load_store_ex'
external/openssl/libssl.a(libssl-lib-ssl_conf.o):ssl_conf.c:function cmd_VerifyCAStore: error: undefined reference to 'X509_STORE_load_store_ex'
external/openssl/libssl.a(libssl-lib-ssl_conf.o):ssl_conf.c:function cmd_ChainCAFile: error: undefined reference to 'X509_STORE_load_file_ex'
Ok so I just had to download the latest stable branch and build from source :)

upgrade libc from 2.21 to 2.28 gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf cross compiler

I am using gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf on my ubuntu system using NetBeans IDE. My cross compiler is having libc-2.21 where as some of the libraries requires libc-2.28.And my target machine(debian jessie) do have libc-2.28 .
How can I upgrade it?
This is the error message I am getting after compiling in Netbeans:
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavutil.so.56: undefined reference to 'fcntl64#GLIBC_2.28'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libsystemd.so.0: undefined reference to 'getrandom#GLIBC_2.25'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libbellesip.so.0: undefined reference to 'fcntl#GLIBC_2.28'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavcodec.so.58: undefined reference to 'powf#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libsystemd.so.0: undefined reference to 'reallocarray#GLIBC_2.26'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libmediastreamer_voip.so.10: undefined reference to 'expf#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libpulsecommon-12.2.so: undefined reference to 'memfd_create#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavcodec.so.58: undefined reference to 'exp2f#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavcodec.so.58: undefined reference to 'log2f#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libortp.so.13: undefined reference to 'logf#GLIBC_2.27'
collect2: error: ld returned 1 exit status

qt error: undefined reference to `str2ba'

I am new to qt. I am using qt creator successfully to create ui. I need bluetooth functionality from qt. I had earlier version of code running through terminal. I copy pasted the running code. I get a lot of undefined references.
error: undefined reference to str2ba'
error: undefined reference tosqlite3_open'
error: undefined reference to sqlite3_errmsg'
error: undefined reference tosqlite3_errmsg'
error: undefined reference to sqlite3_free'
error: undefined reference tosqlite3_close'
error: undefined reference to hci_get_route'
error: undefined reference tohci_open_dev'
error: undefined reference to hci_inquiry'
error: undefined reference toba2str'
error: undefined reference to hci_read_remote_name'
error: undefined reference toba2str'
Is there anything like linux apis can not be used in qt? how to integrate the app then? Or do I have to link libraries like -lpthread -lbluetooth etc.
"Undefined reference..." seems to be a linker error.
Do you link against libsqlite3 and libbluetooth?
Adding
-lsqplite3 -lbluetooth
to your ld/g++ command line helps in that case

C-Python compilation error

I am trying to embed python in c++. I am not able to compile some c++ code that uses Python.h. I get an error that seems to be the library is not referenced correctly.
Below is the error shown which I received:
/tmp/ccxiQ8eE.o:(.data+0xc4): undefined reference to Py_NoopCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0xd4): undefined reference toPy_FilterPalletteCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0xe4): undefined reference to Py_FilterCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0xf4): undefined reference toPy_CaptureCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x104): undefined reference to Py_CaptureBufferCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x114): undefined reference toPy_StreamCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1b4): undefined reference to Py_ModelDebugCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1c4): undefined reference toPy_ModelVersionCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1d4): undefined reference to Py_ModelSimRunCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1e4): undefined reference toPy_ModelSimEndCmd(_object*, _object*)'
collect2: error: ld returned 1 exit status
make: *** [xgs_sim.linux] Error 1
For these functions prototype declaration has been done in some other test.h file and that file has been included while compiling in the program.cc file.
The function definition has been done in test.cc file.
Python version used is python 2.7.1.
Any help/guidelines will be much appreciated. Thanks.

Undefined reference in g++ linking

Every time I make a new module and try to link it to my main class (Estudiant.o) using this line:
g++ -o red1.exe red1.o %OBJETOS_CPP%\Estudiant.o
I get this error:
red1.o:red1.cpp:(.text+0xd): undefined reference to
Estudiant::consultar_DNI() const' red1.o:red1.cpp:(.text+0x18):
undefined reference toEstudiant::Estudiant(int)'
red1.o:red1.cpp:(.text+0x25): undefined reference to
Estudiant::consultar_nota() const' red1.o:red1.cpp:(.text+0x74):
undefined reference toEstudiant::afegir_nota(double)'
red1.o:red1.cpp:(.text+0x83): undefined reference to
Estudiant::~Estudiant()' red1.o:red1.cpp:(.text+0xa3): undefined
reference toEstudiant::consultar_nota() const'
red1.o:red1.cpp:(.text+0xe5): undefined reference to
Estudiant::modificar_nota(double)' red1.o:red1.cpp:(.text+0x10b):
undefined reference toEstudiant::Estudiant()'
red1.o:red1.cpp:(.text+0x13a): undefined reference to
Estudiant::llegir_estudiant()' red1.o:red1.cpp:(.text+0x144):
undefined reference toEstudiant::te_nota() const'
red1.o:red1.cpp:(.text+0x182): undefined reference to
Estudiant::escriure_estudiant() const' red1.o:red1.cpp:(.text+0x18c):
undefined reference toEstudiant::~Estudiant()'
red1.o:red1.cpp:(.text+0x19f): undefined reference to
Estudiant::~Estudiant()'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
red1.o: bad reloc address 0x0 in section.ctors' collect2.exe: error:
ld returned 1 exit status
And I don't have the original Estudiant.cpp so I thought it might be because different compilers were used for compiling and for the link, but I reinstalled MinGW and I'm still getting this error.
I also tried to replace all the files and it didn't work.
I managed to get the source code of the Estudiant.o and compiled another version of it using the code and it worked. I don't know why the same code was compiled on two different machines and one worked and the other one didn't.