Use SDL2 with CLion 2020 - c++

I can't seem to link SDL2 correctly. I am using CLion with MinGW. My CMakeLists.txt looks like this currently, but I tried using the FindSDL2 module floating around, though it always said that it could not find the SDL2 library. This is the only way I've found it to stop giving back errors.
cmake_minimum_required(VERSION 3.16)
project(CBeat)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "CC:/Development/SDL2_MinGW_32bit/lib/cmake/SDL2")
set(SDL2_DIR C:/Mingw)
set(CMAKE_CXX_STANDARD 14)
set(SDL2_LIB_DIR ${SDL2_DIR}/lib)
include_directories(${SDL2_DIR}/include)
add_executable(CBeat main.cpp)
target_link_libraries(CBeat ${SDL2_LIB_DIR}/libSDL2.dll.a ${SDL2_LIB_DIR}/libSDL2main.a ${SDL2_LIB_DIR}/libSDL2.a -mwindows -lmingw32 -lSDL2main -lSDL2)
add_definitions(-DSDL_MAIN_HANDLED)
Now, the main.cpp looks like this, CLion shows no errors and actually is able to give me suggestions and information in each function, but when running it marks various functions as undefined. I attach evidence. I am so desperate right now, I've been trying to figure out this for days now and nothing seems to work!
#include <iostream>
#include <SDL2/SDL.h>
using namespace std;
const int SWIDTH=640, SHEIGHT=420;
int main( int argc, char* args[] ){
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
{
cout<< "SDL could not initialize! SDL_Error:" << SDL_GetError << endl;
}
else
{
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SWIDTH, SHEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
cout << "Window could not be created! SDL_Error: " << SDL_GetError << endl;
}
else
{
screenSurface = SDL_GetWindowSurface(window);
SDL_FillRect(screenSurface, NULL,SDL_MapRGB(screenSurface->format, 0xFF,0xFF,0xFF));
SDL_UpdateWindowSurface( window );
SDL_Delay( 2000 );
}
SDL_DestroyWindow( window );
SDL_Quit();
return 0;
}
}
CLion trying to be useful
And these are the errors it gives back:
[ 50%] Linking CXX executable CBeat.exe
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\CBeat.dir/objects.a(main.cpp.obj): in function `main':
C:/Users/yello/CLionProjects/CBeat/main.cpp:12: undefined reference to `SDL_Init'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:18: undefined reference to `SDL_CreateWindow'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:25: undefined reference to `SDL_GetWindowSurface'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:26: undefined reference to `SDL_MapRGB'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:26: undefined reference to `SDL_FillRect'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:27: undefined reference to `SDL_UpdateWindowSurface'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:28: undefined reference to `SDL_Delay'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:30: undefined reference to `SDL_DestroyWindow'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/yello/CLionProjects/CBeat/main.cpp:31: undefined reference to `SDL_Quit'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\CBeat.dir\build.make:88: recipe for target 'CBeat.exe' failed
CMakeFiles\Makefile2:74: recipe for target 'CMakeFiles/CBeat.dir/all' failed
mingw32-make.exe[3]: *** [CBeat.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/CBeat.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/CBeat.dir/rule] Error 2
mingw32-make.exe: *** [CBeat] Error 2
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/CBeat.dir/rule' failed
Makefile:117: recipe for target 'CBeat' failed

Related

Cmake: undefined reference to included methods

I am learning to use cmake and I am trying to compile a simple set of tests using gtest for a very small project that I wrote.
my CMakeLists.txt looks like
cmake_minimum_required(VERSION 2.6)
project(circuit_sim)
include(FetchContent)
FetchContent_Declare(
googletest
# Specify the commit you depend on and update it regularly.
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
add_executable(test Connector.cpp test.cpp)
target_link_libraries(test gtest_main)
I got most of it from the googletest docs. I am trying to compile an executable that has a main() in test.cpp and relies on a Connector class in Connector.cpp and Connector.h. All files are in the same directory
when I run cmake . and then make I get the following error:
/usr/bin/ld: CMakeFiles/test.dir/test.cpp.o: in function `AllTests_CircuitTest_Test::TestBody()':
test.cpp:(.text+0x33): undefined reference to `Connector::Connector()'
/usr/bin/ld: test.cpp:(.text+0x4c): undefined reference to `Connector::Connector()'
/usr/bin/ld: test.cpp:(.text+0x6d): undefined reference to `Connector::Connector(Connector*)'
/usr/bin/ld: test.cpp:(.text+0x7d): undefined reference to `Connector::connect(Connector*)'
/usr/bin/ld: test.cpp:(.text+0x93): undefined reference to `Connector::in(unsigned long, unsigned long)'
/usr/bin/ld: test.cpp:(.text+0xb8): undefined reference to `Connector::out()'
/usr/bin/ld: test.cpp:(.text+0xc4): undefined reference to `Connector::get_out_conn()'
/usr/bin/ld: test.cpp:(.text+0xd6): undefined reference to `Connector::get_v()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/test.dir/build.make:86: test] Error 1
make[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/test.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
It seems that cmake did not know to include Connector.cpp in the compilation even though I specified it in the CMakeLists.txt. What am I doing wrong?
Code for Connector.cpp, currently it doesn't do very much lol but it's a wip
#include "Connector.h"
#include "circuit_utils.h"
Connector::Connector(){
this->v = 0;
this->c = 0;
this->out_conn = nullptr;
}
Connector::Connector(Connector* out_conn){
this->v = 0;
this->c = 0;
this->out_conn = out_conn;
}
Connector* Connector::connect(Connector* out_conn){
this->out_conn = out_conn;
return this;
}
Connector* Connector::in(uint64_t v, uint64_t c){
this->v = v;
this->c = c;
//this->out();
return this;
}
Connector* Connector::out(){
if(out_conn != nullptr)
out_conn->in(v, c);
return this;
}
uint64_t Connector::get_v() { return v; }
uint64_t Connector::get_c() { return c; }
Connector* Connector::get_out_conn() { return out_conn; }
std::string Connector::to_string() {
std::string to_return = "";
to_return += "-------------\n";
to_return += "voltage: " + std::to_string(FROM_MICROS(((double)v))) + " volts\n";
to_return += "current: " + std::to_string(FROM_MICROS(((double)c))) + " amps\n";
to_return += "-------------\n";
return to_return;
}
Code for test.cpp
#include <iostream>
#include <unistd.h>
#include "gtest/gtest.h"
#include "Connector.h"
#include "circuit_utils.h"
using namespace std;
TEST (AllTests, CircuitTest) {
Connector* power = new Connector();
Connector* ground = new Connector();
power->connect(new Connector(ground));
power->in(TO_MICROS(3.3), TO_MICROS(3.3));
Connector *cur_conn = power;
while(cur_conn != nullptr){
sleep(5);
cur_conn->out();
cur_conn = cur_conn->get_out_conn();
}
ASSERT_EQ(3.3, ground->get_v());
}
Since you need external class, you should put that class "library" in target_link_libraries(), so that the last line of your CMakeLists.txt will become
target_link_libraries(test connector gtest_main)
Also, in another CMakeLists.txt which is in the same directory as Connector.cpp, your should declare them as one library:
set(SOURCES Connector.cpp)
add_library(connector STATIC ${SOURCES})

How do I link a static GLEW library to a CMake project using MinGW?

I'm trying to make a simple triangle project to learn OpenGL, but I'm stuck at a compile error:
GLFWwindow* initApp() {
if (!glfwInit()) {
std::cerr << "Failed to create GLFW context" << std::endl;
return nullptr;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(1280, 720, "TriangleApp", nullptr, nullptr);
if (window == nullptr) {
std::cerr << "Failed to open GLFW window" << std::endl;
glfwTerminate();
return nullptr;
}
glfwMakeContextCurrent(window);
glewExperimental = true;
if (!glewInit()) {
std::cerr << "Failed to initialize GL libraries" << std::endl;
return nullptr;
}
return window;
}
CMake is telling me there's an undefined reference to glewInit and glewExperimental. I have included glew.h before any OpenGL header, defined GLEW_STATIC in my CMake project and linked glfw3.a and glew32s.lib to the target using CMakeLists.txt:
cmake_minimum_required(VERSION 3.17)
project(TriangleApp)
# GLEW
add_compile_definitions(GLEW_STATIC)
include_directories(libraries/glew/include)
set(GLEW_LINK_LIBRARY ${CMAKE_SOURCE_DIR}/libraries/glew/lib/Release/Win32/glew32s.lib)
# GLFW
include_directories(libraries/glfw/include)
set(GLFW_LINK_LIBRARY ${CMAKE_SOURCE_DIR}/libraries/glfw/lib/libglfw3.a)
# My App
include_directories(headers)
add_executable(TriangleApp source/Main.cpp)
target_link_libraries(TriangleApp
${GLEW_LINK_LIBRARY}
${GLFW_LINK_LIBRARY})
Here's the output from the CMake Tasks extension (vscode):
[main] Building folder: TriangleApp
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/benjo/source/repos/windows/C++/OpenGL/TriangleApp/build --config Debug --target all -- -j 10
[build] Scanning dependencies of target TriangleApp
[build] [ 50%] Building CXX object CMakeFiles/TriangleApp.dir/source/Main.cpp.obj
[build] [100%] Linking CXX executable TriangleApp.exe
[build] CMakeFiles\TriangleApp.dir/objects.a(Main.cpp.obj): In function `initApp()':
[build] C:/Users/benjo/source/repos/windows/C++/OpenGL/TriangleApp/source/Main.cpp:27: undefined reference to `glewInit'
[build] CMakeFiles\TriangleApp.dir/objects.a(Main.cpp.obj):Main.cpp:(.rdata$.refptr.glewExperimental[.refptr.glewExperimental]+0x0): undefined reference to `glewExperimental'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make.exe[2]: *** [CMakeFiles\TriangleApp.dir\build.make:108: TriangleApp.exe] Error 1
[build] mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:95: CMakeFiles/TriangleApp.dir/all] Error 2
[build] mingw32-make.exe: *** [Makefile:103: all] Error 2
[build] Build finished with exit code 2

mingw32-make undefined reference to `cv::imread(cv::String const&, int)' OPENCV

So I have OpenCV libraries downloaded from here
https://sourceforge.net/projects/opencvlibrary/files/3.4.6/opencv-3.4.6-vc14_vc15.exe/download
CMake gui with cmakelist.txt like this
cmake_minimum_required(VERSION 2.8)
project(Display)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library
status:") message(STATUS " config:
${OpenCV_DIR}") message(STATUS "
version: ${OpenCV_VERSION}")
message(STATUS " libraries:
${OpenCV_LIBS}") message(STATUS "
include path: ${OpenCV_INCLUDE_DIRS}")
add_executable(Display
DisplayImage.cpp)
target_link_libraries(Display
${OpenCV_LIBS})
and have a simple cpp like this
#include <stdio.h>
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv )
{
// cout << "You have entered " << argc
// << " arguments:" << "\n";
// for (int i = 0; i < argc; ++i)
// cout << argv[i] << "\n";
// cout << "a" << argv[1];
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
printf("Hello World!");
return 0;
}
already configure it with cmake-gui and this shows up
OpenCV library status:
config: D:/opencv/build/x64/vc15/lib
version: 3.4.6
libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_world
include path: D:/opencv/build/include;D:/opencv/build/include/opencv;D:/opencv/build/include/opencv2
Configuring done Generating done
seems good right ? and then on the build directory from command prompt, i typed mingw32-make
and this shows up
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0x72):
undefined reference to
cv::imread(cv::String const&, int)'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0xe3):
undefined reference to
cv::namedWindow(cv::String const&,
int)'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0x129):
undefined reference to
cv::imshow(cv::String const&,
cv::_InputArray const&)'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0x149):
undefined reference to
cv::waitKey(int)'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv6StringC1EPKc[__ZN2cv6StringC1EPKc]+0x42):
undefined reference to
cv::String::allocate(unsigned int)'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv6StringD1Ev[__ZN2cv6StringD1Ev]+0xf):
undefined reference to
cv::String::deallocate()'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$ZN2cv6StringaSERKS0[__ZN2cv6StringaSERKS0_]+0x1c):
undefined reference to
cv::String::deallocate()'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to
cv::fastFree(void*)'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x40):
undefined reference to
cv::Mat::deallocate()'
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv3MataSEOS0_[__ZN2cv3MataSEOS0_]+0xb4):
undefined reference to
cv::fastFree(void*)' collect2.exe:
error: ld returned 1 exit status
mingw32-make[2]: *
[CMakeFiles\Display.dir\build.make:104:
Display.exe] Error 1 mingw32-make[1]:
* [CMakeFiles\Makefile2:72: CMakeFiles/Display.dir/all] Error 2
mingw32-make: *** [Makefile:83: all]
Error 2
how do i fix this ? or is it because that i use the library straight from the website ?
i also try something like putting a wrong parameter on the imread function and then type mingw32-make and it did tell me that i use a wrong parameter. If they know i used the wrong parameter, then why they can't tell what is imread for (or why is it undefined reference ? ) ? I'm using windows.
I'm very new to these libraries, mingw, and cmake, so i'm sorry if my question is stupid.
this question is not duplicate because, i use windows and mingw32-make, everyone that asks this question did not use that and the question is in a different situation than mine.

