Results 1 to 8 of 8

Thread: Including GLEW in Visual Studio 2008 / C++/CLI

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2014
    Posts
    4

    Including GLEW in Visual Studio 2008 / C++/CLI

    Hi,

    I'm trying to plot some scientific data with OpenGL. I want to use windows forms from .net, so I looked for a wrapper for openGL and i found this:
    Article 16051/Creating-an-OpenGL-view-on-a-Windows-Form from codeproject.com (sorry, I'm not allowed to include links in this post )
    I just copypasted the code from the tutorial and it compiles. Now I wanted to add a shader, so I included this line:
    Code :
    GLuint vs = glCreateShader(GL_VERTEX_SHADER);
    to the constructor of the example code. (so it looks like this: Paste YtsLK0vM at Pastebin.com).
    I now get 5380 warnings which look like this (all warnings and errors are translated by hand from german, so sorry if they don't sound exactly right):
    Code :
    warning C4394: "__glewCopyTexSubImage3D": An application domain specific symbol should not be marked with __declspec(dllimport) C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\GL\glew.h	15043

    And then these errors:
    Code :
    5381	error LNK2020: Unresolved token (0A000016) __imp____glewCreateShader.	GLwindow.obj (thats my file which includes the tutorial code)
    5382	error LNK2020: Unresolved token (0A000024) __imp____glewCreateShader.	OpenGL_test.obj (thats the name of the project)
    5383	error LNK2001: Unresolved external symbol "__imp___glewCreateShader".	OpenGL_test.obj
    5384	error LNK2001: Unresolved external symbol "__imp___glewCreateShader".	GLwindow.obj
    5385	fatal error LNK1120: 3 unresolved external links.	C:\Users\ME\Documents\Visual Studio 2008\Projects\OpenGL_test\Debug\OpenGL_test.exe

    What I did:
    I installed glew as it is advised on the website:
    I copied
    Code :
    bin/Release/Win32/glew32.dll	    to     	Windows/system32
    lib/Release/Win32/glew32.lib	    to     	Program files (x86)/Microsoft Visual Studio 9.0/VC/Lib
    lib/Release/Win32/glew32s.lib	    to     	Program files (x86)/Microsoft Visual Studio 9.0/VC/Lib
    include/GL/glew.h	            to     	Program files (x86)/Microsoft Visual Studio 9.0/VC/Include/GL
    include/GL/wglew.h	    to     	Program files (x86)/Microsoft Visual Studio 9.0/VC/Include/GL
    include/GL/glxew.h	    to     	Program files (x86)/Microsoft Visual Studio 9.0/VC/Include/GL
    from the glew-1.10.0-win32-1.zip binary archive.

    And I added the following to my project->linker->input->additional dependencies:
    glew32.lib
    openGL32.lib
    glu32.lib
    gdi32.lib
    User32.lib

    Any ideas what is wrong? I hope you can help me
    Thanks in advance!
    Best regards,
    Nikolas

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2014
    Posts
    4
    Isn't there anybody out there who can help me?
    I mean, it's basically just including the dll and using a single basic function from it, but I'm unable to

  3. #3
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    No idea about the problem, sorry. Could be that you need to do something extra to make a regular (i.e. non-managed C++ .dll, like the downloaded glew32.dll is) work with the managed C++ when targeting .net.
    Is it an option for you to switch fully to C#? Then you could use OpenTK and sidestep the whole thing.

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2014
    Posts
    4
    Hi, thanks for the hint.
    I don't think that it's a problem with the unmanaged dll. I'm using libfftw (which is surely non-managed) in another project in pretty much the same way and it works. Last time I've seen this "unresolved external symbol"-error, it was due to a 64-bit dll instead of 32-bit, and after switching to 32 bit, everything worked. So it sounds like the dll doesent get recognized by the glew32.lib somehow. If I remove the glew32.lib from the additional dependencies, several other errors occur, mainly unresolved tokens, so it does find and use the lib.

    OpenTK is for .net in general, so it can be used with C++/CLI, too. C# is basically just a simplification of C++/CLI by removing the support for the old C++/C stuff.
    The main problem is that I didn't find any tutorials for using openTK for plotting data. So I wanted to implement the usual OpenGL-approach with glew and follow one of the tutorials on the web. But since I want to stay with my windows::forms that are simple and now well known to me, I had to solve the error here.
    If you know a better approach to learn OpenGL and use it with windows::forms and plot my data with it, than I will happily follow your advice.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Oct 2009
    Posts
    463
    Quote Originally Posted by Physikant View Post
    Last time I've seen this "unresolved external symbol"-error, it was due to a 64-bit dll instead of 32-bit, and after switching to 32 bit, everything worked. So it sounds like the dll doesent get recognized by the glew32.lib somehow. If I remove the glew32.lib from the additional dependencies, several other errors occur, mainly unresolved tokens, so it does find and use the lib.
    If you're using a 32-bit application, then 32-bit DLLs should be placed into Windows/SysWOW64 rather than Windows/System32 (see http://en.wikipedia.org/wiki/WoW64#R...nd_file_system ).

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2014
    Posts
    4
    Hey, thanks for the hint.
    I tried that, sadly it didn't change anything.

  7. #7
    Junior Member Newbie
    Join Date
    Sep 2008
    Posts
    25
    Hi,

    process of elimination: You must set a current opengl context, then call glewinit() before being able to use any glew. Have you done so? if not, it might help.

    let us know.

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2011
    Location
    USA
    Posts
    24
    Quote Originally Posted by Physikant View Post

    And then these errors:
    Code :
    5381    error LNK2020: Unresolved token (0A000016) __imp____glewCreateShader.    GLwindow.obj (thats my file which includes the tutorial code)
    5382    error LNK2020: Unresolved token (0A000024) __imp____glewCreateShader.    OpenGL_test.obj (thats the name of the project)
    5383    error LNK2001: Unresolved external symbol "__imp___glewCreateShader".    OpenGL_test.obj
    5384    error LNK2001: Unresolved external symbol "__imp___glewCreateShader".    GLwindow.obj
    5385    fatal error LNK1120: 3 unresolved external links.    C:\Users\ME\Documents\Visual Studio 2008\Projects\OpenGL_test\Debug\OpenGL_test.exe

    What I did:
    I installed glew as it is advised on the website:
    I copied
    Code :
    bin/Release/Win32/glew32.dll        to         Windows/system32
    lib/Release/Win32/glew32.lib        to         Program files (x86)/Microsoft Visual Studio 9.0/VC/Lib
    lib/Release/Win32/glew32s.lib        to         Program files (x86)/Microsoft Visual Studio 9.0/VC/Lib
    include/GL/glew.h                to         Program files (x86)/Microsoft Visual Studio 9.0/VC/Include/GL
    include/GL/wglew.h        to         Program files (x86)/Microsoft Visual Studio 9.0/VC/Include/GL
    include/GL/glxew.h        to         Program files (x86)/Microsoft Visual Studio 9.0/VC/Include/GL
    from the glew-1.10.0-win32-1.zip binary archive.

    And I added the following to my project->linker->input->additional dependencies:
    glew32.lib
    openGL32.lib
    glu32.lib
    gdi32.lib
    User32.lib
    Get rid of the glew32.lib and use glew32s.lib instead. It's a bunch of function pointer loading anyway so it doesn't really matter that it gets statically linked. Compile the library yourself or use the pre-built binaries. If you're on Visual Studio, in the file which uses glew.h, put this define in front of the include line like this:
    Code :
    // add a define
    #define GLEW_STATIC 1
     
    #include <GL/glew.h>
    #include <other_headers.h>
     
    // more code goes here
    .
    .
    .

    Then put this pragma in your main.cpp file:
    Code :
    #pragma comment(lib, "glew32s.lib")

    Make sure to use the x86 version of glew32s.lib if you're compiling for 32-bit systems. Otherwise use the x64 one which you may need to compile for yourself. I don't use Glew anymore but I've made a bunch of projects in the past that use glew32s.lib because glew32.lib tends to be very finicky.

Similar Threads

  1. Including glm.hpp causes compile error on visual studio
    By Jamesel in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-25-2018, 05:50 AM
  2. openCL using visual studio 2008..
    By phoebe0105 in forum OpenCL
    Replies: 0
    Last Post: 04-19-2010, 10:50 AM
  3. Using GLUT with visual studio 2008
    By zabes in forum OpenGL: General
    Replies: 8
    Last Post: 02-08-2010, 02:17 PM
  4. Visual Studio 2008 help
    By hokieOP in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-20-2009, 04:42 AM
  5. open GL and visual studio 2008
    By patelk7 in forum OpenGL: Windows
    Replies: 5
    Last Post: 02-26-2009, 01:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean