Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems building "Using CEGUI In SFML" tutorial c  (Read 12742 times)

0 Members and 1 Guest are viewing this topic.

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« on: December 12, 2008, 10:49:03 am »
First, I wasn't sure where to put this, so I hope here is OK.

I am trying to build the "Using CEGUI In SFML" tutorial code from the wiki, but I can't get it to work. I get 69 linker errors. :?

Here is a sample:
Code: [Select]
1>App.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class CEGUI::Window * __thiscall CEGUI::System::setGUISheet(class CEGUI::Window *)" (__imp_?setGUISheet@System@CEGUI@@QAEPAVWindow@2@PAV32@@Z)
1>App.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class CEGUI::String const CEGUI::FrameWindow::EventCloseClicked" (__imp_?EventCloseClicked@FrameWindow@CEGUI@@2VString@2@B)
1>App.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CEGUI::UVector2::UVector2(class CEGUI::UDim const &,class CEGUI::UDim const &)" (__imp_??0UVector2@CEGUI@@QAE@ABVUDim@1@0@Z)
1>GUIManager.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class CEGUI::SchemeManager & __cdecl CEGUI::Singleton<class CEGUI::SchemeManager>::getSingleton(void)" (__imp_?getSingleton@?$Singleton@VSchemeManager@CEGUI@@@CEGUI@@SAAAVSchemeManager@2@XZ)
1>GUIManager.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual class CEGUI::Rect __thiscall CEGUI::OpenGLRenderer::getRect(void)const " (__imp_?getRect@OpenGLRenderer@CEGUI@@UBE?AVRect@2@XZ)
1>GUIManager.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall CEGUI::System::injectKeyUp(unsigned int)" (__imp_?injectKeyUp@System@CEGUI@@QAE_NI@Z)
If you want to see the rest, please let me know ;) They are all LNK2001

The included sample project is in Visual Studio 2008 format, but I am using the 2005 version, which can't read the project file. Therefore I am starting from scratch.

Here is what I have done:

1) I downloaded CEGUI 0.6.2b Binary Downloads for Microsoft Visual C++ 8 (2005) - With SP1 SDK and installed it.

2) I added these lines to the VC++ directories:

Library files:
...\CEGUI-SDK-0.6.2-vc8\dependencies\lib
...\CEGUI-SDK-0.6.2-vc8\lib

Include files:
...\CEGUI-SDK-0.6.2-vc8\include
...\CEGUI-SDK-0.6.2-vc8\RendererModules\OpenGLGUIRenderer

The last one, \RendererModules\OpenGLGUIRenderer, wasn't in the tutorial, but the program was looking for it when I first tried to compile it (in a later step), so I added it.

3) I started a new empty Win32 project (not a console project), copied the source and header files from the tutorial project to the new project folder, and added them to the project.

4) I set the project to compile in release mode (as that was what was done in the tutorial), and added these to Linker/Input/Additional Dependencies, in the project properties:
Code: [Select]
sfml-graphics.lib sfml-main.lib sfml-system.lib sfml-window.lib glu32.lib pcre.lib CEGUIBase_Static.lib CEGUIExpatParser_Static.lib expat.lib CEGUISILLYImageCodec_Static.lib SILLY.lib OpenGLGUIRenderer_Static.lib CEGUIFalagardWRBase_Static.lib

5) Tried compiling, and got the errors above.  :?

I am not overly experienced, so it is probably (hopefully) something something painfully obvious and simple.

I really hope someone can help, as I would like to get started on learning this crazy GUI thing.


Thank you in advance!

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #1 on: December 12, 2008, 12:32:48 pm »
I want it too :)

But i want compile on mingw, but no success.

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #2 on: December 12, 2008, 01:08:37 pm »
You are linking to the static library while the header is referring to the dynamic library (__declspec(dllimport) ). You should consult CEGUI's documentation, there should be a compilation flag to define, something similar to SFML_DYNAMIC.

Edit: I'm bored, so I googled it for you: Define CEGUI_STATIC in your project
Edit2: Expect more unresolved external  errors :wink: since you'll have to link with all the platform dependent libraries that CEGUI and its components use. Just google all those functions that begins with __imp__ to find out what window's library to link against or just post the errors here.

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #3 on: December 12, 2008, 07:08:51 pm »
If the above is true, the wiki should probably be updated.

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #4 on: December 13, 2008, 05:13:34 pm »
Confirmed, this is from the latest CEGUI's header
Code: [Select]
#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
#   ifdef CEGUIBASE_EXPORTS
#       define CEGUIEXPORT __declspec(dllexport)
#   else
#       define CEGUIEXPORT __declspec(dllimport)
#   endif
#       define CEGUIPRIVATE
#else
#       define CEGUIEXPORT
#       define CEGUIPRIVATE
#endif

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #5 on: December 13, 2008, 07:24:50 pm »
But you compile cegui with sfml on mingw ?

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #6 on: December 14, 2008, 11:22:06 am »
Quote
But you compile cegui with sfml on mingw ?