Clion Cmake & SDL2

I want to use Clion with SDL2 and after lot of tests, I already have an error.
there is my CmakeLists.txt :
cmake_minimum_required(VERSION 3.8)
project(sdl2-test)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lmingw32")
#set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
set(CMAKE_CXX_STANDARD 11)
include_directories(${PROJECT_SOURCE_DIR}/include)
link_directories(${PROJECT_SOURCE_DIR}/lib)
set(SOURCE_FILES main.cpp)
add_executable(sdl2-test ${SOURCE_FILES})
target_link_libraries(sdl2-test SDL2main SDL2)
my main.cpp
#include <iostream>
#include "include/SDL2/SDL.h"
using namespace std;
int main(int argc, char** argv) {
if(SDL_Init(SDL_INIT_EVERYTHING) == -1){
cout << "Something went wrong! " << SDL_GetError() << endl;
}
SDL_Window* window = SDL_CreateWindow("SDL_Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
1280, 720, SDL_WINDOW_OPENGL);
if(window == nullptr){
cout << "Something also went wrong here" << endl;
}
SDL_Delay(2000);
SDL_Quit();
return 0;
}
but when I build my project cmake Obviously Cmake work find but I haave some error :
C:\Users\paulp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\172.4343.16 \bin\cmake\bin\cmake.exe --build C:\Users\paulp\CLionProjects\sdl2-test\cmake- build-debug --target sdl2-test -- -j 4
[ 50%] Building CXX object CMakeFiles/sdl2-test.dir/main.cpp.obj
[100%] Linking CXX executable sdl2-test.exe
CMakeFiles\sdl2-test.dir/objects.a(main.cpp.obj): In function `SDL_main':
C:/Users/paulp/CLionProjects/sdl2-test/main.cpp:8: undefined reference to `SDL_Init'
C:/Users/paulp/CLionProjects/sdl2-test/main.cpp:9: undefined reference to `SDL_GetError'
C:/Users/paulp/CLionProjects/sdl2-test/main.cpp:13: undefined reference to `SDL_CreateWindow'
C:/Users/paulp/CLionProjects/sdl2-test/main.cpp:18: undefined reference to `SDL_Delay'
C:/Users/paulp/CLionProjects/sdl2-test/main.cpp:19: undefined reference to `SDL_Quit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\sdl2-test.dir\build.make:96: recipe for target 'sdl2-test.exe' failed
mingw32-make.exe[3]: *** [sdl2-test.exe] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/sdl2-test.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/sdl2-test.dir/all] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/sdl2-test.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/sdl2-test.dir/rule] Error 2
mingw32-make.exe: *** [sdl2-test] Error 2
Makefile:117: recipe for target 'sdl2-test' failed
any idea how to fix ?
The linking of your application has failed because the linker does not know the location of the sdl2-lib.
You need to search for the SDL2-libraries as well in your cmake-file and add the locations to your makefile:
find_file(SDL2_INCLUDE_DIR NAME SDL.h HINTS SDL2)
find_library(SDL2_LIBRARY NAME SDL2)
add_executable(ChickenShooter main.cpp)
target_include_directories(ChickenShooter ${SDL2_INCLUDE_DIR})
target_link_libraries(ChickenShooter ${SDL2_LIBRARY})
You can look into this post as well: How to dins SDL2 via cmake

