commandline works, same command in Makefile doesn't - c++

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

Related

Error in opengl undefined reference to symbol

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

Can't link OpenSSL libraries properly with Mingw on OS X

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

Built and static linked boost modules causes a bunch of linker errors with shutdown_service() [duplicate]

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

undefined reference error while compiling libcvd

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.

Linking errors when compiling boost asio on Linux

I have been running through a few tutorials of boost and the libraries it has.
I ran through the basic tutorial for boost:
http://www.boost.org/doc/libs/1_52_0/more/getting_started/unix-variants.html
and it worked fine. I am having issues with the asio tutorial:
http://www.boost.org/doc/libs/1_50_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html
It looks like linking errors, but I am including the same path as before:
g++ -I /usr/local/boost_1_52_0 test.cpp -o example
Error:
/tmp/cce4EZME.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x57b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x587): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x593): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::system::error_code::error_code()':
test.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
test.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to `pthread_detach'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::join()':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b): undefined reference to `pthread_join'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE[_ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE]+0x29): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
assuming you have installed your boost libraries in your /usr/lib directory and boost header files in /usr/include/boost and you have saved your code in a file named daytime1.cpp, you have to use the following command to compile the source code you have linked to:
$ g++ daytime1.cpp -o daytime -L /usr/lib/ -lboost_system -lboost_thread -lpthread