0

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!!!

Misa Lazovic
  • 2,805
  • 10
  • 32
  • 38
  • Try adding: `-lglfw -lGL -lGLU` – nnn Nov 28 '15 at 13:03
  • I already have that. In the exact order. – Dieter Johann Nov 28 '15 at 13:04
  • They are not in the list of options passed to `g++`, so then maybe they are not inputted in the right field. See this: http://stackoverflow.com/questions/15040303/how-to-link-libs-in-netbeans-linux – nnn Nov 28 '15 at 13:13
  • I just keep getting error after error after error... This is how it goes: I get the first error. I get an error trying to fix that error. I get an error trying to fix the error for the fix to the original error. Also, please read the [EDITS] in the post for any updates. Thank you for trying to help. – Dieter Johann Nov 28 '15 at 13:19
  • @MisaLazovic Please try to improve as much of a post as you can when suggesting edits instead of merely adding/removing tags http://stackoverflow.com/help/privileges/edit – codeMagic Dec 14 '15 at 18:37
  • @codeMagic OK, noted – Misa Lazovic Dec 14 '15 at 18:38

1 Answers1

0

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!!

Community
  • 1
  • 1