Add dependencies to C++ project via CMake [duplicate] - c++

I'm trying to use GLFW on a project, but when I compile it, I get a lot of undefined reference errors, while many of them is on the library file (libglfw.a).
I tried both, compile the library and download it, but without success.
I'm using MinGW and MSYS running on Windows 7 32-bits on netbeans. The GLFW version is 2.7.3;
These are the errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/prism.exe
make[2]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/prism build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/ByteBuffer.o -Lexternal -lglfw
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:35: undefined reference to `glMatrixMode#4'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:36: undefined reference to `glLoadIdentity#0'
build/Debug/MinGW-Windows/main.o: In function `Z6renderv':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:56: undefined reference to `glClearColor#16'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:57: undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(window.o):window.c:(.text+0x8ae): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe54): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe6c): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xef6): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf4f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf7f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x174c): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1935): undefined reference to `wglCreateContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x19fe): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1a0e): undefined reference to `wglDeleteContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ea6): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ebc): undefined reference to `glGetFloatv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ed8): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ee7): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1f1a): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1a): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1bf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1ef): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x28b): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x2cf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7d): undefined reference to `wglGetProcAddress#4make[2]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
make[1]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/prism.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
CONSTRUIR FALHOU (valor da saída 2, tempo total: 1s)

Don't you have to link the OpenGL libs as well? I don't see libGL or libGLU. I know glClear is in either libGL or libGLU.

In the linker, at Windows, MinGW: -lglew32 -lglfw3 -lopengl32 -lglu32 -lgdi32
Put the libs and the includes files in MinGW and the dlls and exes at Windows systems folders.

In my case the problem was different. I was linking opengl32 in, but still getting the error. The problem turned out to be the library order: glfw has to be linked in before opengl32.
In my case this was in the "Link libraries" listbox in the Code::Blocks IDE, but it's going to be similar in NetBeans or on the command line.

The error I got is
undefined reference to `__imp_glfwInit'
fixed the problem after I change to glfw-3.3.2.bin.WIN64 (64 bit glfw)

Related

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 to `boost::system::system_category(), but I already have -lboost_system

Getting this error from a cpp library I'm trying to port from Linux to Windows, using code::blocks. I'm new to c++ in general but especially new to Windows and CB.
I'm pretty sure I have added the system library accordingly, by which I mean I have compiled it using:
.\b2 -j 8 variant=release link=shared threading=single
Then gone to the lib directory, found boost_system-vc120-1_55.dll and renamed it boost_system.dll
The added F:\plus\boost\boost_1_55_0\stage\lib to the Build options, search directories, linker. (And F:\plus\boost\boost_1_55_0\ in search directories, compiler)
The -lboost_system is after the cpp files in the compile command, although for some reason it's listed twice, but I tried compiling in command prompt without the first one and gave same error.
This is the build output I get:
-------------- Build: Release in sendd (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LF:\plus\wxWidgets-3.0.2\lib\gcc_dll -LF:\plus\boost\boost_1_55_0\stage\lib -o bin\Release\sendd.exe obj\Release\gsmencoding.o obj\Release\hexdump.o obj\Release\pdu.o obj\Release\senddApp.o obj\Release\senddMain.o obj\Release\smpp.o obj\Release\smppclient.o obj\Release\sms.o obj\Release\timeformat.o obj\Release\resource.res -s -mthreads -lwsock32 -lws2_32 -lboost_system -lwxmsw30u -lboost_system -mwindows
obj\Release\smppclient.o:smppclient.cpp:(.text+0x724): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0x769): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0xb28): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0xf28): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0xfaf): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0x13a5): more undefined references to `boost::system::system_category()' follow
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x1b): undefined reference to `boost::system::generic_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x25): undefined reference to `boost::system::generic_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x2f): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x39): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x43): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x4d): undefined reference to `boost::system::system_category()'
Any ideas? Thanks!

commandline works, same command in Makefile doesn't

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

GLFW Undefined References

