Search code examples
c++netbeanslinkerglfwnetbeans-8.1

GLFW3 failing to link properly with Netbeans 8.1


I have looked at some 20 different pages on stackoverflow or otherwise, and none of them have helped me. I have linked in the properties of the project, but the project, when compiled, says

/home/(username)/NetBeansProjects/testGame_cpp/main.cpp:24: undefined reference to `glfwInit'

This is really irritating, and also, I noticed that when I set link options, they don't appear in the command that runs to build the project:

g++ -g -m64 -o testGame main.cpp -L/usr/lib/x86_64-linux-gnu -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic

Please help, this is agitating!! ;(

Here is all I have of the project (main.cpp):

/* 
* File:   main.cpp
* Author: toriyamo
*
* Created on November 27, 2015, 5:34 PM
*/

#include <stdlib.h>
#include <stdio.h>

#include <GL/glew.h>
#include <GLFW/glfw3.h>

using namespace std;

int main(int argc, char** argv) {

    if (!glfwInit()) {
        fprintf(stderr, "**Failed to initialize glfw3!!**\n");
    }

    return 0;
}

EDIT: Also, if I comment out the if() statement, then it compiles with

BUILD SUCCESSSFUL (total time: 259ms)

EDIT 2: I don't believe I installed GLFW correctly... I downloaded it, built it with CMake, and it was successful. I typed into a terminal:

su
Password: (password)
make

This was the output: http://pastebin.com/WMVGRAWp

Apparently it worked... but why is it that the glfw lib's won't work?

EDIT 3: I changed up the makefile so that it builds with options that were in the linking options. I got a new error: http://pastebin.com/aHuZ1jsg Must be missing X- something...

EDIT 4 (the final one): See answer below!!!


Solution

  • I found the solution... of course only after I post the question lol.

    I saw this page, and typed in this command:

    sudo find / | grep "glfw3\.pc"
    cat /usr/local/lib/pkgconfig/glfw3.pc 
    

    I then found

    Requires.private:  x11 xrandr xinerama xi xxf86vm xcursor gl
    

    I added the options in this that I didn't have before into the makefile, and it worked! Finally! Torment of errors ended!!

    Anyways, hope it helps other people as well!!