I am trying to compile libcvd to use PTAM. When I get to the command "make" while compiling it gives me following error:
ln -s libcvd.so.0.7 libcvd.so.0
ln -s libcvd.so.0 libcvd.so
g++ -o progs/se3_exp progs/se3_exp.o -L. -lcvd -ltiff -ljpeg -lpng -llapack -lGLU -lGL -ldc1394 -L -lX11 -lXext -pthread
./libcvd.so: error: undefined reference to 'XQueryPointer'
./libcvd.so: error: undefined reference to 'XPending'
./libcvd.so: error: undefined reference to 'XNextEvent'
./libcvd.so: error: undefined reference to 'XFlush'
./libcvd.so: error: undefined reference to 'XSelectInput'
./libcvd.so: error: undefined reference to 'XStoreName'
./libcvd.so: error: undefined reference to 'XUnmapWindow'
./libcvd.so: error: undefined reference to 'XDestroyWindow'
./libcvd.so: error: undefined reference to 'XCloseDisplay'
./libcvd.so: error: undefined reference to 'XOpenDisplay'
./libcvd.so: error: undefined reference to 'XCreateColormap'
./libcvd.so: error: undefined reference to 'XCreateWindow'
./libcvd.so: error: undefined reference to 'XMapWindow'
./libcvd.so: error: undefined reference to 'XDefineCursor'
./libcvd.so: error: undefined reference to 'XUndefineCursor'
./libcvd.so: error: undefined reference to 'XWarpPointer'
./libcvd.so: error: undefined reference to 'XMoveWindow'
./libcvd.so: error: undefined reference to 'XResizeWindow'
./libcvd.so: error: undefined reference to 'XGetWindowAttributes'
./libcvd.so: error: undefined reference to 'XSetClassHint'
./libcvd.so: error: undefined reference to 'XInternAtom'
./libcvd.so: error: undefined reference to 'XSetWMProtocols'
./libcvd.so: error: undefined reference to 'XLoadQueryFont'
./libcvd.so: error: undefined reference to 'XCreateGlyphCursor'
./libcvd.so: error: undefined reference to 'XFreeFont'
./libcvd.so: error: undefined reference to 'XLookupString'
collect2: ld returned 1 exit status
make: *** [progs/se3_exp] Error 1
I could not find any appropriate solution to this error.
Thank you for your helping.
I found the solution,
In the makefile change the order of the library references in this order:
LOADLIBES = -lX11 -ltiff -ljpeg -lpng -llapack -lGLU -lGL -ldc1394 -L -lXext -pthread
I did two things.
First, I added an extra -lX11 in the following places. The new lines look like this -
thirdparty/libcvd/installfiles/configure: LIBS="-lX11 -lX11 $LIBS"
thirdparty/libcvd/installfiles/configure: LIBS="$LIBS -L$x_libraries -lX11 -lX11 -lXext"
thirdparty/libcvd/installfiles/configure.in: APPEND(LIBS, [-L$x_libraries -lX11 -lX11 -lXext])
Next, I followed this answer of installing all 3 mentioned below (note: you need to install liblapack-dev as well. I had just liblapack3 installed but needed dev as well).
https://stackoverflow.com/a/21432657/771650
Your problem is here:
g++ -o progs/se3_exp progs/se3_exp.o -L. -lcvd [...] -ldc1394 -L -lX11 -lXext -pthread
Unlike the first -L., the second library path (-L) option has no path argument after it, so it steals whatever comes next to use as an (unlikely!) path. To really fix this problem, you need to look at your Makefile's LOADLIBES definition and figure out how this incomplete -L option is getting into it. Most likely, the Makefile has ...-L$(SOME_PATH)... or similar, and the SOME_PATH variable is unexpectedly empty.
Related
I am running an OpenGL C++ file with fragment and vertex files.
I am on Ubuntu 18.04.
The problem is that when I link with g++ command I get errors :
my first linking command was :
g++ -o proj prog.cpp -lGL -lm
and I am getting these errors :
/tmp/ccdaDttM.o: In function `main':
prog.cpp:(.text+0x18): undefined reference to `glfwInit'
prog.cpp:(.text+0x27): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x36): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x45): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x54): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x63): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x84): undefined reference to `glfwCreateWindow'
prog.cpp:(.text+0x9f): undefined reference to `glfwGetFramebufferSize'
prog.cpp:(.text+0xd3): undefined reference to `glfwTerminate'
prog.cpp:(.text+0xe9): undefined reference to `glfwMakeContextCurrent'
prog.cpp:(.text+0xef): undefined reference to `glewExperimental'
prog.cpp:(.text+0xf5): undefined reference to `glewInit'
prog.cpp:(.text+0x22c): undefined reference to `__glewGenVertexArrays'
prog.cpp:(.text+0x241): undefined reference to `__glewGenBuffers'
prog.cpp:(.text+0x256): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x264): undefined reference to `__glewBindBuffer'
prog.cpp:(.text+0x277): undefined reference to `__glewBufferData'
prog.cpp:(.text+0x293): undefined reference to `__glewVertexAttribPointer'
prog.cpp:(.text+0x2bc): undefined reference to `__glewEnableVertexAttribArray'
prog.cpp:(.text+0x2ca): undefined reference to `__glewVertexAttribPointer'
prog.cpp:(.text+0x2f3): undefined reference to `__glewEnableVertexAttribArray'
prog.cpp:(.text+0x301): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x314): undefined reference to `glfwWindowShouldClose'
prog.cpp:(.text+0x326): undefined reference to `glfwPollEvents'
prog.cpp:(.text+0x368): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x38a): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x39d): undefined reference to `glfwSwapBuffers'
prog.cpp:(.text+0x3a9): undefined reference to `__glewDeleteVertexArrays'
prog.cpp:(.text+0x3be): undefined reference to `__glewDeleteBuffers'
prog.cpp:(.text+0x3d1): undefined reference to `glfwTerminate'
/tmp/ccdaDttM.o: In function `Shader::Shader(char const*, char const*)':
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x27b): undefined reference to `__glewCreateShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x28f): undefined reference to `__glewShaderSource'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2af): undefined reference to `__glewCompileShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2c0): undefined reference to `__glewGetShaderiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2e7): undefined reference to `__glewGetShaderInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x347): undefined reference to `__glewCreateShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x35b): undefined reference to `__glewShaderSource'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x37b): undefined reference to `__glewCompileShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x38c): undefined reference to `__glewGetShaderiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x3b3): undefined reference to `__glewGetShaderInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x413): undefined reference to `__glewCreateProgram'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x427): undefined reference to `__glewAttachShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x443): undefined reference to `__glewAttachShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x45f): undefined reference to `__glewLinkProgram'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x473): undefined reference to `__glewGetProgramiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x49d): undefined reference to `__glewGetProgramInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x500): undefined reference to `__glewDeleteShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x511): undefined reference to `__glewDeleteShader'
/tmp/ccdaDttM.o: In function `Shader::Use()':
prog.cpp:(.text._ZN6Shader3UseEv[_ZN6Shader3UseEv]+0xf): undefined reference to `__glewUseProgram'
collect2: error: ld returned 1 exit status
When I googled, I found this post : undefined reference to `__glewCreateShader`
and according to the post, I changed the command to :
g++ -o proj prog.cpp -lGLEW -lm
The long list of errors is reduced but still :
/usr/bin/ld: /tmp/ccSaE0MX.o: undefined reference to symbol 'glDrawArrays'
//usr/lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I viewed several posts and they almost say the same thing
OpenGL library not linking
The command I tried :
g++ -o proj prog.cpp -lGLEW -lm -lGLU -lglut
g++ -o proj prog.cpp -lGL -lGLEW -lm
g++ -o proj prog.cpp -lGLEW -lGL -lm
g++ -o proj prog.cpp -lGLEW -lopengl32 -lm
g++ prog.cpp -lGL -lGLU -lGLEW -lGLFW -lm
g++ prog.cpp -lGL -lGLU -lGLEW -lglut -lm -o proj
include :
#include <iostream>
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "Shader.h"
Update :
here is what I am getting now
g++ -o proj sample.cpp libglut.a -lGL -lm
/usr/bin/ld: libglut.a(glut_event.o): undefined reference to symbol 'XWithdrawWindow'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Please tell me what am I doing wrong.
Thanks
I am trying to compile an app with static curl and i it seems OpenSSL is not properly linked.
COMPILE CMD:
$(CXX) $(CXXFLAGS) program1.cpp /opt/curl-7.62.0/lib/libcurl.a /opt/openssl-1.1.1a/lib/libcrypto.a -o program1 -L/opt/curl-7.62.0/ -L/opt/openssl-1.1.1a/ -Wwrite-strings -fpermissive -static-libstdc++ -lcrypto -lssl -lcurl -Wl,-Bstatic -lidn2 -lrt -lz -Wl,-Bdynamic -ldl -lpthread
CURL:
rm -rf /opt/curl-7.62.0/*; ./configure --prefix=/opt/curl-7.62.0 --with-pic --disable-shared --enable-static --with-libidn=/opt/libidn2-2.0.4 --with-ssl=/opt/openssl-1.1.1a --without-librtmp --without-gnutls --without-nss --without-libssh2 --with-zlib=/opt/zlib-1.2.11 --without-winidn --disable-rtsp --disable-ldap --disable-ldaps --disable-ipv6 LIBS=-ldl; make -j 8; make install; ls -al /opt/curl-7.62.0/;
OPENSSL :
./config --prefix=/opt/openssl-1.1.1a -fPIC -static; make; make install;
Errors :
/opt/curl-7.69.1/lib/libcurl.a(libcurl_la-openssl.o): In function `Curl_ossl_sha256sum':
openssl.c:(.text+0x13c): undefined reference to `EVP_MD_CTX_new'
openssl.c:(.text+0x177): undefined reference to `EVP_MD_CTX_free'
/opt/curl-7.69.1/lib/libcurl.a(libcurl_la-openssl.o): In function `Curl_ossl_md5sum':
openssl.c:(.text+0x1cc): undefined reference to `EVP_MD_CTX_new'
openssl.c:(.text+0x207): undefined reference to `EVP_MD_CTX_free'
/opt/curl-7.69.1/lib/libcurl.a(libcurl_la-openssl.o): In function `Curl_ossl_version':
openssl.c:(.text+0xb54): undefined reference to `OpenSSL_version_num'
/opt/curl-7.69.1/lib/libcurl.a(libcurl_la-openssl.o): In function `servercert':
openssl.c:(.text+0x19d0): undefined reference to `X509_get0_notBefore'
openssl.c:(.text+0x1a2c): undefined reference to `X509_get0_notAfter'
openssl.c:(.text+0x1b29): undefined reference to `OPENSSL_sk_num'
openssl.c:(.text+0x1b7f): undefined reference to `OPENSSL_sk_value'
openssl.c:(.text+0x1c77): undefined reference to `X509_get_X509_PUBKEY'
openssl.c:(.text+0x1caf): undefined reference to `X509_get_X509_PUBKEY'
openssl.c:(.text+0x1f22): undefined reference to `OPENSSL_sk_num'
openssl.c:(.text+0x1fa9): undefined reference to `OPENSSL_sk_value'
openssl.c:(.text+0x207e): undefined reference to `X509_get_version'
openssl.c:(.text+0x21f4): undefined reference to `X509_get_X509_PUBKEY'
openssl.c:(.text+0x2272): undefined reference to `X509_get0_extensions'
openssl.c:(.text+0x227d): undefined reference to `OPENSSL_sk_num'
openssl.c:(.text+0x22f1): undefined reference to `OPENSSL_sk_num'
openssl.c:(.text+0x2303): undefined reference to `OPENSSL_sk_value'
openssl.c:(.text+0x2673): undefined reference to `X509_get0_notBefore'
openssl.c:(.text+0x26cb): undefined reference to `X509_get0_notAfter'
openssl.c:(.text+0x2755): undefined reference to `EVP_PKEY_get0_RSA'
openssl.c:(.text+0x276f): undefined reference to `RSA_get0_key'
openssl.c:(.text+0x2ac5): undefined reference to `ASN1_STRING_get0_data'
openssl.c:(.text+0x2b6c): undefined reference to `EVP_PKEY_get0_DSA'
openssl.c:(.text+0x2b8c): undefined reference to `DSA_get0_pqg'
openssl.c:(.text+0x2b9e): undefined reference to `DSA_get0_key'
openssl.c:(.text+0x2c44): undefined reference to `EVP_PKEY_get0_DH'
openssl.c:(.text+0x2c64): undefined reference to `DH_get0_pqg'
openssl.c:(.text+0x2c76): undefined reference to `DH_get0_key'
openssl.c:(.text+0x2d15): undefined reference to `ASN1_STRING_get0_data'
openssl.c:(.text+0x2d3d): undefined reference to `ASN1_STRING_get0_data'
openssl.c:(.text+0x32aa): undefined reference to `ASN1_STRING_get0_data'
/opt/curl-7.69.1/lib/libcurl.a(libcurl_la-openssl.o): In function `ossl_connect_step2':
openssl.c:(.text+0x3461): undefined reference to `SSL_get_client_random'
openssl.c:(.text+0x3476): undefined reference to `SSL_SESSION_get_master_key'
/opt/curl-7.69.1/lib/libcurl.a(libcurl_la-openssl.o): In function `ossl_connect_step1':
openssl.c:(.text+0x3f51): undefined reference to `TLS_client_method'
openssl.c:(.text+0x40b3): undefined reference to `SSL_CTX_set_options'
openssl.c:(.text+0x545c): undefined reference to `OPENSSL_sk_pop_free'
openssl.c:(.text+0x55fe): undefined reference to `OPENSSL_sk_pop'
openssl.c:(.text+0x5640): undefined reference to `OPENSSL_sk_num'
openssl.c:(.text+0x566c): undefined reference to `OPENSSL_sk_pop_free'
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'main' failed
....
What could it be?
Thank you.
I'm fairly certain that libcurl depends on the SSL/Crypto binaries, not the other way around.
And I believe the gnu linker doesn't "go back" in the library list to resolve missing symbols, only forward in the list. Hence, this order of library includes:
-lcrypto -lssl -lcurl
Should be this:
-lcurl -lssl -lcrypto
Another option - redundantly append -lcrypto -lssl and to the end of the build line. That is:
$(CXX) $(CXXFLAGS) program1.cpp /opt/curl-7.62.0/lib/libcurl.a /opt/openssl-1.1.1a/lib/libcrypto.a -o program1 -L/opt/curl-7.62.0/ -L/opt/openssl-1.1.1a/ -Wwrite-strings -fpermissive -static-libstdc++ -lcrypto -lssl -lcurl -Wl,-Bstatic -lidn2 -lrt -lz -Wl,-Bdynamic -ldl -lpthread -lcrypto -lssl
If any of the above works, you can experiment with link library order.
I have some RSA code, however, I can't get it to compile & link properly.
build.sh:
x86_64-w64-mingw32-g++ rsa.cpp -L/usr/local/opt/openssl/lib -lcrypto -lssl -I/usr/local/opt/openssl/include/ -static-libstdc++ -static-libgcc -o main.exe
result:
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0xe6): undefined reference to `BIO_new_mem_buf'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0xef): undefined reference to `BIO_f_base64'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0xf7): undefined reference to `BIO_new'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x10b): undefined reference to `BIO_push'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x130): undefined reference to `BIO_read'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x146): undefined reference to `BIO_free_all'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x177): undefined reference to `EVP_PKEY_new'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x193): undefined reference to `EVP_PKEY_assign'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x198): undefined reference to `EVP_MD_CTX_create'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x1a5): undefined reference to `EVP_sha256'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x1c7): undefined reference to `EVP_DigestVerifyInit'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x1f1): undefined reference to `EVP_DigestUpdate'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x218): undefined reference to `EVP_DigestVerifyFinal'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x234): undefined reference to `EVP_MD_CTX_cleanup'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x254): undefined reference to `EVP_MD_CTX_cleanup'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x26e): undefined reference to `EVP_MD_CTX_cleanup'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x2ac): undefined reference to `BIO_new_mem_buf'
/var/folders/8k/t6rljvrs6l32k49b3834_njr0000gn/T//ccKr56mH.o:rsa.cpp:(.text+0x2da): undefined reference to `PEM_read_bio_RSA_PUBKEY'
collect2: error: ld returned 1 exit status
both libcrypto.a and libssl.a exist in /usr/local/opt/openssl/lib. I'm building on OS X mingw compiler a windows application.
EDIT: objdump -d /usr/local/opt/openssl/lib/libcrypto.a > ~/libcrypto.a.txt
EDIT2: Tried grouping: x86_64-w64-mingw32-g++ rsa.cpp -L/usr/local/opt/openssl/lib -Wl,--start-group -lcrypto -lssl -Wl,--end-group -lws2_32 -lwsock32 -liphlpapi -I/usr/local/opt/openssl/include/ -static-libstdc++ -static-libgcc -o main.exe, same result
This question already has answers here:
undefined reference to boost::system::system_category() when compiling
(9 answers)
Closed 7 years ago.
I'm trying to get select boost modules built and into my code as static libraries for what we need for our project. I seem to be able to get them to build using their Boost.Build system, and my project will compile using boost shared libraries, but when I try to link static, they break.
I built Boost using the following:
./b2 link=static variant=release threading=multi --with-iostreams --with-system --with-timer --ignore-site-config
Which give success
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/mike/dev/cpp/boost_1_60_0
The following directory should be added to linker library paths:
/home/mike/dev/cpp/boost_1_60_0/stage/lib
Then I try to compile using my makefile with autotools:
tunnel_CPPFLAGS = -march=native -pipe -funroll-loops -fomit-frame-pointer -fforce-addr -fprefetch-loop-arrays -Wall -std=c++0x -I/home/mike/dev/cpp/boost_1_60_0/
tunnel_SOURCES = tunneller/tunnel.cpp config.cpp util.cpp tunneller/remoteclient.cpp tunneller/localclient.cpp
tunnel_LDADD = -lcrypto -lssl
tunnel_LDFLAGS = -pthread -Wl,-Bstatic -L/home/mike/dev/cpp/boost_1_60_0/stage/lib -lboost_iostreams -lboost_timer -lboost_system -Wl,-Bdynamic
Which returns this fantastic error:
make all-recursive
make[1]: Entering directory '/home/mike/dev/cpp/sonar'
Making all in src
make[2]: Entering directory '/home/mike/dev/cpp/sonar/src'
g++ -g -O2 -pthread -Wl,-Bstatic -L/home/mike/dev/cpp/boost_1_60_0/stage/lib -lboost_iostreams -lboost_timer -lboost_system -Wl,-Bdynamic -o tunnel tunneller/tunnel-tunnel.o tunnel-config.o tunnel-util.o tunneller/tunnel-remoteclient.o tunneller/tunnel-localclient.o -lcrypto -lssl
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::task_io_service::shutdown_service()':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::op_queue<boost::asio::detail::task_io_service_operation>::~op_queue()':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::epoll_reactor::deregister_descriptor(int, boost::asio::detail::epoll_reactor::descriptor_state*&, bool)':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::reactive_socket_service_base::destroy(boost::asio::detail::reactive_socket_service_base::base_implementation_type&)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::reactive_socket_service_base::destroy(boost::asio::detail::reactive_socket_service_base::base_implementation_type&)':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o:/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: more undefined references to `boost::system::system_category()' follow
tunneller/tunnel-tunnel.o: In function `_GLOBAL__sub_I__Z14printUsageExitv':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `_GLOBAL__sub_I__Z14printUsageExitv':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `std::default_delete<tunnel::LocalClient>::operator()(tunnel::LocalClient*) const [clone .isra.247]':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `tunnel::RemoteClient::authenticationSuccess()':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `tunnel::RemoteClient::RemoteClient(boost::asio::io_service&, boost::asio::ssl::context&, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, std::string, std::string, std::string)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o:/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: more undefined references to `boost::system::system_category()' follow
tunneller/tunnel-remoteclient.o: In function `_GLOBAL__sub_I__ZN6tunnel12RemoteClientC2ERN5boost4asio10io_serviceERNS2_3ssl7contextENS2_2ip23basic_resolver_iteratorINS8_3tcpEEESsSsSs':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `_GLOBAL__sub_I__ZN6tunnel12RemoteClientC2ERN5boost4asio10io_serviceERNS2_3ssl7contextENS2_2ip23basic_resolver_iteratorINS8_3tcpEEESsSsSs':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `tunnel::LocalClient::handleConnect(boost::system::error_code)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `tunnel::LocalClient::handleConnect(boost::system::error_code)':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `tunnel::LocalClient::handleConnect(boost::system::error_code)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o:/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: more undefined references to `boost::system::system_category()' follow
tunneller/tunnel-localclient.o: In function `_GLOBAL__sub_I__ZN6tunnel11LocalClientC2EPNS_12RemoteClientERN5boost4asio10io_serviceERNS4_2ip23basic_resolver_iteratorINS7_3tcpEEERt':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `_GLOBAL__sub_I__ZN6tunnel11LocalClientC2EPNS_12RemoteClientERN5boost4asio10io_serviceERNS4_2ip23basic_resolver_iteratorINS7_3tcpEEERt':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
Makefile:385: recipe for target 'tunnel' failed
make[2]: *** [tunnel] Error 1
make[2]: Leaving directory '/home/mike/dev/cpp/sonar/src'
Makefile:355: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/mike/dev/cpp/sonar'
Makefile:296: recipe for target 'all' failed
make: *** [all] Error 2
What am I missing to get this to compile properly?
The problem is not when compiling, it is when it trying to link.
The order in which -l option is given matters So, try giving -lboost_system as first in -l options.
-pthread -Wl,-Bstatic -L/home/mike/dev/cpp/boost_1_60_0/stage/lib -lboost_system -lboost_iostreams -lboost_timer -Wl,-Bdynamic
I went through this tutorial on how to install Mesa(OpenGL). Everything works as described. But when I try to put the build command, which works perfectly, into a makefile it doesn't.
This is my makefile:
all:
gcc -lglut -IGL -IGLEW -IGLU main.c -o OpenGLExample
If I enter make, I get:
gcc -lglut -IGL -IGLEW -IGLU main.c -o OpenGLExample
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glClearColor'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glClear'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glColor3f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glOrtho'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glBegin'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glEnd'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glFlush'
collect2: ld returned 1 exit status
make: *** [all] Error 1
I'm using Ubuntu instead of Mint as in the tutorial.
What is it that I'm doing wrong?
You didn't pass OpenGl libraries to the linker. Instead of I you should type l:
all:
gcc main.c -lglut -lGL -lGLEW -lGLU -o OpenGLExample
You should also pass directory where your compiler can find OpenGL header files, this can be done with -I, and probably also an option (or options) specifying where the linker should look for the libraries (-L).