0

I'm new to C++. I'm trying to run a simple example openGL application.

I have downloaded the libraries that are used from the following locations.

http://www.glfw.org/index.html

http://glew.sourceforge.net/

http://glm.g-truc.net/0.9.6/index.html

I am using NetBeans IDE as my C++ IDE. I think I have specified the correct Include Directories because the program compiles without any errors. Following is my include path.

../../../../../gl/glm;../../../../../gl/glew-1.12.0/include;../../../../../gl/glfw-3.1.bin.WIN64/include/GLFW

The command that runs when I compile is the following

CLEAN SUCCESSFUL (total time: 552ms)
C:\MinGW\msys\1.0\bin\make.exe -f nbproject/Makefile-Debug.mk build/Debug/MinGW-Windows/main.o
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/main.o.d"
g++    -c -g -I../../../../../gl/glm -I../../../../../gl/glew-1.12.0/include -I../../../../../gl/glfw-3.1.bin.WIN64/include/GLFW -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp

COMPILE FILE SUCCESSFUL (total time: 4s)

But when running the application I get the following errors.

"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
"/C/MinGW/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
mkdir -p dist/Debug/MinGW-Windows
g++     -o dist/Debug/MinGW-Windows/cppapplication_1 build/Debug/MinGW-Windows/main.o -L../../../../../gl/glfw-3.1.bin.WIN64/lib-mingw -L../../../../../gl/glew-1.12.0/bin/Release/x64
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:19: undefined reference to `glfwInit'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:25: undefined reference to `glfwWindowHint'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:26: undefined reference to `glfwWindowHint'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:27: undefined reference to `glfwWindowHint'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:28: undefined reference to `glfwWindowHint'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:31: undefined reference to `glfwCreateWindow'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:34: undefined reference to `glfwTerminate'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:37: undefined reference to `glfwMakeContextCurrent'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:40: undefined reference to `_imp__glewInit@0'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:46: undefined reference to `glfwSetInputMode'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:49: undefined reference to `glClearColor@16'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:55: undefined reference to `glfwSwapBuffers'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:56: undefined reference to `glfwPollEvents'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:59: undefined reference to `glfwGetKey'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:60: undefined reference to `glfwWindowShouldClose'
C:\Users\name\Documents\NetBeansProjects\CppApplication_1/main.cpp:63: undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/cppapplication_1.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 5s)

Under the Build/Linker section, I have given the following as "Additional Library Directories"

../../../../../gl/glew-1.12.0/lib/Release/x64;../../../../../gl/glfw-3.1.bin.WIN64/lib-mingw

I am using MinGW. What am I doing wrong here?

Update:

I supplied the libaries using the -l option. Now I get another error like the following.

"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make.exe[1]: Entering directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/cppapplication_1.exe
make.exe[1]: Leaving directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'

CLEAN SUCCESSFUL (total time: 1s)
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
"/C/MinGW/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/main.o.d"
g++    -c -g -I../../../../../gl/glm -I../../../../../gl/glew-1.12.0/include -I../../../../../gl/glfw-3.1.bin.WIN64/include/GLFW -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++     -o dist/Debug/MinGW-Windows/cppapplication_1 build/Debug/MinGW-Windows/main.o -L../../../../../gl/glew-1.12.0/bin/Release/x64 -L../../../../../gl/glfw-3.1.bin.WIN64/lib-mingw -lglfw3 -lglew32
../../../../../gl/glew-1.12.0/bin/Release/x64/glew32.dll: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/cppapplication_1.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/name/Documents/NetBeansProjects/CppApplication_1'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)
Can't Tell
  • 12,714
  • 9
  • 63
  • 91
  • You also need to specify which libraries to link with. – molbdnilo Feb 27 '15 at 12:09
  • `-L` try to put the absolute path. Add the libraries you want to link with `-l...` and the include path with `-I`. Remember to put the libraries according to Debug/Release – hlscalon Feb 27 '15 at 12:10
  • @molbdnilo Netbeans compiler seems to put the -L parameter. And the correct dll files are in those directories as well. I updated the question with the full netbeans output – Can't Tell Feb 27 '15 at 12:13
  • @1nflktd I updated the question with the full netbeans output. – Can't Tell Feb 27 '15 at 12:14
  • The "L" parameters only tell the linker where to look for libraries. You need the "l" parameters to tell the linker *which* libraries to look for. – molbdnilo Feb 27 '15 at 12:16
  • @molbdnilo I used the -l parameter. Now I get a different error. What could be the cause of that? – Can't Tell Feb 27 '15 at 12:23
  • "the program compiles without any errors" - **`BUILD FAILED`** – Bartek Banachewicz Feb 27 '15 at 12:25
  • @BartekBanachewicz When I right click and compiled, the file compiled successfully as shown in the first output. – Can't Tell Feb 27 '15 at 12:26
  • True, technically the link failed, but you really should be more explicit about it. – Bartek Banachewicz Feb 27 '15 at 12:27
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Bartek Banachewicz Feb 27 '15 at 12:27
  • @BartekBanachewicz I am now getting a different error, and the linked issue does not seem to provide the answer. Can you take a look and see if you know how to solve it? – Can't Tell Feb 27 '15 at 12:40
  • Mmmmm.... `release/x64` with a `glew32` library? Smells fishy. I am not sure, might be glew idiosyncracy, but ensure you're picking wrong bitness (i386/x86_64) of dll anyway. – Bartek Banachewicz Feb 27 '15 at 12:46

0 Answers0