A opengl es program linking error

hi all:
i am coding a open gl es program
i use POWER VR SDK - PC EMULATOR

the compile is ok
but link error as below:

OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol _glDrawArrays@12
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol _glColorPointer@16
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol _glVertexPointer@16
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol _glEnableClientState@4
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol _glClear@4
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol _glClearColor@16

i use visual C++6.0, and link libgles_cl.lib.
could anyone tell me what’s going on?

all egl* function are ok but gl* are linking error…

I’ve tested linking and it works just fine using VC++ 6.0. Are you sure you are using the right gl.h header file?

Your error messages show that the linker is trying to link _gl<…> functions, though it should link __imp__gl<…> instead. This indicates that the functions are not declared as __declspec(dllimport). Usually that should be the case as GL_API should be #define’d as __declspec(dllimport) at the top of GLES/gl.h.

glClearColor is not part of the OpenGL ES Common Lite profile (libgles_cl.lib). Use glClearColorx if you require Common Lite.

hi Xmas:

i use this one :

C:\Download\OpenGL ES\SDKPackage\Builds\OGLES\Include\GLES\gl.h

i think it’s correct one.

Yes, that should be the correct header file. Please make sure this is the only (or at least the first) gl.h on your include path. You can easily check by adding a syntax error to it and see whether it still compiles.

Which version of the PowerVR SDK are you using? Is there a line with
#define GL_API __declspec(dllimport)
at the top of gl.h? Does that line get used?

1)i don’t know the version of the PVR SDK. but i just download it recently.

2)there are no "#define GL_API __declspec(dllimport) " in gl.h
3)even i add "#define GL_API __declspec(dllimport) " manually, there are still linking error msg.

hi Xmas:
if i add “#define GLAPI __declspec(dllimport)”
the linking error msg. like bellow:

OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol __imp__glDrawArrays@12
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol __imp__glColorPointer@16
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol __imp__glVertexPointer@16
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol __imp__glEnableClientState@4
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol __imp__glClear@4
OGLESHelloTriangle_Windows.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
Debug/OGLESHelloTriangle.exe : fatal error LNK1120: 6 unresolved externals

It seems like your gl.h header file is either leftover from a very old PowerVR SDK install or from a different source altogether. HelloTriangle is a recent addition, but the #define GL_API line has been there for ages. Could you please check the date on that file?

hi xmas

the date of gl.h is 2006/07/20

Ok, so this seems to be the OpenGL ES 1.0 PC Emulation SDK

Please try these steps (assuming you unzipped the SDK package to C:\PowerVR, replace as required):
[ul][li]Create a new empty Win32 project in VC++ 6.0[/:m:3me0sm35][/li][li]Add OGLESHelloTriangle_Windows.cpp to the Source Files[/:m:3me0sm35][/li][li]Open the project settings (Alt+F7) and set the following for All configurations:[/li][list:3me0sm35][li]In the Debug tab, category General, set the Working directory to C:\PowerVR\SDKPackage\Builds\OGLES\WindowsPC\Lib[/:m:3me0sm35][/li][li]In the C/C++ tab, category Preprocessor,[/li][list:3me0sm35][li]add OGLESLITE to the Preprocessor definitions[/:m:3me0sm35][/li][li]add C:\PowerVR\SDKPackage\Builds\OGLES\Include;C:\PowerVR\SDKPackage\Builds\OGLES\WindowsPC\Include to Additional include directories[/:m:3me0sm35][/ul][/:m:3me0sm35][]In the Link tab, category Input,[/li][ul][li]add libgles_cl.lib to Object/library modules[/:m:3me0sm35][/li][]add C:\PowerVR\SDKPackage\Builds\OGLES\WindowsPC\Lib to Additional library path[/:m:3me0sm35][/ul][/:m:3me0sm35][/list:u:3me0sm35][/:m:3me0sm35][]Build and run the project[/:m:3me0sm35][/list:u:3me0sm35]Following these steps, building and running worked fine for me.

hi Xmas:
follow the step u say, i build my sample program success

thanks a lot.

i am coding a open gl es program in LinuxPC
how to compile with gcc?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.