Runtime error upon button->load
« on: 24 July 2013, 00:41:33 »
Unhandled exception at at 0x767CC41F in myprogram.exe: Microsoft C++ exception: std::length_error at memory location 0x0021F38C.

I get this runtime error whenever the button-->load line is reached.
Any ideas what might be causing this?
 I downloaded the lastest TGUI version according to the TGUI download page
("Download the latest development snapshot from github" --> https://github.com/texus/TGUI/archive)/master.zip)

Code: [Select]
...
    tgui::Gui gui;
    tgui::Button::Ptr button(gui);
    button->load("TGUI/widgets/Button/BabyBlue");
    button->setSize(260, 60);
    button->setPosition(270, 440);
    button->setText("Login");
...

« Last Edit: 24 July 2013, 00:43:56 by robvleugel »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Runtime error upon button->load
« Reply #1 on: 24 July 2013, 00:50:54 »
I just looked up the error and it is thrown when creating a string that is longer than the maximum string size. I doubt that this is the case here.

Are you sure that you are not mixing release and debug libraries? This can cause strange things with strings.

If that's not the case, could you upload the project so that I can see if everything was set up correctly and possibly test it myself? I won't be able to do that before tomorrow (or maybe I should say until later today, as it has already passed midnight here).

Re: Runtime error upon button->load
« Reply #2 on: 24 July 2013, 01:10:56 »
I'm not sure, how do I know I mix up release and debug? :)
I'm linking tgui.lib, btw I'm using SFML2 by static linking. It did whine about some SFML dll files I needed so I grabbed these from the SFML/bin folder.

Its 1:15 here but I'm not planning on sleeping before I have this problem fixed, I might get nightmares.




*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Runtime error upon button->load
« Reply #3 on: 24 July 2013, 01:17:46 »
Take a look at the tutorial, if you haven't already.

When your project is in release mode, you need to link with tgui.lib. But when your project is in debug mode, you need to link with tgui-d.lib. On windows then the libraries must always match the build configuration in your project. Thats one of the reasons I prefer developing on linux.

Same time here, but I'm no longer waiting, I'm going to take a nap.

Edit: I overlooked that you are linking statically. But that way you can't get any errors about missing dlls. Are you sure you have SFML_STATIC defined? Also when linking statically to sfml you must do the same to tgui, so use the tgui-s.lib and tgui-s-d.lib libraries.
« Last Edit: 24 July 2013, 01:20:12 by texus »

Re: Runtime error upon button->load
« Reply #4 on: 24 July 2013, 01:25:14 »
I don't even have the tgui-s.lib and tgui-s-d.lib libraries. I guess that's where my problem lies, I'll rebuild TGUI tomorrow to include the static libraries. And the debug files, as I forgot to build these too.
Thanks for the help!


Re: Runtime error upon button->load
« Reply #5 on: 24 July 2013, 11:11:15 »
This topic would probably better suit in the intallation help right now but I dont want to start another topic.
I just downloaded the latest version of SFML and the latest version of TGUI, SFML is the release candidate that doesnt require any building. TGUI I build with cmake, both debug and release staticly. I linked the produced tgui-s-d.lib in my project and the include/lib directories were set correctly. After building my solution using the same code as above, I get a bunch of linking errors:

Code: [Select]
1>tgui-s-d.lib(Container.cpp.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in DebugEntity.obj
1>tgui-s-d.lib(Button.cpp.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in DebugEntity.obj
1>tgui-s-d.lib(Gui.cpp.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in DebugEntity.obj
1>tgui-s-d.lib(EventManager.cpp.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in DebugEntity.obj
etc.etc.

and:

Code: [Select]
Error 51 error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (__imp_?_Init@locale@std@@CAPAV_Locimp@12@XZ) C:\Dev\Projects\Myproject\Myproject\tgui-s-d.lib(Tab.cpp.obj)Myproject
Error 52 error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (__imp_?_Init@locale@std@@CAPAV_Locimp@12@XZ) C:\Dev\Projects\Myproject\Myproject\tgui-s-d.lib(Container.cpp.obj) Myproject

etc.etc.

Any idea what this might be causing?
_MSC_VER --> I'm using Visual studio 2012 express, is this not compatible?

« Last Edit: 24 July 2013, 11:13:57 by robvleugel »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Runtime error upon button->load
« Reply #6 on: 24 July 2013, 11:28:10 »
These errors are completely new to me.

Quote
mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700'
This apparently means that you are using a library that was compiled for VS2010 in a VS2012 project.
You can't use a library that was compiled with a different compiler, and libraries from different VC++ versions aren't compatible.

For now I assume that the other errors might be caused by this, so you should first fix this.

Quote
SFML is the release candidate that doesnt require any building.
What do you mean release candidate? If you just downloaded sfml then you have 2.0, or if you dowloaded from github then you have a newer version but then you would have to build it yourself. If you are really talking about the SFML2-RC from last year, then I must say that tgui isn't compatible with that version (but you don't seem to get errors when building tgui so that can't be the case).

Re: Runtime error upon button->load
« Reply #7 on: 24 July 2013, 11:33:03 »
Oh no I didnt mean release candidate, I ment the newest version : https://www.sfml-dev.org/download/sfml/2.0/  --> Visual C++ 11 (2012) - 32 bits

I'm using this one in VC++ 2013 and it works fine for my SFML project, but as soon as I include tgui it goes wrong.

« Last Edit: 24 July 2013, 11:34:47 by robvleugel »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Runtime error upon button->load
« Reply #8 on: 24 July 2013, 11:53:39 »
Quote
I'm using Visual studio 2012 express
Quote
I'm using this one in VC++ 2013
Which one is it? If it is not 2012 then I would recommend rebuilding sfml as well.

Technically VC++2013 doesn't even exist. It is VS2013 which comes with the VC++12 compiler. Visual studio names are based on the year they come out, while the compiler versions increment every time. A lot of people make mistakes with this, which sometimes makes it hard to understand.

But the main problem is that tgui seems to be compiled with VC++10 and you are using a newer compiler.
Did you select the right compiler in cmake?
« Last Edit: 24 July 2013, 11:56:18 by texus »

Re: Runtime error upon button->load
« Reply #9 on: 24 July 2013, 12:44:20 »
Did you select the right compiler in cmake?

How can I do that?
I'm selecting NMake makefiles in cmake, then use nmake to build TGUI using the Visual Studio 2012 command prompt

edit:
hm seems I'm uing the 2010 command prompt, cant find the 2012
« Last Edit: 24 July 2013, 12:45:56 by robvleugel »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Runtime error upon button->load
« Reply #10 on: 24 July 2013, 12:50:10 »
I was talking about generating a project instead of a makefile.
But if you selected NMake makefiles and build it with VS2012 then it should be fine.

I was downloading VS2012 myself when I got a BSOD, so I am now completely reinstalling windows. So maybe in a few hours I can test things myself.

Edit:
Quote
hm seems I'm uing the 2010 command prompt, cant find the 2012
That's what causing the problems. You can open the command prompt from inside VS.
Edit: Apparently not.
« Last Edit: 24 July 2013, 13:04:58 by texus »

Re: Runtime error upon button->load
« Reply #11 on: 24 July 2013, 13:39:56 »
No you cant open the command prompt from inside VS like in 2010, took me some time to figure out you can open it from VS > VS studio tools in the start menu.

It does seem to work now, but now its complaining about the Button image files.
button->load("Widgets/Button/BabyBlue"); doesnt seem to work but I guess I can figure it out.

Edit:
I did it!
I loaded my first button, I'm awsome!  8)
Thanks for the help
« Last Edit: 24 July 2013, 13:42:47 by robvleugel »

Re: Runtime error upon button->load
« Reply #12 on: 28 July 2013, 13:16:00 »
Can you tell me how you did it? I got the same problem.