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
Related
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
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'm trying to configure and build a sample of node.js addon. The sample was taken from node.js documentation and the source code can be found here
https://github.com/nodejs/node-addon-examples/tree/master/8_passing_wrapped/node_0.12
When I try to compile this in CLion (on Ubuntu 14.04) or when I use node-gyp to build it I've got some errors:
/home/smorzhov/Documents/clion-2016.1/bin/cmake/bin/cmake --build /home/smorzhov/.CLion2016.1/system/cmake/generated/test4-94ee4803/94ee4803/Debug --target all -- -j 4
[ 25%] Linking CXX executable test4
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::Init(v8::Isolate*)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:26: undefined reference to `v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:27: undefined reference to `v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:27: undefined reference to `v8::FunctionTemplate::SetClassName(v8::Local<v8::String>)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:28: undefined reference to `v8::FunctionTemplate::InstanceTemplate()'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:28: undefined reference to `v8::ObjectTemplate::SetInternalFieldCount(int)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:30: undefined reference to `v8::FunctionTemplate::GetFunction()'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:30: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Function>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Function>::New(v8::Isolate*, v8::Function*)':
/usr/include/node/v8.h:7176: undefined reference to `v8::V8::GlobalizeReference(v8::internal::Isolate*, v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `Reset<v8::Function>':
/usr/include/node/v8.h:7235: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::New(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:38: undefined reference to `v8::Value::NumberValue() const'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::PersistentBase<v8::Function> const&)':
/usr/include/node/v8.h:7124: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::Function*)':
/usr/include/node/v8.h:7134: undefined reference to `v8::HandleScope::CreateHandle(v8::internal::Isolate*, v8::internal::Object*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::New(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:47: undefined reference to `v8::Function::NewInstance(int, v8::Local<v8::Value>*) const'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::PersistentBase<v8::Function> const&)':
/usr/include/node/v8.h:7124: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::Function*)':
/usr/include/node/v8.h:7134: undefined reference to `v8::HandleScope::CreateHandle(v8::internal::Isolate*, v8::internal::Object*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::NewInstance(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:57: undefined reference to `v8::Function::NewInstance(int, v8::Local<v8::Value>*) const'
CMakeFiles/test4.dir/myobject.cpp.o: In function `ClearWeak<void>':
/usr/include/node/v8.h:7298: undefined reference to `v8::V8::ClearWeak(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `node::ObjectWrap::Wrap(v8::Local<v8::Object>)':
/usr/include/node/node_object_wrap.h:56: undefined reference to `v8::Object::InternalFieldCount()'
/usr/include/node/node_object_wrap.h:57: undefined reference to `v8::Object::SetAlignedPointerInInternalField(int, void*)'
/usr/include/node/node_object_wrap.h:58: undefined reference to `v8::Isolate::GetCurrent()'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::New(v8::Isolate*, v8::Object*)':
/usr/include/node/v8.h:7176: undefined reference to `v8::V8::GlobalizeReference(v8::internal::Isolate*, v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `SetWeak<v8::Object, node::ObjectWrap>':
/usr/include/node/v8.h:7257: undefined reference to `v8::V8::MakeWeak(v8::internal::Object**, void*, void (*)(v8::WeakCallbackData<v8::Value, void> const&))'
CMakeFiles/test4.dir/myobject.cpp.o: In function `ClearWeak<void>':
/usr/include/node/v8.h:7298: undefined reference to `v8::V8::ClearWeak(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `node::ObjectWrap::WeakCallback(v8::WeakCallbackData<v8::Object, node::ObjectWrap> const&)':
/usr/include/node/node_object_wrap.h:101: undefined reference to `v8::HandleScope::HandleScope(v8::Isolate*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Object>::New(v8::Isolate*, v8::Object*)':
/usr/include/node/v8.h:7134: undefined reference to `v8::HandleScope::CreateHandle(v8::internal::Isolate*, v8::internal::Object*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `node::ObjectWrap::WeakCallback(v8::WeakCallbackData<v8::Object, node::ObjectWrap> const&)':
/usr/include/node/node_object_wrap.h:108: undefined reference to `v8::HandleScope::~HandleScope()'
/usr/include/node/node_object_wrap.h:108: undefined reference to `v8::HandleScope::~HandleScope()'
CMakeFiles/test4.dir/addon.cpp.o: In function `demo::Add(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/addon.cpp:27: undefined reference to `v8::Number::New(v8::Isolate*, double)'
CMakeFiles/test4.dir/addon.cpp.o: In function `demo::InitAll(v8::Local<v8::Object>)':
/home/smorzhov/ClionProjects/test4/test4/addon.cpp:31: undefined reference to `v8::Object::GetIsolate()'
CMakeFiles/test4.dir/addon.cpp.o: In function `_register_addon':
/home/smorzhov/ClionProjects/test4/test4/addon.cpp:37: undefined reference to `node_module_register'
CMakeFiles/test4.dir/addon.cpp.o: In function `v8::Value::ToObject() const':
/usr/include/node/v8.h:7778: undefined reference to `v8::Isolate::GetCurrent()'
/usr/include/node/v8.h:7778: undefined reference to `v8::Isolate::GetCurrentContext()'
/usr/include/node/v8.h:7779: undefined reference to `v8::Value::ToObject(v8::Local<v8::Context>) const'
CMakeFiles/test4.dir/addon.cpp.o: In function `demo::MyObject* node::ObjectWrap::Unwrap<demo::MyObject>(v8::Local<v8::Object>)':
/usr/include/node/node_object_wrap.h:29: undefined reference to `v8::Object::InternalFieldCount()'
CMakeFiles/test4.dir/addon.cpp.o: In function `v8::Object::GetAlignedPointerFromInternalField(int)':
/usr/include/node/v8.h:7636: undefined reference to `v8::Object::SlowGetAlignedPointerFromInternalField(int)'
CMakeFiles/test4.dir/addon.cpp.o: In function `void node::NODE_SET_METHOD<v8::Local<v8::Object> >(v8::Local<v8::Object> const&, char const*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&))':
/usr/include/node/node.h:239: undefined reference to `v8::Isolate::GetCurrent()'
/usr/include/node/node.h:240: undefined reference to `v8::HandleScope::HandleScope(v8::Isolate*)'
/usr/include/node/node.h:242: undefined reference to `v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int)'
/usr/include/node/node.h:243: undefined reference to `v8::FunctionTemplate::GetFunction()'
/usr/include/node/node.h:244: undefined reference to `v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)'
/usr/include/node/node.h:245: undefined reference to `v8::Function::SetName(v8::Local<v8::String>)'
/usr/include/node/node.h:246: undefined reference to `v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)'
/usr/include/node/node.h:246: undefined reference to `v8::HandleScope::~HandleScope()'
/usr/include/node/node.h:246: undefined reference to `v8::HandleScope::~HandleScope()'
collect2: error: ld returned 1 exit status
make[2]: *** [test4] Error 1
make[1]: *** [CMakeFiles/test4.dir/all] Error 2
make: *** [all] Error 2
Maybe it is important, the IDE don't understand
#include node.h
and I have to change it to #include node/node.h
It seems, that compiler sees only node and v8 headers and cannot find their sources.
Can somebody help me to fix that? How to make compiler to see node and v8 sources?
PS. My CmakeLists.txt file
cmake_minimum_required(VERSION 3.3)
project(test4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES addon.cpp main.cpp myobject.cpp myobject.h)
add_executable(test4 ${SOURCE_FILES})
If you follow the README and use node-gyp with the -v flag, you can see that compilation looks like this:
g++ '-DNODE_GYP_MODULE_NAME=addon' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/home/yannick/.node-gyp/5.9.0/include/node -I/home/yannick/.node-gyp/5.9.0/src -I/home/yannick/.node-gyp/5.9.0/deps/uv/include -I/home/yannick/.node-gyp/5.9.0/deps/v8/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++0x -MMD -MF ./Release/.deps/Release/obj.target/addon/myobject.o.d.raw -c -o Release/obj.target/addon/myobject.o ../myobject.cc
So it's a tad more complex that just specifying a few sources : there are several include dirs to be used, that seems specific to the node version you are running, and include an external dependency (libuv)
Why don't you use the build methods suggested by the README ?
code:
#include <pcl/io/pcd_io.h>
#include <pcl/filters/passthrough.h>
int
main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr filteredCloud(new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ>(argv[1], *cloud) != 0)
{
return -1;
}
pcl::PassThrough<pcl::PointXYZ> filter;
filter.setInputCloud(cloud);
filter.setFilterFieldName("z");
filter.setFilterLimits(0.0, 2.0);
filter.filter(*filteredCloud);
}
Cmakelists1.txt: (with support to connect to matlab engine)
Cmakelists2.txt: (no support)
when i build the code with Cmakelists2.txt, I get no errors
But when i build the code with Cmakelists1.txt, I get a huge list of undefined reference errors. Cmakelists1.txt is a superset of Cmakelists2.txt, so whatever builds with 2 should build with 1
The code is a minimalist code & i have removed the matlab part for clarity.
Can anybody help?
Cmakelists1.txt
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(passthrough_test)
find_package(PCL 1.2 REQUIRED)
set (PROJECT_LINK_LIBS libeng.so libmat.so libmx.so libut.so)
link_directories(${PCL_LIBRARY_DIRS} /usr/local/MATLAB/R2014a/bin/glnxa64)
include_directories(${PCL_INCLUDE_DIRS} /usr/local/MATLAB/R2014a/extern/include/)
add_definitions(${PCL_DEFINITIONS})
add_executable (passthrough_test passthrough_test.cpp)
target_link_libraries (passthrough_test ${PCL_LIBRARIES} ${PROJECT_LINK_LIBS})
Cmakelists2.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(passthrough_test)
find_package(PCL 1.2 REQUIRED)
link_directories(${PCL_LIBRARY_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (passthrough_test passthrough_test.cpp)
target_link_libraries (passthrough_test ${PCL_LIBRARIES})
List of errors:
Linking CXX executable passthrough_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/passthrough_test.dir/link.txt --verbose=1
/usr/bin/c++ -Wno-deprecated -g CMakeFiles/passthrough_test.dir/passthrough_test.cpp.o -o passthrough_test -L/usr/local/lib -L/usr/local/MATLAB/R2014a/bin/glnxa64 -rdynamic -lboost_system -lboost_filesystem -lboost_thread -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_chrono -lpthread /usr/local/lib/libpcl_common.so -Wl,-Bstatic -lflann_cpp_s -Wl,-Bdynamic /usr/local/lib/libpcl_kdtree.so /usr/local/lib/libpcl_octree.so /usr/local/lib/libpcl_search.so /usr/local/lib/libpcl_sample_consensus.so /usr/local/lib/libpcl_filters.so -lOpenNI -lOpenNI2 /usr/lib/libvtkCommon.so.5.8.0 /usr/lib/libvtkFiltering.so.5.8.0 /usr/lib/libvtkImaging.so.5.8.0 /usr/lib/libvtkGraphics.so.5.8.0 /usr/lib/libvtkGenericFiltering.so.5.8.0 /usr/lib/libvtkIO.so.5.8.0 /usr/lib/libvtkRendering.so.5.8.0 /usr/lib/libvtkVolumeRendering.so.5.8.0 /usr/lib/libvtkHybrid.so.5.8.0 /usr/lib/libvtkWidgets.so.5.8.0 /usr/lib/libvtkParallel.so.5.8.0 /usr/lib/libvtkInfovis.so.5.8.0 /usr/lib/libvtkGeovis.so.5.8.0 /usr/lib/libvtkViews.so.5.8.0 /usr/lib/libvtkCharts.so.5.8.0 /usr/local/lib/libpcl_io.so /usr/local/lib/libpcl_features.so /usr/local/lib/libpcl_ml.so /usr/local/lib/libpcl_segmentation.so /usr/local/lib/libpcl_visualization.so /usr/local/lib/libpcl_outofcore.so /usr/local/lib/libpcl_cuda_features.so /usr/local/lib/libpcl_cuda_segmentation.so /usr/local/lib/libpcl_cuda_io.so /usr/local/lib/libpcl_cuda_sample_consensus.so -lqhull /usr/local/lib/libpcl_surface.so /usr/local/lib/libpcl_registration.so /usr/local/lib/libpcl_recognition.so /usr/local/lib/libpcl_keypoints.so /usr/local/lib/libpcl_gpu_containers.so /usr/local/lib/libpcl_gpu_utils.so /usr/local/lib/libpcl_gpu_octree.so /usr/local/lib/libpcl_gpu_features.so /usr/local/lib/libpcl_gpu_segmentation.so /usr/local/lib/libpcl_gpu_surface.so /usr/local/lib/libpcl_gpu_kinfu.so /usr/local/lib/libpcl_gpu_kinfu_large_scale.so /usr/local/lib/libpcl_tracking.so /usr/local/lib/libpcl_stereo.so /usr/local/lib/libpcl_people.so /usr/local/lib/libpcl_apps.so /usr/local/lib/libpcl_3d_rec_framework.so -lboost_system -lboost_filesystem -lboost_thread -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_chrono -lpthread -lqhull -lOpenNI -lOpenNI2 -Wl,-Bstatic -lflann_cpp_s -Wl,-Bdynamic /usr/lib/libvtkCommon.so.5.8.0 /usr/lib/libvtkFiltering.so.5.8.0 /usr/lib/libvtkImaging.so.5.8.0 /usr/lib/libvtkGraphics.so.5.8.0 /usr/lib/libvtkGenericFiltering.so.5.8.0 /usr/lib/libvtkIO.so.5.8.0 /usr/lib/libvtkRendering.so.5.8.0 /usr/lib/libvtkVolumeRendering.so.5.8.0 /usr/lib/libvtkHybrid.so.5.8.0 /usr/lib/libvtkWidgets.so.5.8.0 /usr/lib/libvtkParallel.so.5.8.0 /usr/lib/libvtkInfovis.so.5.8.0 /usr/lib/libvtkGeovis.so.5.8.0 /usr/lib/libvtkViews.so.5.8.0 /usr/lib/libvtkCharts.so.5.8.0 -leng -lmat -lmx -lut /usr/local/lib/libpcl_common.so /usr/local/lib/libpcl_kdtree.so /usr/local/lib/libpcl_octree.so /usr/local/lib/libpcl_search.so /usr/local/lib/libpcl_sample_consensus.so /usr/local/lib/libpcl_filters.so /usr/local/lib/libpcl_io.so /usr/local/lib/libpcl_features.so /usr/local/lib/libpcl_ml.so /usr/local/lib/libpcl_segmentation.so /usr/local/lib/libpcl_visualization.so /usr/local/lib/libpcl_outofcore.so /usr/local/lib/libpcl_cuda_features.so /usr/local/lib/libpcl_cuda_segmentation.so /usr/local/lib/libpcl_cuda_io.so /usr/local/lib/libpcl_cuda_sample_consensus.so /usr/local/lib/libpcl_surface.so /usr/local/lib/libpcl_registration.so /usr/local/lib/libpcl_recognition.so /usr/local/lib/libpcl_keypoints.so /usr/local/lib/libpcl_gpu_containers.so /usr/local/lib/libpcl_gpu_utils.so /usr/local/lib/libpcl_gpu_octree.so /usr/local/lib/libpcl_gpu_features.so /usr/local/lib/libpcl_gpu_segmentation.so /usr/local/lib/libpcl_gpu_surface.so /usr/local/lib/libpcl_gpu_kinfu.so /usr/local/lib/libpcl_gpu_kinfu_large_scale.so /usr/local/lib/libpcl_tracking.so /usr/local/lib/libpcl_stereo.so /usr/local/lib/libpcl_people.so /usr/local/lib/libpcl_apps.so /usr/local/lib/libpcl_3d_rec_framework.so -leng -lmat -lmx -lut /usr/lib/libvtkViews.so.5.8.0 /usr/lib/libvtkInfovis.so.5.8.0 /usr/lib/libvtkWidgets.so.5.8.0 /usr/lib/libvtkVolumeRendering.so.5.8.0 /usr/lib/libvtkHybrid.so.5.8.0 /usr/lib/libvtkParallel.so.5.8.0 /usr/lib/libvtkRendering.so.5.8.0 /usr/lib/libvtkImaging.so.5.8.0 /usr/lib/libvtkGraphics.so.5.8.0 /usr/lib/libvtkIO.so.5.8.0 /usr/lib/libvtkFiltering.so.5.8.0 /usr/lib/libvtkCommon.so.5.8.0 -lm /usr/lib/libvtksys.so.5.8.0 -ldl -Wl,-rpath,/usr/local/lib:/usr/local/MATLAB/R2014a/bin/glnxa64
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFReadDirectory#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_CTX_use_certificate_chain_file#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFIsTiled#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_get_error#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_use_PrivateKey_file#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_set_ex_data#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFScanlineSize#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `X509_STORE_set_flags#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `X509_get_subject_name#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `ENGINE_load_private_key#OPENSSL_1.0.0'
make[2]: Leaving directory `/home/shome/temp_codes/passthrough_test/build'
//usr/lib/libpq.so.5: undefined reference to `CRYPTO_set_id_callback#OPENSSL_1.0.0'
make[1]: Leaving directory `/home/shome/temp_codes/passthrough_test/build'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFClose#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_CTX_get_cert_store#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFGetFieldDefaulted#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_check_private_key#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `ENGINE_by_id#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `CRYPTO_set_locking_callback#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `X509_NAME_get_text_by_NID#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_write#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `X509_free#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_free#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_ctrl#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_set_verify#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_set_fd#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_use_PrivateKey#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFSetWarningHandler#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `ENGINE_finish#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `_TIFFmalloc#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_get_peer_certificate#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `CRYPTO_num_locks#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_use_certificate_file#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `ENGINE_free#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `OPENSSL_config#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `X509_STORE_load_locations#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFDefaultStripSize#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFReadTile#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_read#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `_TIFFfree#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFGetField#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFClientOpen#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_CTX_new#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFNumberOfDirectories#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `ERR_get_error#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `TLSv1_method#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_new#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_load_error_strings#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFOpen#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFReadRGBAImage#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_CTX_load_verify_locations#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFSetField#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `ENGINE_init#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `ERR_reason_error_string#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_connect#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_CTX_ctrl#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_pending#OPENSSL_1.0.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_library_init#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFSetDirectory#LIBTIFF_4.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFReadScanline#LIBTIFF_4.0'
//usr/lib/libpq.so.5: undefined reference to `SSL_shutdown#OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.8.0: undefined reference to `TIFFNumberOfTiles#LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
make[2]: *** [passthrough_test] Error 1
make[1]: *** [CMakeFiles/passthrough_test.dir/all] Error 2
make: *** [all] Error 2
Trying to compile a cpp program in I run into the following linking errors:
11:42:55 **** Incremental Build of configuration Debug for project mrconv ****
Info: Internal Builder is used for build
g++ "-IC:\\Users\\Jesse\\Documents\\Work\\Research\\FiberTracking\\Software\\mrtrix\\source\\mrtrix-0.2.11\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\bin" "-IC:\\Users\\Jesse\\Programs\\gtk+\\include\\glib-2.0" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib\\glib-2.0\\include" "-IC:\\gtkmm64\\include\\glibmm-2.4\\glibmm" "-IC:\\gtkmm64\\include\\glibmm-2.4" "-IC:\\gtkmm64\\lib\\glibmm-2.4\\include" "-IC:\\gtkmm64\\include\\sigc++-2.0" "-IC:\\gtkmm64\\lib\\sigc++-2.0\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include\\gsl" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\mrconvert.o" "..\\src\\mrconvert.cpp"
g++ "-LC:\\GnuWin32\\lib\\" -o mrconv.exe "src\\mrconvert.o" -llibgsl
src\mrconvert.o: In function `main':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:119: undefined reference to `MR::App::run(int, char**)'
src\mrconvert.o: In function `ZN5MyApp7executeEv':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:123: undefined reference to `MR::parse_floats(std::string const&)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:167: undefined reference to `MR::DataType::parse(std::string const&)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:174: undefined reference to `MR::Image::parse_axes_specifier(MR::Image::Axes const&, std::string const&)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:201: undefined reference to `MR::parse_ints(std::string const&, int)'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:225: undefined reference to `MR::ProgressBar::init(unsigned int, std::string const&)'
src\mrconvert.o: In function `_static_initialization_and_destruction_0':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:55: undefined reference to `MR::Argument::End'
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:95: undefined reference to `MR::Option::End'
src\mrconvert.o: In function `ZNK2MR9Exception7displayEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:187: undefined reference to `MR::Exception::level_offset'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:187: undefined reference to `MR::error'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:188: undefined reference to `MR::Exception::level_offset'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:188: undefined reference to `MR::info'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:189: undefined reference to `MR::debug'
src\mrconvert.o: In function `ZN2MR11ProgressBar3incEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:451: undefined reference to `MR::ProgressBar::current_val'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:451: undefined reference to `MR::ProgressBar::current_val'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:452: undefined reference to `MR::ProgressBar::display'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:452: undefined reference to `MR::ProgressBar::stop'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::multiplier'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::stop_watch'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `Glib::Timer::elapsed() const'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::current_val'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:453: undefined reference to `MR::ProgressBar::multiplier'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:454: undefined reference to `MR::ProgressBar::percent'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:455: undefined reference to `MR::ProgressBar::percent'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:456: undefined reference to `MR::ProgressBar::display_func'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:458: undefined reference to `MR::ProgressBar::stop'
src\mrconvert.o: In function `ZN2MR11ProgressBar4doneEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:461: undefined reference to `MR::ProgressBar::display'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/mrtrix.h:461: undefined reference to `MR::ProgressBar::done_func'
src\mrconvert.o: In function `ZN2MR5Image6ObjectD1Ev':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::info'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::Image::Mapper::unmap(MR::Image::Header const&)'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::Image::Mapper::~Mapper()'
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:49: undefined reference to `MR::Image::Mapper::~Mapper()'
src\mrconvert.o: In function `ZN2MR5Image6Object3mapEv':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/image/object.h:57: undefined reference to `MR::Image::Mapper::map(MR::Image::Header const&)'
src\mrconvert.o: In function `ZNK2MR7ArgBase9get_imageERNS_5Image6HeaderE':
C:/Users/Jesse/Documents/Work/Research/FiberTracking/Software/mrtrix/source/mrtrix-0.2.11/lib/args.h:201: undefined reference to `MR::Image::Object::create(std::string const&, MR::Image::Header&)'
src\mrconvert.o: In function `ZN5MyAppC1EiPPcPPKcPKN2MR8ArgumentEPKNS5_6OptionEPKjS3_S3_':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:119: undefined reference to `MR::App::App(int, char**, char const**, MR::Argument const*, MR::Option const*, unsigned int const*, char const*, char const*)'
src\mrconvert.o: In function `ZN5MyAppD1Ev':
C:\Users\Jesse\workspace\mrconv\Debug/../src/mrconvert.cpp:119: undefined reference to `MR::App::~App()'
collect2.exe: error: ld returned 1 exit status
11:42:57 Build Finished (took 1s.854ms)
It would appear these are internal linking errors? How do I go about finding the source of these errors?
you need to compile all the files and link them together. It's either missing a cpp file or library
This might be the problem. You need to use -L to specify where library files are. -I is to specify where included files are located.
g++ "-IC:\\Users\\Jesse\\Documents\\Work\\Research\\FiberTracking\\Software\\mrtrix\\source\\mrtrix-0.2.11\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib" "-IC:\\Users\\Jesse\\Programs\\gtk+\\bin" "-IC:\\Users\\Jesse\\Programs\\gtk+\\include\\glib-2.0" "-IC:\\Users\\Jesse\\Programs\\gtk+\\lib\\glib-2.0\\include" "-IC:\\gtkmm64\\include\\glibmm-2.4\\glibmm" "-IC:\\gtkmm64\\include\\glibmm-2.4" "-IC:\\gtkmm64\\lib\\glibmm-2.4\\include" "-IC:\\gtkmm64\\include\\sigc++-2.0" "-IC:\\gtkmm64\\lib\\sigc++-2.0\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include" "-IC:\\Program Files (x86)\\GnuWin32\\include\\gsl" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\mrconvert.o" "..\\src\\mrconvert.cpp"
I think some of them shouldbe changed to -L. for example
"-IC:\\Users\\Jesse\...lib"
Should be
-L"C:\\Users\\Jesse\...lib"
And should go on the linkage line. i.e. The second line where you link everything.