Undefined reference with OpenSSL - c++

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 :)

Related

Can't compile qt project with static lib curl

I am trying to compile a qt project with qtcurl using a statically built curl.
I am using the following to build a minimalist curl static library:
./configure --disable-shared --enable-static --prefix=/tmp/curl --disable-ldap --disable-sspi --without-librtmp --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb --without-libidn --enable-ares
I am including
-L/tmp/curl/lib/libcurl.a
in the LIBS of the project, and
/tmp/curl/include
in the INCLUDEPATH
This is the output that I am getting:
QtCUrl.o: In function `QtCUrl::QtCUrl()':
QtCUrl.cpp:(.text+0x10d): undefined reference to `curl_easy_init'
QtCUrl.o: In function `QtCUrl::~QtCUrl()':
QtCUrl.cpp:(.text+0x32e): undefined reference to `curl_slist_free_all'
QtCUrl.cpp:(.text+0x355): undefined reference to `curl_easy_cleanup'
QtCUrl.o: In function `QtCUrl::setOptions(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0xcee): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xdac): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xee9): undefined reference to `curl_slist_append'
QtCUrl.cpp:(.text+0xfe5): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1078): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x109f): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1155): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1290): undefined reference to `curl_easy_setopt'
QtCUrl.o: In function `QtCUrl::exec(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0x1f27): undefined reference to `curl_easy_perform'
QtCUrl.o: In function `curlGlobalInit()':
QtCUrl.cpp:(.text+0xa6): undefined reference to `curl_global_init'
collect2: error: ld returned 1 exit status
What am I missing here?

Can't get a Fast Artificial Neural Net (FANN) project to make. It gives undefined references when certain code is used

I have been having trouble with the Fast Artificial Neural Network (FANN) library. I can't seem to get it completely working on my system. I think I am missing some dependency, but I can't seem to figure out how to fix it.
I am on Ubuntu, but I decided to clone the repository from GitHub rather than use apt-get. I cloned to the directory /home/lucas/includes/fann and from that directory I performed cmake ., and finally sudo make install like instructed at the GitHub readme.
Some parts of the library work, but some crash. Here is my example file:
#include <iostream>
#include <fann.h>
#include <fann_cpp.h>
using namespace std;
using namespace FANN;
int main(int argc, char** argv) {
fann_type** input_data;
//training_data training_data;
return 0;
}
Here is my CMake file:
cmake_minimum_required(VERSION 2.8.4)
project(FANN_sin)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(/usr/local/include/)
include_directories(/usr/local/lib/)
set(SOURCE_FILES main.cpp)
add_executable(FANN_sin ${SOURCE_FILES})
target_link_libraries(FANN_sin /usr/local/lib/libfann.a)
When I run the code with the training_data training_data commented out, it compiles and runs. However, when I try to run with that part uncommented, the project won't make.
Here are the errors:
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_batch_parallel._omp_fn.1':
floatfann.c:(.text+0x20): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0x28): undefined reference to `omp_get_thread_num'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_irpropm_parallel._omp_fn.3':
floatfann.c:(.text+0x116): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0x11e): undefined reference to `omp_get_thread_num'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_quickprop_parallel._omp_fn.5':
floatfann.c:(.text+0x304): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0x30c): undefined reference to `omp_get_thread_num'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_sarprop_parallel._omp_fn.7':
floatfann.c:(.text+0x592): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0x59a): undefined reference to `omp_get_thread_num'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_batch_parallel._omp_fn.0':
floatfann.c:(.text+0xf375): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0xf37d): undefined reference to `omp_get_thread_num'
floatfann.c:(.text+0xf3dd): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_irpropm_parallel._omp_fn.2':
floatfann.c:(.text+0xf4c5): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0xf4cd): undefined reference to `omp_get_thread_num'
floatfann.c:(.text+0xf52d): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_quickprop_parallel._omp_fn.4':
floatfann.c:(.text+0xf615): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0xf61d): undefined reference to `omp_get_thread_num'
floatfann.c:(.text+0xf67d): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_sarprop_parallel._omp_fn.6':
floatfann.c:(.text+0xf765): undefined reference to `omp_get_num_threads'
floatfann.c:(.text+0xf76d): undefined reference to `omp_get_thread_num'
floatfann.c:(.text+0xf7cd): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_batch_parallel':
floatfann.c:(.text+0x13a9a): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x13aa1): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x13ac5): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x13ad4): undefined reference to `GOMP_parallel_end'
floatfann.c:(.text+0x13b09): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x13b10): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x13b48): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x13b57): undefined reference to `GOMP_parallel_end'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_irpropm_parallel':
floatfann.c:(.text+0x13e6d): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x13e74): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x13e98): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x13ea7): undefined reference to `GOMP_parallel_end'
floatfann.c:(.text+0x13f09): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x13f10): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x13f79): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x13f88): undefined reference to `GOMP_parallel_end'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_quickprop_parallel':
floatfann.c:(.text+0x142ad): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x142b4): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x142d8): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x142e7): undefined reference to `GOMP_parallel_end'
floatfann.c:(.text+0x14355): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x1435c): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x143dd): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x143ec): undefined reference to `GOMP_parallel_end'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_sarprop_parallel':
floatfann.c:(.text+0x1470d): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x14714): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x14738): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x14747): undefined reference to `GOMP_parallel_end'
floatfann.c:(.text+0x1483d): undefined reference to `omp_set_dynamic'
floatfann.c:(.text+0x14844): undefined reference to `omp_set_num_threads'
floatfann.c:(.text+0x1492a): undefined reference to `GOMP_parallel_start'
floatfann.c:(.text+0x14939): undefined reference to `GOMP_parallel_end'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_batch_parallel._omp_fn.0':
floatfann.c:(.text+0xf4a4): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_irpropm_parallel._omp_fn.2':
floatfann.c:(.text+0xf5f4): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_quickprop_parallel._omp_fn.4':
floatfann.c:(.text+0xf744): undefined reference to `GOMP_barrier'
/usr/local/lib/libfann.a(floatfann.c.o): In function `fann_train_epoch_sarprop_parallel._omp_fn.6':
floatfann.c:(.text+0xf894): undefined reference to `GOMP_barrier'
collect2: error: ld returned 1 exit status
make[2]: *** [FANN_sin] Error 1
make[1]: *** [CMakeFiles/FANN_sin.dir/all] Error 2
make: *** [all] Error 2
I researched the errors, and I assume they are referring GOMP, an OpenMP implementation for GCC. I currently have GCC version 4.8.4. I have the support library package libgomp1 from apt-get installed also, so I'm not sure what the problem is.
Did I miss something? Thanks.

linker error while building roborobo using SDL

I'm using robo robo simulator. It requires SDL to be installed. SDL was successfully installed using sudo apt-get install in Ubuntu
'make' was used to compile and link.
compilation was successful but while linking I got the following linker errors
[LD] roborobo
src/core/roborobo.o: In function `clean_up()':
roborobo.cpp:(.text+0x29): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x35): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x41): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x4d): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x59): undefined reference to `SDL_FreeSurface'
src/core/roborobo.o:roborobo.cpp:(.text+0x6a): more undefined references to `SDL_FreeSurface' follow
src/core/roborobo.o: In function `checkQuitEvent()':
roborobo.cpp:(.text+0xdff): undefined reference to `SDL_PollEvent'
src/core/roborobo.o: In function `handleKeyEvent(unsigned char*)':
roborobo.cpp:(.text+0xead): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0xf1a): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0xf43): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0x1037): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0x111e): undefined reference to `SDL_Delay'
src/core/roborobo.o:roborobo.cpp:(.text+0x1191): more undefined references to `SDL_Delay' follow
and many more
SDL_gfxPrimitives.c:(.text+0x7477): undefined reference to `SDL_UnlockSurface'
SDL_gfxPrimitives.c:(.text+0x7491): undefined reference to `SDL_UpperBlit'
SDL_gfxPrimitives.c:(.text+0x74e6): undefined reference to `SDL_CreateRGBSurface'
collect2: error: ld returned 1 exit status
make: [roborobo] Error 1 (ignored)
the make file also has sdl-config --cflags --libs -lSDL_image
the Makefile is in http://pastebin.com/5EdcZWAd
the entire console output after 'make' is in http://pastebin.com/yXDHR9xw

