Portál AbcLinuxu, 11. května 2024 02:04


Dotaz: Problem s kompilaci jednoducheho programu v Net Beans [C++, GLFW]

Bundas avatar 19.4.2014 16:30 Bundas | skóre: 14 | Pardubice
Problem s kompilaci jednoducheho programu v Net Beans [C++, GLFW]
Přečteno: 201×
Odpovědět | Admin

Nejde mi zkompilovat bezchybne napsany program:

(jsou tam tyto hlavickove soubory: iostream, stdio.h, stdlib.h, GL/glew.h, GLFW/glfw3.h, glm/glm.hpp,)

#define GLFW_INCLUDE_GL_3
using namespace glm;
using namespace std;


int main(){
    if(!glfwInit()){
        return -1;
    }
    GLFWwindow* window; // (In the accompanying source code, this variable is global)
    window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL);
    if( window == NULL ){
    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;
}
    glfwMakeContextCurrent(window);
 
// Initialize GLEW
    glewExperimental=true; // Needed in core profile
    if (glewInit() != GLEW_OK) {
    fprintf(stderr, "Failed to initialize GLEW\n");
    return -1;
}
    return 0;
}
A tohle je vystup v netbeans
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/root/NetBeansProjects/pokus'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/pokus
make[2]: Entering directory `/root/NetBeansProjects/pokus'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/main.o.d"
g++    -c -g -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/pokus build/Debug/GNU-Linux-x86/main.o 
build/Debug/GNU-Linux-x86/main.o: In function `main':
/root/NetBeansProjects/pokus/main.cpp:15: undefined reference to `glfwInit'
/root/NetBeansProjects/pokus/main.cpp:19: undefined reference to `glfwCreateWindow'
/root/NetBeansProjects/pokus/main.cpp:22: undefined reference to `glfwTerminate'
/root/NetBeansProjects/pokus/main.cpp:25: undefined reference to `glfwMakeContextCurrent'
/root/NetBeansProjects/pokus/main.cpp:28: undefined reference to `glewExperimental'
/root/NetBeansProjects/pokus/main.cpp:29: undefined reference to `glewInit'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/pokus] Error 1
make[2]: Leaving directory `/root/NetBeansProjects/pokus'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/root/NetBeansProjects/pokus'
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 3s)
Vsechny hlavickove soubory mam v spravne nainstalovane.
Abe the Messiah has come.
Nástroje: Začni sledovat (0) ?Zašle upozornění na váš email při vložení nového komentáře.

Odpovědi

19.4.2014 19:27 MadCatX
Rozbalit Rozbalit vše Re: Problem s kompilaci jednoducheho programu v Net Beans [C++, GLFW]
Odpovědět | | Sbalit | Link | Blokovat | Admin
  1. Ten program bezchybně napsaný není. V kódu není nikde řečeno, jaká verze OpenGL se má použít. Includovat stdio.h a iostream je taky špatně, protože v C++ by se mělo použít cstdio.
  2. Problém není v překladu, ale linkování. Musíš linkeru říct, že má program linkovat proti knihovně glfw. GLFW jsem nikdy nepoužil, ale ta knihovna se nejspíš bude jmenovat glfw.so. Jak se v GCC nastavují parametry linkeru ti prozradí Google
  3. .

Založit nové vláknoNahoru

Tiskni Sdílej: Linkuj Jaggni to Vybrali.sme.sk Google Del.icio.us Facebook

ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.