0

am setting up GLEW and GLFW on clion, glfw worked fine but I have a trouble with glew. After linking glew, I built the code and worked fine, but when using any glew function then run the code, a runtime error shows up before executing any line code.

I tried deleting every glew file on my computer then reinstalling glew as proposed in this previous problem. I thought the problem might be a linking problem so I searched for a proper way to link glew. I found this old question, but the glew version used in his case is different from the one I've downloaded from the official site which has Cmake ready to link.

Cmake code:

cmake_minimum_required(VERSION 3.12)
project(graphics)

set(CMAKE_CXX_STANDARD 14)

add_executable(graphics main.cpp)

set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(glfw)
target_link_libraries(graphics glfw)
find_package(OpenGL REQUIRED)
target_link_libraries(graphics OpenGL::GL)

add_subdirectory(glew-2.1.0/build/cmake)
target_link_libraries(graphics glew)
find_package(glew REQUIRED)

The code I try to run:

#include <iostream>
using namespace std;

#include "glew-2.1.0/include/GL/glew.h"

int main()
{
    glewInit();
    return 0;
}

am still thinking it may be a linking problem but I don't have much experience with cmake. hope you help me, thanks in advance

EDIT: Problem fixed. It was a missed dll file. This file is glew32d.dll which created by clion after linking, but Clion couldn't use it so I put it in the project directory. I also tried to put in MinGW/bin and worked. The program I used to figure out the missed dll file found in the comments.

Ahmad
  • 1
  • 2
  • ***still thinking it may be a linking problem*** No its not a linking problem, The error message `0xC0000135` means dll not found. Do you have the required dlls in one of the folders in your `PATH` environment variable? Or the same folder as your executable? – drescherjm Apr 20 '21 at 13:30
  • In [GLEW Documentation][http://glew.sourceforge.net/install.html ], no mention about additional dll for static version, I tried to find out what could be required as additional files for static version but I didn't find any. @drescherjm – Ahmad Apr 20 '21 at 15:18
  • This program should help you figure out what dll is needed: [https://github.com/lucasg/Dependencies](https://github.com/lucasg/Dependencies) – drescherjm Apr 20 '21 at 16:26
  • Thanks a lot, it worked. I used the program, glew32d.dll was missed. This dll was created by Clion in **ProjectDir/cmake-build-debug/bin** , but Clion couldn't use it I don't know why, I tried to put with the project files and it worked. @drescherjm – Ahmad Apr 21 '21 at 13:02

0 Answers0