Hello opengl buddies..
I've been working with opengl for several weeks now, i stumbled upon an
issue. I'm using glut & MS Visual C++, and I can't seem to use
glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
Then, I get an
error LNK2001: unresolved external symbol __imp____glewWindowPos2i
It maybe has to do something with including or VC++ dependencies hence
the "unresolved external"... I don't know...
Can you help me? :)
|
|
0
|
|
|
|
Reply
|
Spock
|
11/24/2009 9:38:40 PM |
|
Spock wrote:
> Hello opengl buddies..
>
> I've been working with opengl for several weeks now, i stumbled upon an
> issue. I'm using glut & MS Visual C++, and I can't seem to use
> glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
> Then, I get an
> error LNK2001: unresolved external symbol __imp____glewWindowPos2i
>
> It maybe has to do something with including or VC++ dependencies hence
> the "unresolved external"... I don't know...
> Can you help me? :)
How about actually linking against GLEW. Just including glew.h won't do the
trick. You also must add glew.lib to the libraries you link against in your
linker settings.
--
OpenGL tip #42:
How to exactly map texture texels to screen pixels:
<http://preview.tinyurl.com/cgndc8>
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
11/24/2009 10:19:17 PM
|
|
On 24 stu, 22:38, Spock <sp...@enterprise.com> wrote:
> Hello opengl buddies..
>
> I've been working with opengl for several weeks now, i stumbled upon an
> issue. I'm using glut & MS Visual C++, and I can't seem to use
> glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
> Then, I get an
> error LNK2001: unresolved external symbol __imp____glewWindowPos2i
>
> It maybe has to do something with including or VC++ dependencies hence
> the "unresolved external"... I don't know...
> Can you help me? :)
If you're using Mesa 3D Graphics Library and VC++, and need to use
glWindowPos2i you need to use the
OpenGL extension mechanism to get a pointer to the specified function,
ie. wglGetProcAddress("glWindowPos2i");
Instead of GL/glew.h, you can use:
#include <GL/mesa_wgl.h>
#include <GL/wglew.h>
After that include, insert this line:
typedef void (WINAPI *WINPOS)(int x, int y);
And finnaly, before using glWindowPos2i func. declare and initialize
the function:
WINPOS glWindowPos2i;
glWindowPos2i = (WINPOS)wglGetProcAddress("glWindowPos2i");
There is no need for extra linker settings.
|
|
0
|
|
|
|
Reply
|
beaver
|
11/24/2009 10:55:47 PM
|
|
Wolfgang Draxinger wrote:
> Spock wrote:
>
>> Hello opengl buddies..
>>
>> I've been working with opengl for several weeks now, i stumbled upon an
>> issue. I'm using glut & MS Visual C++, and I can't seem to use
>> glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
>> Then, I get an
>> error LNK2001: unresolved external symbol __imp____glewWindowPos2i
>>
>> It maybe has to do something with including or VC++ dependencies hence
>> the "unresolved external"... I don't know...
>> Can you help me? :)
>
> How about actually linking against GLEW. Just including glew.h won't do the
> trick. You also must add glew.lib to the libraries you link against in your
> linker settings.
>
Seems like glew.lib did not came with Mesa, anyway, I've downloaded the
lib file, pasted it to lib and the error is gone.. However, when I run
the app it crashes...
|
|
0
|
|
|
|
Reply
|
Spock
|
11/24/2009 11:06:59 PM
|
|
beaver wrote:
> On 24 stu, 22:38, Spock <sp...@enterprise.com> wrote:
>> Hello opengl buddies..
>>
>> I've been working with opengl for several weeks now, i stumbled upon an
>> issue. I'm using glut & MS Visual C++, and I can't seem to use
>> glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
>> Then, I get an
>> error LNK2001: unresolved external symbol __imp____glewWindowPos2i
>>
>> It maybe has to do something with including or VC++ dependencies hence
>> the "unresolved external"... I don't know...
>> Can you help me? :)
>
> If you're using Mesa 3D Graphics Library and VC++, and need to use
> glWindowPos2i you need to use the
> OpenGL extension mechanism to get a pointer to the specified function,
> ie. wglGetProcAddress("glWindowPos2i");
>
> Instead of GL/glew.h, you can use:
>
> #include <GL/mesa_wgl.h>
> #include <GL/wglew.h>
>
> After that include, insert this line:
>
> typedef void (WINAPI *WINPOS)(int x, int y);
>
> And finnaly, before using glWindowPos2i func. declare and initialize
> the function:
>
> WINPOS glWindowPos2i;
> glWindowPos2i = (WINPOS)wglGetProcAddress("glWindowPos2i");
>
> There is no need for extra linker settings.
Thank you for your solution beaver, it works fine for me. But I'm
looking for more elegant solution like Wolfgang is offering, so my
friends that use Linux can also compile this.
Wolfgangs solution is syntacticly ok, but application crashes on
glWindowPos2i
|
|
0
|
|
|
|
Reply
|
Spock
|
11/24/2009 11:12:13 PM
|
|
On 25 stu, 00:12, Spock <sp...@enterprise.com> wrote:
> beaver wrote:
> > On 24 stu, 22:38, Spock <sp...@enterprise.com> wrote:
> >> Hello opengl buddies..
>
> >> I've been working with opengl for several weeks now, i stumbled upon an
> >> issue. I'm using glut & MS Visual C++, and I can't seem to use
> >> glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
> >> Then, I get an
> >> error LNK2001: unresolved external symbol __imp____glewWindowPos2i
>
> >> It maybe has to do something with including or VC++ dependencies hence
> >> the "unresolved external"... I don't know...
> >> Can you help me? :)
>
> > If you're using Mesa 3D Graphics Library and VC++, and need to use
> > glWindowPos2i you need to use the
> > OpenGL extension mechanism to get a pointer to the specified function,
> > ie. wglGetProcAddress("glWindowPos2i");
>
> > Instead of GL/glew.h, you can use:
>
> > #include <GL/mesa_wgl.h>
> > #include <GL/wglew.h>
>
> > After that include, insert this line:
>
> > typedef void (WINAPI *WINPOS)(int x, int y);
>
> > And finnaly, before using glWindowPos2i func. declare and initialize
> > the function:
>
> > WINPOS glWindowPos2i;
> > glWindowPos2i = (WINPOS)wglGetProcAddress("glWindowPos2i");
>
> > There is no need for extra linker settings.
>
> Thank you for your solution beaver, it works fine for me. But I'm
> looking for more elegant solution like Wolfgang is offering, so my
> friends that use Linux can also compile this.
>
> Wolfgangs solution is syntacticly ok, but application crashes on
> glWindowPos2i
You can use compiler macros for that purpose.
|
|
0
|
|
|
|
Reply
|
beaver
|
11/25/2009 12:17:36 AM
|
|
On 2009-11-24, Spock <spock@enterprise.com> wrote:
>>
>> How about actually linking against GLEW. Just including glew.h won't do the
>> trick. You also must add glew.lib to the libraries you link against in your
>> linker settings.
>>
>
> Seems like glew.lib did not came with Mesa, anyway, I've downloaded the
> lib file, pasted it to lib and the error is gone.. However, when I run
> the app it crashes...
You must check that an extension is really available at runtime before
using it. GLEW will initialize unsupported extension entry points to
null (which is probably why your program crashes), so you can just check
that instead of parsing the GL_EXTENSIONS string if you like.
--
John Tsiombikas (Nuclear / Mindlapse)
http://nuclear.sdf-eu.org/
|
|
0
|
|
|
|
Reply
|
John
|
11/25/2009 9:36:42 AM
|
|
John Tsiombikas wrote:
> On 2009-11-24, Spock <spock@enterprise.com> wrote:
>>> How about actually linking against GLEW. Just including glew.h won't do the
>>> trick. You also must add glew.lib to the libraries you link against in your
>>> linker settings.
>>>
>> Seems like glew.lib did not came with Mesa, anyway, I've downloaded the
>> lib file, pasted it to lib and the error is gone.. However, when I run
>> the app it crashes...
>
> You must check that an extension is really available at runtime before
> using it. GLEW will initialize unsupported extension entry points to
> null (which is probably why your program crashes), so you can just check
> that instead of parsing the GL_EXTENSIONS string if you like.
>
>
Ok, cool, and how exactly would I do that?
|
|
0
|
|
|
|
Reply
|
Spock
|
11/25/2009 1:27:44 PM
|
|
Spock wrote:
>> You must check that an extension is really available at runtime before
>> using it. GLEW will initialize unsupported extension entry points to
>> null (which is probably why your program crashes), so you can just
check
>> that instead of parsing the GL_EXTENSIONS string if you like.
>>
>>
> Ok, cool, and how exactly would I do that?
By checking the function pointer for (not) being null.
if(glWindowPos2i) {
glWindowPos2i(...);
} else {
fprintf(stderr, "glWindowPos2i not supported\n");
return;
}
You can also implement a small generic placeholder function, emitting an
informative message, which address you place in uninitialized GLEW
function pointers. Not that such a function _must_ exit the program, if
it's used to fill in for functions that return a value.
If your runtime environment implements some backtrace functionality one
can also print nice debug information. Example with GNU glibc:
void not_implemented(...)
{
#define MAX_CALL_DEPTH 1000
void *callptrs[MAX_CALL_DEPTH];
int calldepth;
calldepth = backtrace(callptrs, MAX_CALL_DEPTH);
fprintf(stderr, "Unimplemented function called - Backtrace, last
call first:\n");
backtrace_symbols_fs(callptrs, calldepth, stderr);
fflush(stderr);
_exit(-1); /* IMPORTANT: Use the underscore exit for immediate
process termination */
}
void init_GL_ext()
{
/* ... */
if(!glWindowPos2i)
glWindowPos2i = not_implemented();
}
Wolfgang
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
11/26/2009 12:00:45 AM
|
|
On 25 stu, 00:12, Spock <sp...@enterprise.com> wrote:
> beaver wrote:
> > On 24 stu, 22:38, Spock <sp...@enterprise.com> wrote:
> >> Hello opengl buddies..
>
> >> I've been working with opengl for several weeks now, i stumbled upon an
> >> issue. I'm using glut & MS Visual C++, and I can't seem to use
> >> glWindow2i method. Then I've tried MesaGLUT, included <GL/glew.h>...
> >> Then, I get an
> >> error LNK2001: unresolved external symbol __imp____glewWindowPos2i
>
> >> It maybe has to do something with including or VC++ dependencies hence
> >> the "unresolved external"... I don't know...
> >> Can you help me? :)
>
> > If you're using Mesa 3D Graphics Library and VC++, and need to use
> > glWindowPos2i you need to use the
> > OpenGL extension mechanism to get a pointer to the specified function,
> > ie. wglGetProcAddress("glWindowPos2i");
>
> > Instead of GL/glew.h, you can use:
>
> > #include <GL/mesa_wgl.h>
> > #include <GL/wglew.h>
>
> > After that include, insert this line:
>
> > typedef void (WINAPI *WINPOS)(int x, int y);
>
> > And finnaly, before using glWindowPos2i func. declare and initialize
> > the function:
>
> > WINPOS glWindowPos2i;
> > glWindowPos2i = (WINPOS)wglGetProcAddress("glWindowPos2i");
>
> > There is no need for extra linker settings.
>
> Thank you for your solution beaver, it works fine for me. But I'm
> looking for more elegant solution like Wolfgang is offering, so my
> friends that use Linux can also compile this.
>
> Wolfgangs solution is syntacticly ok, but application crashes on
> glWindowPos2i
The provided solution (using compiler macros) is working very fine,
but anyway, there are some other possible solutions.
The interesting solution on specified problem can be find here:
https://svn.assembla.com/svn/LaspView/src/SpiceRender/glWindowPos.cpp
so, check it out!
Cheers
|
|
0
|
|
|
|
Reply
|
beaver
|
11/30/2009 8:19:20 PM
|
|
|
9 Replies
475 Views
(page loaded in 0.068 seconds)
|