synergy won't compile -- undefined reference to `pthread_xxxx

When following the build instructions for Synergy, I get the following errors.
Is there an already-developed solution to get Synergy to build?
If not, how do I get Synergy to compile on Ubuntu 13.10?
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::newMutex()':
CArchMultithreadPosix.cpp:(.text+0x319): undefined reference to `pthread_mutexattr_init'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::raiseSignal(IArchMultithread::ESignal)':
CArchMultithreadPosix.cpp:(.text+0x43b): undefined reference to `pthread_kill'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::threadSignalHandler(void*)':
CArchMultithreadPosix.cpp:(.text+0x490): undefined reference to `pthread_detach'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::closeThread(CArchThreadImpl*)':
CArchMultithreadPosix.cpp:(.text+0x62b): undefined reference to `pthread_detach'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::newThread(void* (*)(void*), void*)':
CArchMultithreadPosix.cpp:(.text+0x8e6): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x90f): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x935): undefined reference to `pthread_create'
CArchMultithreadPosix.cpp:(.text+0x9a4): undefined reference to `pthread_create'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::CArchMultithreadPosix()':
CArchMultithreadPosix.cpp:(.text+0xe11): undefined reference to `pthread_mutexattr_init'
CArchMultithreadPosix.cpp:(.text+0xf05): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0xf26): undefined reference to `pthread_sigmask'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::startSignalHandler()':
CArchMultithreadPosix.cpp:(.text+0x10a8): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x10cd): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x1104): undefined reference to `pthread_create'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::cancelThread(CArchThreadImpl*)':
CArchMultithreadPosix.cpp:(.text+0x5e3): undefined reference to `pthread_kill'
collect2: error: ld returned 1 exit status
make[2]: *** [../../bin/synergyd] Error 1
make[1]: *** [src/cmd/synergyd/CMakeFiles/synergyd.dir/all] Error 2
make: *** [all] Error 2
Going back to: /usr/local/src/synergy-1.4.15-Source
Error: make failed: 512
SOLUTION: manually change the order of the contents of /synergy-1.4.15-Source/src/cmd/synergyd/CMakeFiles/synergyd.dir/link.txt to put -lpthread contents last.
You'd rather edit the CMakelists.txt file to add pthread at the end of the target_link_libraries command.
You may also add link_libraries(pthread).

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

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.