OpenGL project returns with undefined references

I am following a tutorial for OpenGL from this site. I have downloaded and installed (hopefully correctly) the OpenGL libraries that are used. (GLEW, GLFW, GLM). However, when I compile the code from the site, I find a lot of errors with undefined references.
Code:
#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 GLFW\n" );
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 GLEW\n");
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;
}
Errors:
"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:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:21: undefined reference to `glfwInit'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:27: undefined reference to `glfwOpenWindowHint'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:28: undefined reference to `glfwOpenWindowHint'
C:\Users\jared\Documents\NetBeansProjects\opengl_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:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:30: undefined reference to `glfwOpenWindowHint'
make[2]: Leaving directory `/cygdrive/c/Users/jared/Documents/NetBeansProjects/opengl_1'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:31: undefined reference to `glfwOpenWindowHint'
nbproject/Makefile-Debug.mk:59: recipe for target `.build-conf' failed
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:34: undefined reference to `glfwOpenWindow'
make[1]: Leaving directory `/cygdrive/c/Users/jared/Documents/NetBeansProjects/opengl_1'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:37: undefined reference to `glfwTerminate'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:42: undefined reference to `_imp__glewInit#0'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:47: undefined reference to `glfwSetWindowTitle'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:50: undefined reference to `glfwEnable'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:53: undefined reference to `glClearColor#16'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:59: undefined reference to `glfwSwapBuffers'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:62: undefined reference to `glfwGetKey'
C:\Users\jared\Documents\NetBeansProjects\opengl_1/main.cpp:63: undefined reference to `glfwGetWindowParam'
C:\Users\jared\Documents\NetBeansProjects\opengl_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)
Note: I'm using Netbeans (with C++ plugin) as an IDE.
Re-reading the makefile output, I see you don't actually link with the GL libraries. You need to modify the project setting to include the libraries.