Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML on Win32 with Cmake, cannot link to glew  (Read 1917 times)

0 Members and 1 Guest are viewing this topic.

vlad12

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
SFML on Win32 with Cmake, cannot link to glew
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10916
    • View Profile
    • development blog
    • Email
AW: SFML on Win32 with Cmake, cannot link to glew
« Reply #1 on: November 30, 2013, 11:41:39 am »
What OS, compiler and exact SFML version are you using and what errors do you get?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

vlad12

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML on Win32 with Cmake, cannot link to glew
« Reply #2 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>

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10916
    • View Profile
    • development blog
    • Email
Re: SFML on Win32 with Cmake, cannot link to glew
« Reply #3 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/