Compiling MyGUI with OpenGL platform


31-01-2011 07:59:18

From what I see on the forums, I am not the only one having trouble building MyGUI with the OpenGL platform. However, I have not been able to solve all of my problems from reading other forums posts, so I'm posting with what I'm stuck on here.

For reference I am compiling MyGUI 3.0.1 on Windows 7 with a newly installed copy of MinGW (GCC 4.5.2).

After fixing the libwinmm problem ( and the size_t problem (, I get the following error which I have not been able to resolve:

c:/Users/Elliott/Desktop/mygui_build/MyGUI3.0/Platforms/OpenGL/OpenGLPlatform/src/MyGUI_OpenGLTexture.cpp: In member function 'virtual MyGUI::IRenderTarget* MyGUI::OpenGLTexture::getRenderTarget()':
c:/Users/Elliott/Desktop/mygui_build/MyGUI3.0/Platforms/OpenGL/OpenGLPlatform/src/MyGUI_OpenGLTexture.cpp:340:50: error: cannot allocate an object of abstract type 'MyGUI::OpenGLRTTexture'
c:/Users/Elliott/Desktop/mygui_build/MyGUI3.0/Platforms/OpenGL/OpenGLPlatform/include/MyGUI_OpenGLRTTexture.h:21:2: note: because the following virtual functions are pure within 'MyGUI::OpenGLRTTexture':
c:/Users/Elliott/Desktop/mygui_build/MyGUI3.0/MyGUIEngine/include/MyGUI_IRenderTarget.h:44:16: note: virtual void MyGUI::IRenderTarget::doRender(MyGUI::IVertexBuffer*, MyGUI::ITexture*, int)

This might have been mentioned in the second thread I linked above (it's little hard to make sense of the original post), but I don't see a solution listed.


P.S. In general should I stick with a stable version or should I be trying SVN head instead?


31-01-2011 09:21:37

First of all try to get newer MyGUI version either from svn or MyGUI 3.2.0 RC1. I think most or all of your issues was fixed.


31-01-2011 19:19:41

Here's what I get for 3.2.0 RC1:

First, (and I actually got this for 3.0.0 although I forgot to mention it,) when I install freetype to a non-standard directory, the build breaks, even when cmake supposedly found it. This is because cmake puts /path/to/include/freetype2 on the include list, but not /path/to/include itself (which contains ft2build.h). I solved this by adding an explicit -DCMAKE_CXX_FLAGS=-I/path/to/include parameter, but it would be convenient if this could be fixed to work out of the box.

[ 19%] Building CXX object MyGUIEngine/CMakeFiles/MyGUIEngine.dir/src/MyGUI_ResourceTrueTypeFont.cpp.obj
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/MyGUIEngine/src/MyGUI_ResourceTrueTypeFont.cpp:28:23: fatal error: ft2build.h: No such file or directory

Second, (and this is the one I'm stuck on):

[ 34%] Building CXX object Common/CMakeFiles/Common.dir/Base/OpenGL/BaseManager.cpp.obj
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Base/OpenGL/BaseManager.cpp: In member function 'virtual void* base::BaseManager::loadImage(int&, int&, MyGUI::PixelFormat&, const std::string&)':
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Base/OpenGL/BaseManager.cpp:569:18: error: 'PixelFormat' was not declared in this scope

Again, I'm compiling on Windows 7 with a new copy of MinGW (GCC 4.5.2).


31-01-2011 19:58:22

I found some info about this in google. Looks like that there is (or was) bug with PixelFormat's definitions in MinGW. Try adding line "using namespace Gdiplus;" into BaseManager.cpp


31-01-2011 21:49:08

Patched BaseManager.cpp. Next error:

[ 34%] Building CXX object Common/CMakeFiles/Common.dir/Base/OpenGL/BaseManager.cpp.obj
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Base/OpenGL/BaseManager.cpp: In member function 'virtual void base::BaseManager::saveImage(int, int, MyGUI::PixelFormat, void*, const std::string&)':
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Base/OpenGL/BaseManager.cpp:629:82: error: 'alloca' was not declared in this scope

Thanks for the help.


31-01-2011 22:20:47

Looks like we need to include malloc.h to get alloca on MinGW: ... oca-h.html

Next error:

[ 35%] Building CXX object Common/CMakeFiles/Common.dir/Input/Win32/PointerManager.cpp.obj
In file included from c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Input/Win32/PointerManager.cpp:11:0:
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Input/Win32/ResourceW32Pointer.cpp: In member function 'virtual void input::ResourceW32Pointer::deserialization(MyGUI::xml::Element*, MyGUI::Version)':
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Input/Win32/ResourceW32Pointer.cpp:39:44: error: cast from 'CHAR*' to 'WORD' loses precision
c:/Users/Elliott/Desktop/mygui_build/MyGUI_3.2.0_RC1/Common/Input/Win32/ResourceW32Pointer.cpp:41:44: error: cast from 'CHAR*' to 'WORD' loses precision
(repeated another 20 times or so...)


31-01-2011 23:34:46

By the way, I also tested svn head (r4106) and it has exactly the same issues that I've reported here (that is: using namespace Gdiplus; and #include <malloc.h>, and then my currently unresolved issue of CHAR* to WORD casts).


31-01-2011 23:39:30

Update to 4107 :)


01-02-2011 00:25:18

With r4108 I get a linking error:

Linking CXX executable ../../bin/Demo_Colour.exe
../../lib/libCommon.a(BaseManager.cpp.obj): In function `~BaseManager':
c:/Users/Elliott/Desktop/mygui_build/mygui-svn-4108/Common/Base/OpenGL/BaseManager.cpp:86: undefined reference to `GdiplusShutdown@4'
../../lib/libCommon.a(BaseManager.cpp.obj): In function `BaseManager':
c:/Users/Elliott/Desktop/mygui_build/mygui-svn-4108/Common/Base/OpenGL/BaseManager.cpp:81: undefined reference to `GdiplusStartup@12'
../../lib/libCommon.a(BaseManager.cpp.obj): In function `ZN7Gdiplus11GdiplusBasenwEj':
c:/bin/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../include/gdiplus/gdiplusbase.h:38: undefined reference to `GdipAlloc@4'

Please note however that I was only able to get this far after fixing both of the above problems again, which appear not to have been fixed. Here's the patch:

Index: Common/Base/OpenGL/BaseManager.cpp
--- Common/Base/OpenGL/BaseManager.cpp (revision 4108)
+++ Common/Base/OpenGL/BaseManager.cpp (working copy)
@@ -10,10 +10,14 @@
#include <GL/gl.h>
#include <GL/glu.h>

+#include <malloc.h>
//for image loader
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")

+using namespace Gdiplus;
// ▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒
const char* WND_CLASS_NAME = "MyGUI_Demo_window";


01-02-2011 10:24:06

Try r4109


01-02-2011 19:29:33

As of r4011 we're still got the link error:

Linking CXX executable ../../bin/Demo_Colour.exe
../../lib/libCommon.a(BaseManager.cpp.obj): In function `~BaseManager':
c:/Users/Elliott/Desktop/mygui_build/mygui-svn-4111/Common/Base/OpenGL/BaseManager.cpp:91: undefined reference to `GdiplusShutdown@4'
../../lib/libCommon.a(BaseManager.cpp.obj): In function `BaseManager':
c:/Users/Elliott/Desktop/mygui_build/mygui-svn-4111/Common/Base/OpenGL/BaseManager.cpp:86: undefined reference to `GdiplusStartup@12'
../../lib/libCommon.a(BaseManager.cpp.obj): In function `ZN7Gdiplus11GdiplusBasenwEj':
c:/bin/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../include/gdiplus/gdiplusbase.h:38: undefined reference to `GdipAlloc@4'



02-02-2011 02:44:20

Perhaps the #pragma comment(lib ...) option doesn't transfer to libraries that link with a compiled library? libCommon.a compiles just fine; it's only when we get to the sample code that we see this problem.

Also, have you considered specifying the linker flags using CMake? When I do this manually (by adding -lgdiplus to CMAKE_CXX_STANDARD_LIBRARIES), everything compiles fine (although this is hackish and I wouldn't recommend it as a general solution).

Thanks for all your help.


02-02-2011 05:47:29

The more I look at this the more I'm convinced that #pragma comment(lib ...) doesn't do anything at all for MinGW. One post on Stack Overflow says as much for GCC ( ... nder-linux), and I don't see why MinGW would be different.

How about something like the following? With this final modification, I can get all the way through the build without any trouble.

Index: CMake/Utils/MyGUIConfigTargets.cmake
--- CMake/Utils/MyGUIConfigTargets.cmake (revision 4111)
+++ CMake/Utils/MyGUIConfigTargets.cmake (working copy)
@@ -176,6 +176,9 @@
+ if (MINGW)
+ target_link_libraries(${PROJECTNAME} gdiplus)
+ endif ()
add_dependencies(${PROJECTNAME} MyGUI.DirectXPlatform)
target_link_libraries(${PROJECTNAME} MyGUI.DirectXPlatform)
Index: Common/Base/OpenGL/BaseManager.cpp
--- Common/Base/OpenGL/BaseManager.cpp (revision 4111)
+++ Common/Base/OpenGL/BaseManager.cpp (working copy)
@@ -17,7 +17,6 @@
# ifndef __MINGW32__
# pragma comment(lib, "gdiplus.lib")
# else
-# pragma comment(lib, "libgdiplus.a")
# include <malloc.h>
using namespace Gdiplus;
# endif


02-02-2011 09:40:53

Thank you for helping with this. I commited fix.


02-02-2011 23:06:08

Thanks. It compiles cleanly out of the box now.


18-07-2011 22:06:55

eds, so how have you solved the problem with "from 'CHAR*' to 'WORD' loses precision". I have the same kind of problem with mygui 3.2.0_RC1 in file: D:\Dev\MyGUI_3.2.0_RC1\Common\Input\Win32\ResourceW32Pointer.cpp. Thanks beforehand.

And also: I try to simply build MyGUI for use in OGRE, so tell me if this topic refers to building for OpenGL exactly. But, anyway, error message is the same, so reasons for that may be same also.


19-07-2011 04:20:43

Altren fixed it in SVN revision 4107, so that might be a place to start. If you still have trouble Altren might be the right person to ask about it.

I was compiling for OpenGL, no idea if that would affect this.