No, I used MSVC

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #7 on: December 14, 2008, 11:52:25 am »
You compile and its function OK ?

Can you test with mingw? I need it too much.

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #8 on: December 14, 2008, 03:04:36 pm »
Thanks a lot, bullno1!

I did as you recommended, and I am down to 8 errors by now. Yay!
Turns out that, apart from defining CEGUI_STATIC, I had to add winmm.lib and OpenGL32.lib to the already long list of additional dependencies.

Here are the remaining errors:
Code: [Select]
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Load_Char
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Init_FreeType
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Done_Face
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Done_FreeType
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Get_Next_Char
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Get_First_Char
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Set_Char_Size
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_New_Memory_Face
I tried google'ing a couple of these, but I couldn't really understand what the problem is, or what to do about it. Maybe you know something? :)

By the way, where would be the proper place to put the #define CEGUI_STATIC statement? If I put it at the top of main.cpp it doesn't do squat, but if I put it in CEGUIConfig.h or CEGUIBase.h it has the desired effect.

I am guessing CEGUIConfig.h.

I never used a library that needed any definitions or special setting up before, and I do not really feel too comfortable editing their source files, but maybe I should just get used to that? Is that normal practice?

Thanks again!

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #9 on: December 14, 2008, 03:12:48 pm »
Quote
I never used a library that needed any definitions or special setting up before, and I do not really feel too comfortable editing their source files, but maybe I should just get used to that? Is that normal practice?

No, the headers are not meant to be edited. It's normal for libraries to have "special definitions". SFML does that too (SFML_DYNAMIC). All those are stated in the docs or tutorial of the libraries.

Quote
I tried google'ing a couple of these, but I couldn't really understand what the problem is, or what to do about it. Maybe you know something? Smile

You need to link against freetype library to solve the rest of the errors. I think it's distributed along with CEGUI, in the dependency folder.

Quote
Turns out that, apart from defining CEGUI_STATIC, I had to add winmm.lib and OpenGL32.lib to the already long list of additional dependencies.

You are linking statically, that's why

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #10 on: December 15, 2008, 09:46:29 am »
Quote from: "bullno1"
No, the headers are not meant to be edited. It's normal for libraries to have "special definitions". SFML does that too (SFML_DYNAMIC). All those are stated in the docs or tutorial of the libraries.
Yeah, OK, I guess the right way is to #define CEGUI_STATIC every time I need to #include <cegui.h>, then. Seems a little cumbersome, though, but I guess I can live with that. I see now why I can't just #define CEGUI_STATIC at the top of main.cpp, because it might not get compiled before the file that has the #include <cegui.h> statement. Silly me...

Quote from: "bullno1"
Quote
I tried google'ing a couple of these, but I couldn't really understand what the problem is, or what to do about it. Maybe you know something? Smile

You need to link against freetype library to solve the rest of the errors. I think it's distributed along with CEGUI, in the dependency folder.

Quote
Turns out that, apart from defining CEGUI_STATIC, I had to add winmm.lib and OpenGL32.lib to the already long list of additional dependencies.

You are linking statically, that's why
Ah yes, that makes a lot of sense when I think about it. So simple, yet so confusing.

I also noticed that I was linking against the dynamic versions of the SFML .lib files.
Now, this HAS to be an error in the tutorial, because there is no #define SFML_DYNAMIC anywhere in the source files.
I am really starting to doubt that this ever compiled with the settings described in the tutorial..

So for anyone following this thread, I now have
Code: [Select]
sfml-graphics-s.lib sfml-main.lib sfml-system-s.lib sfml-window-s.lib glu32.lib pcre.lib CEGUIBase_Static.lib CEGUIExpatParser_Static.lib expat.lib CEGUISILLYImageCodec_Static.lib SILLY.lib OpenGLGUIRenderer_Static.lib CEGUIFalagardWRBase_Static.lib winmm.lib OpenGL32.lib freetype.libin Properties->Linker->input->Additional Dependencies.

And..........Drum roll.........IT COMPILES! :shock: YAY!  :D

Of course, when I try to run it, I get
Quote
sfmlCEGUI.exe - Application Error

The application failed to initialize properly (0xc0150002). Click on OK to terminate the application.
:? Oh well.. Luckily I can think of a couple of things to try to get it to work. I wonder if it would have been faster to just build my own simple GUI system ;) But then I wouldn't have learned as much.

