Estoy siguiendo un tutorial para OpenGL de este sitio. He descargado e instalado (con suertecorrectamente) las bibliotecas de OpenGL que se utilizan. (GLEW, GLFW, GLM). Sin embargo, cuando compilo el código del sitio, encuentro muchos errores con referencias no definidas.
Código:
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>
#include <glm/glm.hpp>
using namespace glm;
int main( void )
{
// Initialize GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFWn" );
return -1;
}
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.n" );
glfwTerminate();
return -1;
}
// Initialize GLEW
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEWn");
return -1;
}
glfwSetWindowTitle( "Playground" );
// Ensure we can capture the escape key being pressed below
glfwEnable( GLFW_STICKY_KEYS );
// Dark blue background
glClearColor(0.0f, 0.0f, 0.3f, 0.0f);
do{
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers();
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
glfwGetWindowParam( GLFW_OPENED ) );
// Close OpenGL window and terminate GLFW
glfwTerminate();
return 0;
}
Errores:
"make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/jared/Documents/NetBeansProjects/opengl_1"
"make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/opengl_1.exe
make[2]: Entering directory `/cygdrive/c/Users/jared/Documents/NetBeansProjects/opengl_1"
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/opengl_1 build/Debug/MinGW-Windows/main.o
build/Debug/MinGW-Windows/main.o: In function `main":
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:21: undefined reference to `glfwInit"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:27: undefined reference to `glfwOpenWindowHint"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:28: undefined reference to `glfwOpenWindowHint"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:29: undefined reference to `glfwOpenWindowHint"
nbproject/Makefile-Debug.mk:62: recipe for target `dist/Debug/MinGW-Windows/opengl_1.exe" failed
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:30: undefined reference to `glfwOpenWindowHint"
make[2]: Leaving directory `/cygdrive/c/Users/jared/Documents/NetBeansProjects/opengl_1"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:31: undefined reference to `glfwOpenWindowHint"
nbproject/Makefile-Debug.mk:59: recipe for target `.build-conf" failed
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:34: undefined reference to `glfwOpenWindow"
make[1]: Leaving directory `/cygdrive/c/Users/jared/Documents/NetBeansProjects/opengl_1"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:37: undefined reference to `glfwTerminate"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:42: undefined reference to `_imp__glewInit@0"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:47: undefined reference to `glfwSetWindowTitle"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:50: undefined reference to `glfwEnable"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:53: undefined reference to `glClearColor@16"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:59: undefined reference to `glfwSwapBuffers"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:62: undefined reference to `glfwGetKey"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:63: undefined reference to `glfwGetWindowParam"
C:UsersjaredDocumentsNetBeansProjectsopengl_1/main.cpp:66: undefined reference to `glfwTerminate"
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/opengl_1.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 875ms)
Nota: Estoy usando Netbeans (con el complemento C ++) como IDE.
Respuestas
2 para la respuesta № 1Al volver a leer la salida de makefile, veo que en realidad no está vinculado con las bibliotecas GL. Necesita modificar la configuración del proyecto para incluir las bibliotecas.