I'm trying to use GLFW on a project, but when I compile it, I get a lot of undefined reference errors, while many of them is on the library file (libglfw.a).
I tried both, compile the library and download it, but without success.
I'm using MinGW and MSYS running on Windows 7 32-bits on netbeans. The GLFW version is 2.7.3;
These are the errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/prism.exe
make[2]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/prism build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/ByteBuffer.o -Lexternal -lglfw
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:35: undefined reference to `glMatrixMode#4'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:36: undefined reference to `glLoadIdentity#0'
build/Debug/MinGW-Windows/main.o: In function `Z6renderv':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:56: undefined reference to `glClearColor#16'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:57: undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(window.o):window.c:(.text+0x8ae): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe54): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe6c): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xef6): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf4f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf7f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x174c): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1935): undefined reference to `wglCreateContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x19fe): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1a0e): undefined reference to `wglDeleteContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ea6): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ebc): undefined reference to `glGetFloatv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ed8): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ee7): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1f1a): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1a): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1bf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1ef): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x28b): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x2cf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7d): undefined reference to `wglGetProcAddress#4make[2]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
make[1]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/prism.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
CONSTRUIR FALHOU (valor da saída 2, tempo total: 1s)
Don't you have to link the OpenGL libs as well? I don't see libGL or libGLU. I know glClear is in either libGL or libGLU.
In the linker, at Windows, MinGW: -lglew32 -lglfw3 -lopengl32 -lglu32 -lgdi32
Put the libs and the includes files in MinGW and the dlls and exes at Windows systems folders.
In my case the problem was different. I was linking opengl32 in, but still getting the error. The problem turned out to be the library order: glfw has to be linked in before opengl32.
In my case this was in the "Link libraries" listbox in the Code::Blocks IDE, but it's going to be similar in NetBeans or on the command line.
The error I got is
undefined reference to `__imp_glfwInit'
fixed the problem after I change to glfw-3.3.2.bin.WIN64 (64 bit glfw)

question about boost asio

i have following code
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#include <boost/asio.hpp>
using namespace std;
int main(int argc,char *argv[]) {
boost::asio::io_service io;
boost::asio::deadline_timer t(io,boost::posix_time::seconds(5));
t.wait();
std::cout<<" hello world\n";
return 0;
}
but i have following error list
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/david/NetBeansProjects/Boost'
/usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/boost
make[2]: Entering directory `/home/david/NetBeansProjects/Boost'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/boost build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:205: undefined reference to `boost::system::get_system_category()'
/usr/include/boost/system/error_code.hpp:206: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:211: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:212: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:213: undefined reference to `boost::system::get_system_category()'
build/Debug/GNU-Linux-x86/main.o: In function `error_code':
/usr/include/boost/system/error_code.hpp:312: undefined reference to `boost::system::get_system_category()'
build/Debug/GNU-Linux-x86/main.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost/asio/error.hpp:218: undefined reference to `boost::system::get_system_category()'
build/Debug/GNU-Linux-x86/main.o: In function `~posix_thread':
/usr/include/boost/asio/detail/posix_thread.hpp:69: undefined reference to `pthread_detach'
build/Debug/GNU-Linux-x86/main.o: In function `boost::asio::detail::posix_thread::join()':
/usr/include/boost/asio/detail/posix_thread.hpp:77: undefined reference to `pthread_join'
build/Debug/GNU-Linux-x86/main.o: In function `~posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:61: undefined reference to `pthread_key_delete'
build/Debug/GNU-Linux-x86/main.o: In function `posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:47: undefined reference to `pthread_key_create'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/boost] Error 1
make[2]: Leaving directory `/home/david/NetBeansProjects/Boost'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/david/NetBeansProjects/Boost'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 5s)
pleas help what is happaned?
The problem is not in your code, the problem is in the settings of the compiler (actually linker). You need to link to the Boost.System and pthread libraries. Usually it's done by passing -lboost_system, -lpthread to the linker options in your Makefile, or favorite IDE.
You need to link with the Boost.System library: -lboost_system
Also you need to link with pthreads lib: -lpthread
You need to right click your project root folder and select properties.
From there, you need to select 'Linker' in the left pane and the 'Libraries' option field is there. You need to browse your system till you find the libboost_system.a binary. Usually at /usr/local/lib.
If you cant find the file you are after you may not have compiled the source for those libraries yet. Check out either http://ubuntuforums.org/showthread.php?t=1180792 or the getting started documentation included in the boost tar package.
For future reference to anyone with the same problem:
In netbeans right click the project -->Properties -> C++ Compiler and at the bottom there's an option for "Aditional arguments" pass in the -lboost_system option. Note: -lboost_system must be defined or you'll get errors