Imagination PowerVR SDK Blog

Getting link error when trying to create and render the text using UIRenderer


#1

Hello,

I have to render a simple 2d text in win32 application, everything being compiled but getting folowing link errors:

Error LNK2005 “class pvr::EmbeddedRefCountedResource __cdecl pvr::createGraphicsContext(void)” (?createGraphicsContext@pvr@@YA?AV?$EmbeddedRefCountedResource@VIGraphicsContext@pvr@@@1@XZ) already defined in app.obj myapp D:…\app\PVRGles.lib(ContextGles.obj) 1

Error LNK1169 one or more multiply defined symbols found trading_app D:…\app\Debug\trading_app.exe 1

this is the code that produces link error:

[scode lang=“C++”]class MyApp : public pvr::Shell {
private:
pvr::ui::UIRenderer spriteEngine;
pvr::ui::Text myText ;
// …
};

pvr::Result::Enum initView() {
// …
myText = spriteEngine.createText(“some text”); // this is the line causing link error
myText ->setAnchor(pvr::ui::anchor::TopLeft, glm::vec2(-1, 0));
myText ->setPixelOffset(30, -20);
}[/scode]

when calling createText function the link errors described above are thrown - I’m not understanding why it wants to create another graphicsContext !?

as additional info I’m linking the project against following libs:

[blockquote]PVRGles.lib
PVRNativeGles.lib
PVRCore.lib
PVRAssets.lib
PVREgl.lib
PVRShell.lib
PVRUIRenderer.lib
libEGL.lib
libGLESv2.lib[/blockquote]

What Am I doing wroung ?
How to get rid of the link errors ?

thanks


#2

Hi Fname,

It looks like you may have multiple includes or cyclic references meaning that the symbol createGraphicsContext (in this case a function) gets declared more than once and therefore causes a linker error. Also you do not need to link against either libEGL.lib or libGLESv2.lib (although that should not cause a problem).

If you could post the includes here that may be helpful in diagnosing the root cause. You could also delete the framework libraries and rebuild them. (found here: C:\Imagination\PowerVR_Graphics\PowerVR_SDK\SDK_2016_R1.3\Framework\Bin\WindowsVC2010\)

Regards,
Shaun


#3

Hi Shaun,

thanks for suggestions - well, actually I already had the framework libs rebuilt when was working on this app.
Also I removed from the additional dependencies list libEGL.lib and libGLESv2.lib - and it threw 30 LNK2019 erros on gl function calls - but this is expectable, because I use openGL functions directly - not from gl:: namespace or in any other way.

I have got 3 header files with their sources and one main project file from where the application starts working.

[blockquote]shader.h
//…std includes
#include <GLES3/gl3.h>

shader_manager.h
#include “PVRShell/PVRShell.h”
#include “shader.h”

trading_graph.h
#include <GLES3/gl3.h>
//…std includes
#include “PVRShell/PVRShell.h”

app.cpp (main application source file)
#if defined(APPLE) && defined (TARGET_OS_IPHONE)
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#else
#define GL_GLEXT_PROTOTYPES
#include <GLES3/gl3.h>
#include <EGL/egl.h>
#endif

#include “PVRShell/PVRShellNoPVRApi.h”
#include “PVRUIRenderer/PVRUIRenderer.h”
//std includes
#include “shader_manager.h”
#include “trading_graph.h”[/blockquote]

thanks


#4

Hi Fname,

In order to use PVRUIRenderer you must include PVRShell/PVRShell.h, this is because the UI Renderer relies on functionality provided by PVRAPI. I would suggest taking a look at the Intro UI Renderer which can be found here: C:\Imagination\PowerVR_Graphics\PowerVR_SDK\SDK_2016_R1.3\Examples\Beginner\05_IntroUIRenderer

Regards,
Shaun