SFML community forums

Help => General => Topic started by: vlad12 on November 30, 2013, 06:13:25 am

Title: SFML on Win32 with Cmake, cannot link to glew
Post by: vlad12 on November 30, 2013, 06:13:25 am
Hi there,

It seems like a really simple thing, but i just can't manage to get it working. The error is that the my generated vc project doesn't recognize GL_ARRAY_BUFFER and other stuff which is usually resolved by linking to GLEW. I understand that GLEW is already included in SFML as long as we declare static linking true. Here is the CMake code:

#other stuff

# OpenGL
find_package(OpenGL)

# SFML
if(WIN32)
   set(SFML_STATIC_LIBRARIES TRUE)
endif(WIN32)

set(SFML_INCLUDE_DIR "${SharedDependencies}/Shared")

find_package(SFML COMPONENTS  system window graphics)
include_directories(${SFML_INCLUDE_DIR})

add_executable(App main.cpp)
target_link_libraries(App Core)
target_link_libraries(App Graphics)
target_link_libraries(App ${OPENGL_LIBRARIES})
target_link_libraries(App  ${SFML_LIBRARIES})

#other stuff

I also tried adding  add_definitions(-DSFML_STATIC -DGLEW_STATIC) with no success.
My apologies if this is a redundant question, but I really searched online and none of the solutions worked.

Thanks
Title: AW: SFML on Win32 with Cmake, cannot link to glew
Post by: eXpl0it3r on November 30, 2013, 11:41:39 am
What OS, compiler and exact SFML version are you using and what errors do you get?
Title: Re: SFML on Win32 with Cmake, cannot link to glew
Post by: vlad12 on November 30, 2013, 07:47:07 pm
In on win7 x64, using Visual Studio 2013 compiler (VC120). SFML version is 2.1. Here are a few errors:

   120   IntelliSense: identifier "glVertexAttribPointer" is undefined   
   114   IntelliSense: identifier "glUseProgram" is undefined   
   117   IntelliSense: identifier "glUniform1i" is undefined   
   112   IntelliSense: identifier "glGetUniformLocation" is undefined   
   113   IntelliSense: identifier "glGetAttribLocation" is undefined   
   121   IntelliSense: identifier "glEnableVertexAttribArray" is undefined   
Error   38   error C2065: 'GL_VERTEX_SHADER' : undeclared identifier
Error   94   error C2065: 'GL_VERTEX_SHADER' : undeclared identifier   
Error   15   error C2065: 'GL_ARRAY_BUFFER' : undeclared identifier   
Error   69   error C2065: 'GLchar' : undeclared identifier

And a lot more like these... so basically it doesn't recognizer the usual non-windows opengl, which is usually resolved by using GLEW.

And my headers:
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Graphics.hpp>
Title: Re: SFML on Win32 with Cmake, cannot link to glew
Post by: eXpl0it3r on November 30, 2013, 07:54:25 pm
Since there are no binaries for VS 2013, you'll have to recompile SFML on your own. If you choose the latest version from GitHub and link statically, you'll have to link SFML's dependencies manually.