Linking libraries

nolane61 wrote on Saturday, August 17, 2013:

I just want test glfw.

main.cpp:
#include <GL/glfw3.h>
#include <vector>
#include <iostream>
using namespace std;

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

    glfwTerminate();

    int temp;
    cin >> temp;
    return 0;
}

I load the lastest Binaries for 64-bit Windows files from “http://www.glfw.org/download.html”. I use MinGW in Code Blocks 12.11 in Windows 7. When I build siple project which has the only file, I get this build log:

-------------- Build: Debug in glfw (compiler: GNU GCC Compiler)---------------

g++.exe -Wall  -g  -std=c++11   -I"C:\Program Files (x86)\CodeBlocks\MinGW\include"  -c C:\glfw\main.cpp -o obj\Debug\main.o
g++.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib"  -o bin\Debug\glfw.exe obj\Debug\main.o    -lglfw3 -lopengl32 
obj\Debug\main.o: In function `main':
C:/glfw/main.cpp:8: undefined reference to `glfwInit'
C:/glfw/main.cpp:10: undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status

“C:\Program Files (x86)\CodeBlocks\MinGW\lib” contains libglfw3.a and libopengl32.a.

What’s my fault?

I’m not familiar with Code Blocks but the error message indicates that the glfw3 library is not being found. Does it work if you use the pathname for the library instead?