w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Can't compile easy source in C++ and OpenGL (GLFW) in Linux in NetBeans

First things first:

this is my source (I didn't use this characters: <, > in header files.):

That is wrong, and you should. Your current include statements are wrong, and I am actually surprised how it passed the compilation process this way.

You are seeing linker errors in here:

/home/jan/NetBeansProjects/a/main.cpp:12: undefined reference to
/home/jan/NetBeansProjects/a/main.cpp:16: undefined reference to
/home/jan/NetBeansProjects/a/main.cpp:19: undefined reference to
/home/jan/NetBeansProjects/a/main.cpp:22: undefined reference to
/home/jan/NetBeansProjects/a/main.cpp:25: undefined reference to
/home/jan/NetBeansProjects/a/main.cpp:26: undefined reference to `glewInit'

There might be the following options for the failure:

  • You are not linking against the library (most likely)

  • You are not having the library installed (unlikely, based on your description)

  • You are using symbols not present in the library (again, unlikely)

The most probably reason is that you are not linking against the library, eventually. You should have this set up for the linker:


Note that you will also need to add everything in the chain that comes up as a dependency when you start adding these, so based on your comment this is the whole chain to add:

-L/usr/local/lib -lglfw3 -pthread -lGLEW -lGLU -lGL -lrt
-lXrandr -lXxf86vm -lXi -lXinerama -lX11

Since you are using the Netbeans IDE, you will need to go to the project settings to set it up unless you edit the files in the background manually. Here, you can see a screenshot which demonstrates that you have a linker tab where you can set up all this properly.

enter image
description here

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.