EDIT: OK, I take it back. I have no idea how to get it to run.

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #11 on: December 15, 2008, 10:09:04 am »
Quote

Yeah, OK, I guess the right way is to #define CEGUI_STATIC every time I need to #include <cegui.h>, then. Seems a little cumbersome, though, but I guess I can live with that. I see now why I can't just #define CEGUI_STATIC at the top of main.cpp, because it might not get compiled before the file that has the #include <cegui.h> statement. Silly me...

Quote
Now, this HAS to be an error in the tutorial, because there is no #define SFML_DYNAMIC anywhere in the source files.


No, you don't do it in the source file, you do it in the compiler setting since it's a global definition. From what you're posting, I guess you're using Visual C++. The setting is in : C/C++->Preprocessor->Preprocesor definitions

Quote

The application failed to initialize properly (0xc0150002). Click on OK to terminate the application.

No idea, maybe it's a CRT problem. Make sure you link against the correct lib for your compiler. MSVC 2005 and MSVC 2008 libraries are sometimes incompatible. What are the messages in the debug console?

No offense but your C++ knowledge seems lacking. I suggest that you should learn the basic first, SFML examples look easy but creating a complete application is not that simple.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problems building "Using CEGUI In SFML" tutorial c
« Reply #12 on: December 15, 2008, 10:09:11 am »
This kind of macros are not meant to be defined in every CPP file including CeGUI or SFML headers. You have to define them globally in your project's makefile / options (that's why they don't appear in any tutorial source code ;)).

If you're using Visual C++, then it's located in "project options" --> "C/C++" --> "Preprocessor" --> "Preprocessor definitions".
Laurent Gomila - SFML developer

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #13 on: December 15, 2008, 05:39:39 pm »
Hah - simultaneous posting! :)
Thanks guys, that way makes a lot more sense.

Quote from: "bullno1"
Make sure you link against the correct lib for your compiler. MSVC 2005 and MSVC 2008 libraries are sometimes incompatible.
The only things I am linking against are sfml files, winmm.lib (which came with the compiler, I believe), and the files that came with the CEGUI SDK (which is supposed to be for my exact compiler version, VS 2005 sp1), so I don't think that is the problem.

Quote from: "bullno1"
What are the messages in the debug console?
This is everything I get:
Code: [Select]
'sfmlCEGUI.exe': Loaded '...\sfmlCEGUI\release\sfmlCEGUI.exe', Symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\opengl32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\glu32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2\msvcp80.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2\msvcr80.dll', No symbols loaded.
'sfmlCEGUI.exe': Loaded '...\sfmlCEGUI\release\SILLY.dll', Binary was not built with debug information.
LDR: LdrpWalkImportDescriptor() failed to probe ...\sfmlcegui\release\SILLY.dll for its manifest, ntstatus 0xc0150002
Debugger:: An unhandled non-continuable exception was thrown during process load
The program '[1744] sfmlCEGUI.exe: Native' has exited with code -1072365566 (0xc0150002).
So maybe it has something to do with SILLY?

Quote from: "bullno1"
No offense but your C++ knowledge seems lacking.
None taken, and it is!

Quote from: "bullno1"
I suggest that you should learn the basic first, SFML examples look easy but creating a complete application is not that simple.
Well, actually I have learned quite a lot of basics. These are just some of the topics I have studied: Functions, control structures, file I/O, classes, inheritance, polymorphism, templates (both using and creating), operator overloading, search and sort algorithms, multiple inheritance, the STL, function pointers, functors, and the list goes on.

This is also not my first application. I have actually made a couple games before, and just last week I integrated a physics engine (Box2D) into my little engine, with no major Problems.

Forgive me for saying this, but given the size of C++, asking someone to learn "the basics" seems a little vague, and I mean that in the least offensive way possible.
Besides, learning some basic skills is exactly what I am trying to do here.

Don't get me wrong; I am grateful for everything I have received here, and I will not be any less grateful if you decide to stop helping me.

Knowledge is gold -and you have given me some.

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Problems building "Using CEGUI In SFML" tutorial c
« Reply #14 on: December 16, 2008, 05:39:58 am »
Quote
Well, actually I have learned quite a lot of basics. These are just some of the topics I have studied: Functions, control structures, file I/O, classes, inheritance, polymorphism, templates (both using and creating), operator overloading, search and sort algorithms, multiple inheritance, the STL, function pointers, functors, and the list goes on.

That's a lot. I think you just somehow overlooked some topics.

This looks like a CRT problem.
I think you're linking with the wrong version of CEGUI. If your program is in debug mode, link against debug version of CEGUI(those with _d) . In release mode, link against those without _d. Same thing goes for SFML.

 

anything