I've got a problem with compiling the following files. Just to explain the situation: I did get all of the files, except the Makefile, for an exercise. My problem is, that I can not compile the program because of some undefined references. I do not have access to the unit.cpp or plotx11.cpp. Maybe someone knows what causes the problem.
Makefile:
CXXFLAGS = -g -Wall
LIBS = -lX11 -pthread
C11 = -std=c++11
vierGewinnt: vierGewinnt.cpp unit.o plotx11.o
$(CXX) $(CXXFLAGS) $(C11) $(LIBS) -o $# $^
vierGewinnt.o: vierGewinnt.cpp unit.h
$(CXX) $(CXXFLAGS) $(C11) $(LIBS) -c $<
.PHONY.: clean
clean:
rm -f vierGewinnt vierGewinnt.o
Unit.h includes just some declaration of methods and some constant variables.
plotx11.h:
#ifndef __PLOTX11__
#define __PLOTX11__
enum PlColors
{
Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, DarkGrey,
DarkRed, DarkGreen, DarkYellow, DarkBlue, DarkMagenta, DarkCyan, Grey
};
void PlDelay (int msecs);
void PlInit (int &width, int &height);
void PlClear ();
void PlFlush ();
void PlStop ();
void PlLineColor (PlColors color);
void PlLineWidth (int width);
void PlMarkerSize (int width);
void PlFrame (int x0, int x1, int y0, int y1);
void PlScale (double x0, double x1, double y0, double y1);
void PlPlot (double x, double y, int mode);
void PlWhere (double &x, double &y);
void HandleXEvents();
#endif
vierGewinnt.cpp:
#include <cmath>
#include <iostream>
#include <random>
#include "unit.h"
void NetzwerkMain();
// ...
// const unsigned int Schwierigkeitsgrad = 0;
enum Feld
{ leer, gelb, rot };
int main()
{
int Zug, Gegenzug;
// Netzwerkspiel? Rufe NetzwerkMain() auf.
// ...
// Start(Schwierigkeitsgrad);
for(unsigned int Spiel = 1; Spiel <= AnzahlSpiele; Spiel++)
{
// ...
}
return 0;
}
enum class SpielStatus {
Verbindungsfehler,
Niederlage,
Unentschieden,
Sieg
};
SpielStatus Netzwerkspiel( Feld MeineFarbe ) {
return SpielStatus::Verbindungsfehler;
}
The errors:
g++ -O -g -Wall -std=c++11 -lX11 -lpthread -o vierGewinnt vierGewinnt.o unit.o plotx11.o
unit.o: In function `asio::ip::resolver_service<asio::ip::tcp>::shutdown_service()':
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEE16shutdown_serviceEv[_ZN4asio2ip16resolver_serviceINS0_3tcpEE16shutdown_serviceEv]+0x1d6): undefined reference to `pthread_join'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEE16shutdown_serviceEv[_ZN4asio2ip16resolver_serviceINS0_3tcpEE16shutdown_serviceEv]+0x1f9): undefined reference to `pthread_detach'
unit.o: In function `asio::ip::resolver_service<asio::ip::tcp>::~resolver_service()':
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEED0Ev[_ZN4asio2ip16resolver_serviceINS0_3tcpEED5Ev]+0x314): undefined reference to `pthread_detach'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEED0Ev[_ZN4asio2ip16resolver_serviceINS0_3tcpEED5Ev]+0x336): undefined reference to `pthread_join'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEED0Ev[_ZN4asio2ip16resolver_serviceINS0_3tcpEED5Ev]+0x359): undefined reference to `pthread_detach'
unit.o: In function `asio::ip::resolver_service<asio::ip::tcp>::~resolver_service()':
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEED2Ev[_ZN4asio2ip16resolver_serviceINS0_3tcpEED5Ev]+0x304): undefined reference to `pthread_detach'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEED2Ev[_ZN4asio2ip16resolver_serviceINS0_3tcpEED5Ev]+0x326): undefined reference to `pthread_join'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEED2Ev[_ZN4asio2ip16resolver_serviceINS0_3tcpEED5Ev]+0x349): undefined reference to `pthread_detach'
unit.o: In function `asio::ip::resolver_service<asio::ip::tcp>::fork_service(asio::io_service::fork_event)':
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEE12fork_serviceENS_10io_service10fork_eventE[_ZN4asio2ip16resolver_serviceINS0_3tcpEE12fork_serviceENS_10io_service10fork_eventE]+0x10d): undefined reference to `pthread_create'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEE12fork_serviceENS_10io_service10fork_eventE[_ZN4asio2ip16resolver_serviceINS0_3tcpEE12fork_serviceENS_10io_service10fork_eventE]+0x176): undefined reference to `pthread_join'
unit.cpp:(.text._ZN4asio2ip16resolver_serviceINS0_3tcpEE12fork_serviceENS_10io_service10fork_eventE[_ZN4asio2ip16resolver_serviceINS0_3tcpEE12fork_serviceENS_10io_service10fork_eventE]+0x18d): undefined reference to `pthread_detach'
plotx11.o: In function `PlLineWidth(int)':
plotx11.cpp:(.text+0x1c2): undefined reference to `XChangeGC'
plotx11.o: In function `PlClear()':
plotx11.cpp:(.text+0x203): undefined reference to `XClearWindow'
plotx11.o: In function `PlStop()':
plotx11.cpp:(.text+0x263): undefined reference to `XClearWindow'
plotx11.cpp:(.text+0x2ab): undefined reference to `XDestroyWindow'
plotx11.o: In function `PlInit(int&, int&)':
plotx11.cpp:(.text+0x2d4): undefined reference to `XOpenDisplay'
plotx11.cpp:(.text+0x316): undefined reference to `XSynchronize'
plotx11.cpp:(.text+0x328): undefined reference to `XDefaultColormap'
plotx11.cpp:(.text+0x3d0): undefined reference to `XAllocColor'
plotx11.cpp:(.text+0x42e): undefined reference to `XCreateSimpleWindow'
plotx11.cpp:(.text+0x463): undefined reference to `XSetStandardProperties'
plotx11.cpp:(.text+0x47d): undefined reference to `XSelectInput'
plotx11.cpp:(.text+0x4be): undefined reference to `XChangeWindowAttributes'
plotx11.cpp:(.text+0x4d5): undefined reference to `XCreateGC'
plotx11.cpp:(.text+0x50e): undefined reference to `XSetState'
plotx11.cpp:(.text+0x521): undefined reference to `XMapWindow'
plotx11.cpp:(.text+0x52f): undefined reference to `XSync'
plotx11.o: In function `pplot(double, double, int)':
plotx11.cpp:(.text+0x733): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x79d): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x7cf): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x858): undefined reference to `XFillArc'
plotx11.cpp:(.text+0x89e): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x8cc): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x8fe): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x951): undefined reference to `XFillRectangle'
plotx11.cpp:(.text+0x992): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x9c4): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xa1b): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xa78): undefined reference to `XDrawArc'
plotx11.o: In function `PlPlot(double, double, int)':
plotx11.cpp:(.text+0xbd5): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xc3d): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xc6f): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xcf8): undefined reference to `XFillArc'
plotx11.cpp:(.text+0xd3e): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xd6c): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xd9e): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xdf1): undefined reference to `XFillRectangle'
plotx11.cpp:(.text+0xe32): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xe64): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xebb): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0xf18): undefined reference to `XDrawArc'
plotx11.o: In function `XGetNextEvent(_XEvent*)':
plotx11.cpp:(.text+0xf5b): undefined reference to `XNextEvent'
plotx11.cpp:(.text+0xf9d): undefined reference to `XEventsQueued'
plotx11.cpp:(.text+0xfb0): undefined reference to `XPeekEvent'
plotx11.cpp:(.text+0xfed): undefined reference to `XEventsQueued'
plotx11.cpp:(.text+0x1000): undefined reference to `XPeekEvent'
plotx11.cpp:(.text+0x1056): undefined reference to `XNextEvent'
plotx11.cpp:(.text+0x106d): undefined reference to `XEventsQueued'
plotx11.cpp:(.text+0x1084): undefined reference to `XPeekEvent'
plotx11.o: In function `HandleXEvents()':
plotx11.cpp:(.text+0x10dd): undefined reference to `XEventsQueued'
plotx11.cpp:(.text+0x10f6): undefined reference to `XNextEvent'
plotx11.cpp:(.text+0x111d): undefined reference to `XRefreshKeyboardMapping'
plotx11.cpp:(.text+0x1141): undefined reference to `XClearWindow'
plotx11.cpp:(.text+0x1179): undefined reference to `XSetForeground'
plotx11.cpp:(.text+0x1275): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x12f0): undefined reference to `XFillArc'
plotx11.cpp:(.text+0x134a): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x137c): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x13ae): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x13f1): undefined reference to `XFillRectangle'
plotx11.cpp:(.text+0x142d): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x145b): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x148c): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x14dc): undefined reference to `XDrawLine'
plotx11.cpp:(.text+0x1538): undefined reference to `XDrawArc'
plotx11.cpp:(.text+0x157b): undefined reference to `XDrawLine'
plotx11.o: In function `PlLineColor(PlColors)':
plotx11.cpp:(.text+0x190): undefined reference to `XSetForeground'
plotx11.o: In function `PlFlush()':
plotx11.cpp:(.text+0x1ea): undefined reference to `XSync'
plotx11.o: In function `PlStop()':
plotx11.cpp:(.text+0x2bb): undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status
Makefile:7: recipe for target 'vierGewinnt' failed
make: *** [vierGewinnt] Error 1
Related
I'm learning Corba with OmniORB and try to compile simple example program but it doesn't work. Unfortunately is really hard to find some information how to do it.
What I do looks like:
I made simple interface file in idl directory
interface IssueAlert {
string sendAlert(in string alert);
};
Compile it using omniidl -bcxx -Wbexamples echo.idl
I get result files and using examples made that code as a server app.
#include "idl/echo.hh"
#include <iostream>
using namespace std;
class IssueAlert_i : public POA_IssueAlert {
public:
IssueAlert_i();
virtual ~IssueAlert_i();
char* sendAlert(const char* alert);
};
IssueAlert_i::IssueAlert_i(){}
IssueAlert_i::~IssueAlert_i(){}
char* IssueAlert_i::sendAlert(const char* alert){
cout << "Upcall: " << alert << endl;
return CORBA::string_dup(alert);
}
//////////////////////////////////////////////////////////////////////
int main(int argc, char** argv){
try {
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
PortableServer::Servant_var<IssueAlert_i> issue = new
IssueAlert_i();
PortableServer::ObjectId_var issue_id = poa->activate_object(issue);
// Obtain a reference to the object, and print it out as a
// stringified IOR.
obj = issue->_this();
CORBA::String_var sior(orb->object_to_string(obj));
cout << sior << endl;
PortableServer::POAManager_var pman = poa->the_POAManager();
pman->activate();
// Block until the ORB is shut down.
orb->run();
}catch (CORBA::SystemException& ex) {
cerr << "Caught CORBA::" << ex._name() << endl;
}catch (CORBA::Exception& ex) {
cerr << "Caught CORBA::Exception: " << ex._name() << endl;
}
return 0;
}
To compile it i'm using command:
clang++ -std=c++17 -Wall -Wextra -Wnarrowing -Wsign-conversion -lomniORB4 -lomnithread -lomniDynamic4 servant.cpp -I/usr/include -L/usr/lib64/ -o server
All OmniORB things installed by yum are in /usr/include and /usr/lib64.
I get that error:
/tmp/servant-e9e6b6.o: In function `IssueAlert_i::IssueAlert_i()':
servant.cpp:(.text+0x148): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
/tmp/servant-e9e6b6.o: In function `IssueAlert_i::~IssueAlert_i()':
servant.cpp:(.text+0x198): undefined reference to `POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o: In function `IssueAlert_i::~IssueAlert_i()':
servant.cpp:(.text+0x201): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
/tmp/servant-e9e6b6.o: In function `POA_IssueAlert::_this()':
servant.cpp:
(.text._ZN14POA_IssueAlert5_thisEv[_ZN14POA_IssueAlert5_thisEv]+0x1e): undefined reference to `IssueAlert::_PD_repoId'
/tmp/servant-e9e6b6.o:(.rodata+0x68): undefined reference to `_impl_IssueAlert::_dispatch(omniCallHandle&)'
/tmp/servant-e9e6b6.o:(.rodata+0x70): undefined reference to `_impl_IssueAlert::_ptrToInterface(char const*)'
/tmp/servant-e9e6b6.o:(.rodata+0x78): undefined reference to `_impl_IssueAlert::_mostDerivedRepoId()'
/tmp/servant-e9e6b6.o:(.rodata+0xf0): undefined reference to `virtual thunk to _impl_IssueAlert::_ptrToInterface(char const*)'
/tmp/servant-e9e6b6.o:(.rodata+0x100): undefined reference to `virtual thunk to _impl_IssueAlert::_mostDerivedRepoId()'
/tmp/servant-e9e6b6.o:(.rodata+0x120): undefined reference to `virtual thunk to _impl_IssueAlert::_dispatch(omniCallHandle&)'
/tmp/servant-e9e6b6.o:(.rodata+0x288): undefined reference to `typeinfo for POA_IssueAlert'
/tmp/servant-e9e6b6.o:(.rodata+0x290): undefined reference to `POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x298): undefined reference to `POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x2a8): undefined reference to `_impl_IssueAlert::_dispatch(omniCallHandle&)'
/tmp/servant-e9e6b6.o:(.rodata+0x2b0): undefined reference to `_impl_IssueAlert::_ptrToInterface(char const*)'
/tmp/servant-e9e6b6.o:(.rodata+0x2b8): undefined reference to `_impl_IssueAlert::_mostDerivedRepoId()'
/tmp/servant-e9e6b6.o:(.rodata+0x318): undefined reference to `typeinfo for POA_IssueAlert'
/tmp/servant-e9e6b6.o:(.rodata+0x320): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x328): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x330): undefined reference to `virtual thunk to _impl_IssueAlert::_ptrToInterface(char const*)'
/tmp/servant-e9e6b6.o:(.rodata+0x340): undefined reference to `virtual thunk to _impl_IssueAlert::_mostDerivedRepoId()'
/tmp/servant-e9e6b6.o:(.rodata+0x360): undefined reference to `virtual thunk to _impl_IssueAlert::_dispatch(omniCallHandle&)'
/tmp/servant-e9e6b6.o:(.rodata+0x3c8): undefined reference to `typeinfo for POA_IssueAlert'
/tmp/servant-e9e6b6.o:(.rodata+0x3d0): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x3d8): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x458): undefined reference to `typeinfo for _impl_IssueAlert'
/tmp/servant-e9e6b6.o:(.rodata+0x460): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x468): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x478): undefined reference to `_impl_IssueAlert::_dispatch(omniCallHandle&)'
/tmp/servant-e9e6b6.o:(.rodata+0x480): undefined reference to `_impl_IssueAlert::_ptrToInterface(char const*)'
/tmp/servant-e9e6b6.o:(.rodata+0x488): undefined reference to `_impl_IssueAlert::_mostDerivedRepoId()'
/tmp/servant-e9e6b6.o:(.rodata+0x4e8): undefined reference to `typeinfo for _impl_IssueAlert'
/tmp/servant-e9e6b6.o:(.rodata+0x4f0): undefined reference to `virtual thunk to _impl_IssueAlert::~_impl_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x4f8): undefined reference to `virtual thunk to _impl_IssueAlert::~_impl_IssueAlert()'
/tmp/servant-e9e6b6.o:(.rodata+0x500): undefined reference to `virtual thunk to _impl_IssueAlert::_ptrToInterface(char const*)'
/tmp/servant-e9e6b6.o:(.rodata+0x510): undefined reference to `virtual thunk to _impl_IssueAlert::_mostDerivedRepoId()'
/tmp/servant-e9e6b6.o:(.rodata+0x530): undefined reference to `virtual thunk to _impl_IssueAlert::_dispatch(omniCallHandle&)'
/tmp/servant-e9e6b6.o:(.rodata+0x6d0): undefined reference to `typeinfo for POA_IssueAlert'
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
Can someone help me with this compilation - unfortuantelly final project i want to do must use C++17 then best will be to stay with this compiler.
Solution found:
clang++ -std=c++17 -Wall -Wextra -Wnarrowing -Wsign-conversion -lomniORB4 -lomnithread -lomniDynamic4 servant.cpp idl/echoSK.cc -o server
It just require to add echoSK.cc into command.
I'm new to the SFML library. I'm trying to compile an example program.
I have got the following sample code from SFML official documentation:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text text("Hello SFML", font, 50);
// Load a music to play
sf::Music music;
if (!music.openFromFile("nice_music.ogg"))
return EXIT_FAILURE;
// Play the music
music.play();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Draw the sprite
window.draw(sprite);
// Draw the string
window.draw(text);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
I tried to compile it with the following command:
g++.exe code.cpp -s -lsfml-main -lsfml-audio-s -lflac \
-lvorbisenc -lvorbisfile -lvorbis -logg -lsfml-network-s \
-lws2_32 -lsfml-graphics-s -lfreetype -lglew32 -ljpeg \
-lsfml-window-s -lopengl32 -lgdi32 -lsfml-system-s -lwinmm \
-lgdi32 -luser32 -lkernel32 -lcomctl32 -lmingw32 \
-luser32 -lgdi32 -ldxguid -mwindows \
-std=c++11 -o code.exe
But I got these linker errors (paths shortened):
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x6de): undefined reference to `_imp__alSourcePlay'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x7c8): undefined reference to `_imp__alSourcePause'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xa66): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xb7a): undefined reference to `_imp__alBufferData'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xb96): undefined reference to `_imp__alSourceQueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xc9d): undefined reference to `_imp__alBufferData'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xcb9): undefined reference to `_imp__alSourceQueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xdd8): undefined reference to `_imp__alGenBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xdfd): undefined reference to `_imp__alSourcePlay'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xed0): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xf0b): undefined reference to `_imp__alSourceUnqueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0xfed): undefined reference to `_imp__alGetBufferi'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x100a): undefined reference to `_imp__alGetBufferi'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x1160): undefined reference to `_imp__alSourceStop'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x1180): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x11b8): undefined reference to `_imp__alSourceUnqueueBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x11ef): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x1204): undefined reference to `_imp__alDeleteBuffers'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x126d): undefined reference to `_imp__alSourcePause'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x12e7): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundStream.cpp.obj):SoundStream.cpp:(.text+0x12f1): undefined reference to `_imp__alSourceUnqueueBuffers'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0xe): undefined reference to `_imp__alcOpenDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x2c): undefined reference to `_imp__alcCreateContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x42): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x9b): undefined reference to `_imp__alListenerf'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0xc6): undefined reference to `_imp__alListener3f'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0xdb): undefined reference to `_imp__alListenerfv'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x19c): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x1ae): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x1c0): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x1f9): undefined reference to `_imp__alListenerf'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x24e): undefined reference to `_imp__alListener3f'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x2e4): undefined reference to `_imp__alListenerfv'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x384): undefined reference to `_imp__alListenerfv'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x445): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x47d): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x48f): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x4a9): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x501): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x521): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x541): undefined reference to `_imp__alGetEnumValue'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x59e): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x5b8): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x5d2): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x6be): undefined reference to `_imp__alIsExtensionPresent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x6e2): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x6f4): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x70d): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x7ae): undefined reference to `_imp__alcIsExtensionPresent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x807): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x820): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text+0x839): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text$_ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev[__ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev]+0x13): undefined reference to `_imp__alcMakeContextCurrent'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text$_ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev[__ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev]+0x25): undefined reference to `_imp__alcDestroyContext'
../lib32/libsfml-audio-s.a(AudioDevice.cpp.obj):AudioDevice.cpp:(.text$_ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev[__ZNSt8auto_ptrIN2sf4priv11AudioDeviceEED1Ev]+0x37): undefined reference to `_imp__alcCloseDevice'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x62): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x7a): undefined reference to `_imp__alDeleteSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x132): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x14a): undefined reference to `_imp__alDeleteSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x21b): undefined reference to `_imp__alGenSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x23b): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x2f1): undefined reference to `_imp__alGenSources'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x30b): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x330): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x356): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x412): undefined reference to `_imp__alGetSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x44b): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x46e): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x58b): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x5c1): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x5fb): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x63b): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x66c): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x69b): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x6cb): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x6fb): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x72b): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x776): undefined reference to `_imp__alGetSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x7ab): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x7db): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x80b): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x82b): undefined reference to `_imp__alGetSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x84f): undefined reference to `_imp__alSourcef'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x8da): undefined reference to `_imp__alGetSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x906): undefined reference to `_imp__alSource3f'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x91e): undefined reference to `_imp__alGetSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x941): undefined reference to `_imp__alSourcei'
../lib32/libsfml-audio-s.a(SoundSource.cpp.obj):SoundSource.cpp:(.text+0x9db): undefined reference to `_imp__alGetSourcei'
collect2.exe: error: ld returned 1 exit status
I think it's due to improper order of static libraries in the compile command. What is the correct order for linking static SFML libraries?
Your library order is fine (just having a quick look at it). You just forgot to link OpenAL (under Windows this would be -lOpenAL32), which is something to notice since all the undefined references start with _imp__al. Once done, everything should link and run as expected.
I am new to using CImg and boost. I am getting undefined symbol references as mentioned below, in the code also shared below.
I am using this command line to build it: g++ -lboost_filesystem -lboost_system -L/usr/X11R6/lib -lm -lpthread -lX11 grayscaleConvertor.cpp &> errLog.txt
I am using the -l args in the compiler command. eg: -lboost_filesystem which I read on another post in stackoverflow, but that is not helping resolve the boost::filesystem:: symbols
locate CImg : /usr/include/CImg.h
locate boost: /usr/include/boost (plus more lines)
errLog.txt
/tmp/ccRIIPim.o: In function main':
grayscaleConvertor.cpp:(.text+0x179): undefined reference toboost::filesystem::path::extension() const'
grayscaleConvertor.cpp:(.text+0x213): undefined reference to boost::filesystem::path::filename() const'
/tmp/ccRIIPim.o: In function__static_initialization_and_destruction_0(int, int)':
grayscaleConvertor.cpp:(.text+0x68e): undefined reference to boost::system::generic_category()'
grayscaleConvertor.cpp:(.text+0x698): undefined reference toboost::system::generic_category()'
grayscaleConvertor.cpp:(.text+0x6a2): undefined reference to boost::system::system_category()'
/tmp/ccRIIPim.o: In functionboost::system::error_code::error_code()':
grayscaleConvertor.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x10): undefined reference to boost::system::system_category()'
/tmp/ccRIIPim.o: In functionboost::system::error_code::clear()':
grayscaleConvertor.cpp:(.text._ZN5boost6system10error_code5clearEv[_ZN5boost6system10error_code5clearEv]+0x10): undefined reference to boost::system::system_category()'
/tmp/ccRIIPim.o: In functionboost::filesystem::path::compare(std::__cxx11::basic_string, std::allocator > const&) const':
grayscaleConvertor.cpp:(.text._ZNK5boost10filesystem4path7compareERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNK5boost10filesystem4path7compareERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x3b): undefined reference to boost::filesystem::path::compare(boost::filesystem::path const&) const'
/tmp/ccRIIPim.o: In functionboost::filesystem::exists(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem6existsERKNS0_4pathE[_ZN5boost10filesystem6existsERKNS0_4pathE]+0x24): undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::is_directory(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem12is_directoryERKNS0_4pathE[_ZN5boost10filesystem12is_directoryERKNS0_4pathE]+0x24): undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::is_regular_file(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem15is_regular_fileERKNS0_4pathE[_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE]+0x24): undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_entry::status(boost::system::error_code&) const':
grayscaleConvertor.cpp:(.text._ZNK5boost10filesystem15directory_entry6statusERNS_6system10error_codeE[_ZNK5boost10filesystem15directory_entry6statusERNS_6system10error_codeE]+0x31): undefined reference to boost::filesystem::directory_entry::m_get_status(boost::system::error_code*) const'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_entry::symlink_status(boost::system::error_code&) const':
grayscaleConvertor.cpp:(.text._ZNK5boost10filesystem15directory_entry14symlink_statusERNS_6system10error_codeE[_ZNK5boost10filesystem15directory_entry14symlink_statusERNS_6system10error_codeE]+0x31): undefined reference to boost::filesystem::directory_entry::m_get_symlink_status(boost::system::error_code*) const'
/tmp/ccRIIPim.o: In functionboost::filesystem::detail::dir_itr_imp::~dir_itr_imp()':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem6detail11dir_itr_impD2Ev[_ZN5boost10filesystem6detail11dir_itr_impD5Ev]+0x2e): undefined reference to boost::filesystem::detail::dir_itr_close(void*&, void*&)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathE[_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathE]+0x4a): undefined reference to boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&, boost::system::error_code&)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathERNS_6system10error_codeE[_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathERNS_6system10error_codeE]+0x4b): undefined reference to boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functionboost::filesystem::directory_iterator::increment()':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem18directory_iterator9incrementEv[_ZN5boost10filesystem18directory_iterator9incrementEv]+0xf): undefined reference to boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)'
/tmp/ccRIIPim.o: In functioncimg_library::cimg::Mutex_info::trylock(unsigned int)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library4cimg10Mutex_info7trylockEj[_ZN12cimg_library4cimg10Mutex_info7trylockEj]+0x1c): undefined reference to pthread_mutex_trylock'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::screen_width()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x26): undefined reference to XOpenDisplay'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x96): undefined reference toXCloseDisplay'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::screen_height()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x26): undefined reference toXOpenDisplay'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x96): undefined reference to XCloseDisplay'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_handle_events(_XEvent const*)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0xb5): undefined reference to XUnmapWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x112): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x1f0): undefined reference to XResizeWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x2c2): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x317): undefined reference to XGetWindowAttributes'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x335): undefined reference toXSync'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x356): undefined reference to XSetInputFocus'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x472): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x5c4): undefined reference to XCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x601): undefined reference toXLookupString'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x635): undefined reference to XQueryKeymap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x6d8): undefined reference toXLookupString'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x71b): undefined reference to XCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x7f0): undefined reference toXCheckWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x861): undefined reference to XCheckWindowEvent'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_events_thread(void*)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x6a): undefined reference to XCheckTypedEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x94): undefined reference toXCheckMaskEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x14c): undefined reference to pthread_testcancel'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay13_set_colormapERmj[_ZN12cimg_library11CImgDisplay13_set_colormapERmj]+0x2a2): undefined reference to XStoreColors'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_map_window()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x50): undefined reference to XMapRaised'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x74): undefined reference toXWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xcb): undefined reference to XGetWindowAttributes'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xe9): undefined reference toXSync'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::_paint(bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0xcd): undefined reference toXSendEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0x130): undefined reference to XPutImage'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_init_fullscreen()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0xfe): undefined reference to XCreateWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x1df): undefined reference toXCreateImage'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x208): undefined reference to XSelectInput'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x226): undefined reference toXMapRaised'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x24a): undefined reference to XWindowEvent'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x2c1): undefined reference toXPutImage'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x2e6): undefined reference to XGetWindowAttributes'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x304): undefined reference toXSync'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::_desinit_fullscreen()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x28): undefined reference toXUngrabKeyboard'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x4d): undefined reference to XDestroyWindow'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xf7): undefined reference to XOpenDisplay'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x330): undefined reference toXVisualIDFromVisual'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x34b): undefined reference to XGetVisualInfo'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x392): undefined reference toXFree'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x3d2): undefined reference to pthread_create'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x57c): undefined reference toXCreateWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x5e3): undefined reference to XCreateSimpleWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x614): undefined reference toXSelectInput'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x650): undefined reference to XStoreName'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x6ab): undefined reference toXCreateColormap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x703): undefined reference to XSetWindowColormap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x70b): undefined reference toXAllocClassHint'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x741): undefined reference to XSetClassHint'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x74f): undefined reference toXFree'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x84a): undefined reference to XCreateImage'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x870): undefined reference toXInternAtom'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x896): undefined reference to XInternAtom'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x8ce): undefined reference toXSetWMProtocols'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x902): undefined reference to XGrabKeyboard'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::assign()':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x10c): undefined reference to XDestroyWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x17b): undefined reference toXFreeColormap'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x198): undefined reference to XSync'
/tmp/ccRIIPim.o: In functioncimg_library::CImgDisplay::resize(int, int, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x208): undefined reference to XResizeWindow'
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x227): undefined reference toXGetWindowAttributes'
/tmp/ccRIIPim.o: In function cimg_library::CImgDisplay::move(int, int)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay4moveEii[_ZN12cimg_library11CImgDisplay4moveEii]+0x72): undefined reference toXMoveWindow'
/tmp/ccRIIPim.o: In function void cimg_library::CImgDisplay::_resize<unsigned char>(unsigned char, unsigned int, unsigned int, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeIhEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeIhEEvT_jjb]+0x106): undefined reference toXCreateImage'
/tmp/ccRIIPim.o: In function void cimg_library::CImgDisplay::_resize<unsigned short>(unsigned short, unsigned int, unsigned int, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeItEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeItEEvT_jjb]+0x10b): undefined reference toXCreateImage'
/tmp/ccRIIPim.o: In function void cimg_library::CImgDisplay::_resize<unsigned int>(unsigned int, unsigned int, unsigned int, bool)':
grayscaleConvertor.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeIjEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeIjEEvT_jjb]+0x106): undefined reference toXCreateImage'
/tmp/ccRIIPim.o: In function boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*)':
grayscaleConvertor.cpp:(.text._ZN5boost10filesystem4pathC2INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x21): undefined reference toboost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__cxx11::basic_string, std::allocator >&)'
collect2: error: ld returned 1 exit status
grayscaleConvertor.cpp
#define BOOST_FILESYSTEM_VERSION 3
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
#include "CImg.h"
#include <iostream>
#include <string>
using namespace cimg_library;
using namespace std;
namespace fs = ::boost::filesystem;
int main()
{
const string ext = ".png";
fs::path root("/Downloads/testdata1/");
if(!fs::exists(root) || !fs::is_directory(root)) return -1;
fs::recursive_directory_iterator it(root);
fs::recursive_directory_iterator endit;
while(it != endit)
{
if(fs::is_regular_file(*it) && it->path().extension()==ext)
{
CImg<unsigned char> image(it->path().filename().string().c_str()),
gray(image.width(), image.height(), 1, 1, 0),
grayWeight(image.width(), image.height(), 1, 1, 0),
imgR(image.width(), image.height(), 1, 3, 0),
imgG(image.width(), image.height(), 1, 3, 0),
imgB(image.width(), image.height(), 1, 3, 0);
}
++it;
}
return 0;
}
I am very new to c++ and OpenGL so I am not sure 100% what I am doing yet...
So, I copied the following code from This page:
#include <GLFW/glfw3.h>
int main(void) {
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window) {
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window)) {
/* Render here */
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
When I run it in netbeans, I get the follow errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/ryan/NetBeansProjects/Test3D'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/test3d
make[2]: Entering directory `/home/ryan/NetBeansProjects/Test3D'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/main.o.d"
g++ -c -g `pkg-config --cflags glfw3` `pkg-config --cflags x11` -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/test3d build/Debug/GNU-Linux-x86/main.o `pkg-config --libs glfw3` `pkg-config --libs x11`
/usr/local/lib/libglfw3.a(context.c.o): In function `parseGLVersion':
context.c:(.text+0x53): undefined reference to `glGetString'
/usr/local/lib/libglfw3.a(context.c.o): In function `_glfwRefreshContextAttribs':
context.c:(.text+0x8d3): undefined reference to `glGetIntegerv'
context.c:(.text+0x956): undefined reference to `glGetIntegerv'
context.c:(.text+0x9c9): undefined reference to `glGetIntegerv'
context.c:(.text+0xa1e): undefined reference to `glGetIntegerv'
/usr/local/lib/libglfw3.a(context.c.o): In function `glfwExtensionSupported':
context.c:(.text+0xd29): undefined reference to `glGetString'
context.c:(.text+0xd88): undefined reference to `glGetIntegerv'
/usr/local/lib/libglfw3.a(window.c.o): In function `glfwCreateWindow':
window.c:(.text+0x724): undefined reference to `glClear'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwInitGammaRamp':
x11_gamma.c:(.text+0x49): undefined reference to `XRRGetScreenResources'
x11_gamma.c:(.text+0x6a): undefined reference to `XRRGetCrtcGammaSize'
x11_gamma.c:(.text+0x81): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwPlatformGetGammaRamp':
x11_gamma.c:(.text+0xce): undefined reference to `XRRGetCrtcGammaSize'
x11_gamma.c:(.text+0xf1): undefined reference to `XRRGetCrtcGamma'
x11_gamma.c:(.text+0x17d): undefined reference to `XRRFreeGamma'
x11_gamma.c:(.text+0x1a5): undefined reference to `XF86VidModeGetGammaRampSize'
x11_gamma.c:(.text+0x1f3): undefined reference to `XF86VidModeGetGammaRamp'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwPlatformSetGammaRamp':
x11_gamma.c:(.text+0x231): undefined reference to `XRRAllocGamma'
x11_gamma.c:(.text+0x2cd): undefined reference to `XRRSetCrtcGamma'
x11_gamma.c:(.text+0x2d9): undefined reference to `XRRFreeGamma'
x11_gamma.c:(.text+0x321): undefined reference to `XF86VidModeSetGammaRamp'
/usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x15f2): undefined reference to `XF86VidModeQueryExtension'
x11_init.c:(.text+0x1611): undefined reference to `XRRQueryExtension'
x11_init.c:(.text+0x163b): undefined reference to `XRRQueryVersion'
x11_init.c:(.text+0x16cf): undefined reference to `XIQueryVersion'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwSetVideoMode':
x11_monitor.c:(.text+0x176): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x19b): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x1bd): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0x3c3): undefined reference to `XRRSetCrtcConfig'
x11_monitor.c:(.text+0x3cf): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x3db): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x3e7): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwRestoreVideoMode':
x11_monitor.c:(.text+0x432): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x457): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x4cc): undefined reference to `XRRSetCrtcConfig'
x11_monitor.c:(.text+0x4d8): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x4e4): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetMonitors':
x11_monitor.c:(.text+0x543): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x560): undefined reference to `XRRGetOutputPrimary'
x11_monitor.c:(.text+0x5b8): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x5d3): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x642): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0x65f): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x66b): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x6ff): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x70b): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x72f): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetMonitorPos':
x11_monitor.c:(.text+0x8b3): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x8d8): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x910): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x91c): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetVideoModes':
x11_monitor.c:(.text+0x9be): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x9e0): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0xb6d): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0xb79): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetVideoMode':
x11_monitor.c:(.text+0xc51): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0xc76): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0xccb): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0xcd7): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_window.c.o): In function `createWindow':
x11_window.c:(.text+0x6dc): undefined reference to `XISelectEvents'
x11_window.c:(.text+0x71e): undefined reference to `XRRSelectInput'
/usr/local/lib/libglfw3.a(x11_window.c.o): In function `processEvent':
x11_window.c:(.text+0x1784): undefined reference to `XRRUpdateConfiguration'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `getFBConfigAttrib':
glx_context.c:(.text+0x4d): undefined reference to `glXGetFBConfigAttrib'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `chooseFBConfig':
glx_context.c:(.text+0x7a): undefined reference to `glXGetClientString'
glx_context.c:(.text+0xe5): undefined reference to `glXGetFBConfigs'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `createLegacyContext':
glx_context.c:(.text+0x41f): undefined reference to `glXCreateNewContext'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwInitContextAPI':
glx_context.c:(.text+0x434): undefined reference to `pthread_key_create'
glx_context.c:(.text+0x46f): undefined reference to `glXQueryExtension'
glx_context.c:(.text+0x4aa): undefined reference to `glXQueryVersion'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwTerminateContextAPI':
glx_context.c:(.text+0x69e): undefined reference to `pthread_key_delete'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwCreateContext':
glx_context.c:(.text+0x780): undefined reference to `glXGetVisualFromFBConfig'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwDestroyContext':
glx_context.c:(.text+0xda8): undefined reference to `glXDestroyContext'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwPlatformMakeContextCurrent':
glx_context.c:(.text+0xdf4): undefined reference to `glXMakeCurrent'
glx_context.c:(.text+0xe0f): undefined reference to `glXMakeCurrent'
glx_context.c:(.text+0xe23): undefined reference to `pthread_setspecific'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwPlatformGetCurrentContext':
glx_context.c:(.text+0xe36): undefined reference to `pthread_getspecific'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwPlatformSwapBuffers':
glx_context.c:(.text+0xe61): undefined reference to `glXSwapBuffers'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwPlatformExtensionSupported':
glx_context.c:(.text+0xf04): undefined reference to `glXQueryExtensionsString'
/usr/local/lib/libglfw3.a(glx_context.c.o): In function `_glfwPlatformGetProcAddress':
glx_context.c:(.text+0xf4c): undefined reference to `glXGetProcAddressARB'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/test3d] Error 1
make[2]: Leaving directory `/home/ryan/NetBeansProjects/Test3D'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/ryan/NetBeansProjects/Test3D'
make: *** [.build-impl] Error 2
I am not sure what this means 100%, but I am assuming I don't have some packages added to the project.
However, I was able to install and run a program following thsese steps: https://stackoverflow.com/a/17772217/1778465 which links to here http://www.glfw.org/docs/3.0/quick.html, so I know that GLFW works.
Your build settings lack to specify to link with the OpenGL interface library. When compiling for
Windows → opengl32.lib → -lopengl32
X11/GLX (Linux / *BSD / *Solaris) → libGL.so -lGL
MacOS X → OpenGL Framework → -framework OpenGL
I'm trying to compile the message pack (http://msgpack.org/) example code and keep getting these errors which I can't get to the bottom of:
g++ -o"MsgPack2" ./src/MsgPack2.o -lmsgpack -lmsgpackc
./src/MsgPack2.o: In function `main':
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:38:
undefined reference to msgpack::rpc::server::listen(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, unsigned
short)'
./src/MsgPack2.o: In functionloop':
/usr/local/include/msgpack/rpc/loop.h:30: undefined reference to
mp::wavy::loop::loop()'
./src/MsgPack2.o: In functionbase':
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::server(msgpack::rpc::loop)'
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::serve(msgpack::rpc::dispatcher*)'
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::~server()'
./src/MsgPack2.o: In function~base':
/usr/local/include/msgpack/rpc/server.h:64: undefined reference to
msgpack::rpc::server::~server()'
./src/MsgPack2.o: In function
myserver::dispatch(msgpack::rpc::request)':
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:14:
undefined reference to msgpack::rpc::request::method()'
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:18:
undefined reference tomsgpack::rpc::request::params()'
./src/MsgPack2.o: In function
msgpack::rpc::loop_util<msgpack::rpc::session_pool>::run(unsigned
long)':
/usr/local/include/msgpack/rpc/loop_util.h:34: undefined reference
tomsgpack::rpc::session_pool::get_loop()'
/usr/local/include/msgpack/rpc/loop_util.h:34: undefined reference
to mp::wavy::loop::run(unsigned long)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call(int&,
msgpack::type::nil&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call(msgpack::type::nil&, unsigned char&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call, std::allocator >
(msgpack::type::nil&, std::basic_string,
std::allocator >&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In function__shared_count':
/usr/include/c++/4.5/tr1/shared_ptr.h:121: undefined reference to
mp::wavy::loop::~loop()'
./src/MsgPack2.o: In function
std::tr1::_Sp_deleter::operator()(mp::wavy::loop*)
const':
/usr/include/c++/4.5/tr1/shared_ptr.h:99: undefined reference to
`mp::wavy::loop::~loop()'
collect2: ld returned 1 exit status
make: * [MsgPack2] Error 1
And here is the code:
#include <msgpack/rpc/server.h>
class myserver : public msgpack::rpc::server::base {
public:
void add(msgpack::rpc::request req, int a1, int a2)
{
req.result(a1 + a2);
}
public:
void dispatch(msgpack::rpc::request req)
try {
std::string method;
req.method().convert(&method);
if(method == "add") {
msgpack::type::tuple<int, int> params;
req.params().convert(¶ms);
add(req, params.get<0>(), params.get<1>());
} else {
req.error(msgpack::rpc::NO_METHOD_ERROR);
}
} catch (msgpack::type_error& e) {
req.error(msgpack::rpc::ARGUMENT_ERROR);
return;
} catch (std::exception& e) {
req.error(std::string(e.what()));
return;
}
};
int main(void)
{
myserver svr;
svr.instance.listen("127.0.0.1", 80800);
svr.instance.run(4); // run 4 threads
return 0;
}
If anyone has any ideas, it would be greatly appreciated.
Many thanks in advance,
You need -lmsgpack-rpc.
[Side note: 80800 is not a valid port.]