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

Author Topic: help decrypting error message  (Read 3546 times)

0 Members and 1 Guest are viewing this topic.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
help decrypting error message
« on: June 12, 2014, 12:00:06 am »
I'm working through the SFML game dev book, and it's pretty great. However, when coding along to the chapter 7 - Warfare Unleashed - Implementing Gameplay I encountered this error, that I haven't been able to figure out on my own:

Quote

22:31:46: Starting: "/usr/bin/make"
g++ -c -pipe -std=c++11 -Wall -Wextra -g -Wall -W -DQT_WEBKIT -I/usr/share/qt4/mkspecs/linux-g++ -I../SFMLbook -I../SFMLbook -I. -o world.o ../SFMLbook/world.cpp
In file included from /usr/include/c++/4.8/set:60:0,
                 from ../SFMLbook/scenenode.hpp:13,
                 from ../SFMLbook/entity.hpp:4,
                 from ../SFMLbook/aircraft.hpp:4,
                 from ../SFMLbook/world.hpp:4,
                 from ../SFMLbook/world.cpp:1:
/usr/include/c++/4.8/bits/stl_tree.h: In instantiation of 'std::_Rb_tree_node<_Val>::_Rb_tree_node(_Args&& ...) [with _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >]':
/usr/include/c++/4.8/ext/new_allocator.h:120:4:   required from 'void __gnu_cxx::new_allocator< <template-parameter-1-1> >::construct(_Up*, _Args&& ...) [with _Up = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Tp = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >]'
/usr/include/c++/4.8/bits/alloc_traits.h:254:4:   required from 'static typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Alloc = std::allocator<std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > > >; typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type = void]'
/usr/include/c++/4.8/bits/alloc_traits.h:393:57:   required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Alloc = std::allocator<std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > > >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'
/usr/include/c++/4.8/bits/stl_tree.h:408:36:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*]'
/usr/include/c++/4.8/bits/stl_tree.h:429:55:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_clone_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*]'
/usr/include/c++/4.8/bits/stl_tree.h:1087:43:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_copy(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type) [with _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*]'
/usr/include/c++/4.8/bits/stl_tree.h:659:50:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Rb_tree(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&) [with _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >]'
/usr/include/c++/4.8/bits/stl_map.h:181:22:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = Fonts::ID; _Tp = std::unique_ptr<sf::Font, std::default_delete<sf::Font> >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >]'
../SFMLbook/resourceholder.hpp:11:7:   required from here
/usr/include/c++/4.8/bits/stl_tree.h:140:49: error: use of deleted function 'constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = const Fonts::ID; _T2 = std::unique_ptr<sf::Font, std::default_delete<sf::Font> >]'
    _M_value_field(std::forward<_Args>(__args)...) { }
                                                 ^
In file included from /usr/include/c++/4.8/utility:70:0,
                 from /usr/include/c++/4.8/algorithm:60,
                 from /usr/local/include/SFML/Graphics/Rect.hpp:32,
                 from /usr/local/include/SFML/Graphics/Transform.hpp:32,
                 from /usr/local/include/SFML/Graphics/Transformable.hpp:32,
                 from ../SFMLbook/scenenode.hpp:6,
                 from ../SFMLbook/entity.hpp:4,
                 from ../SFMLbook/aircraft.hpp:4,
                 from ../SFMLbook/world.hpp:4,
                 from ../SFMLbook/world.cpp:1:
/usr/include/c++/4.8/bits/stl_pair.h:127:17: note: 'constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = const Fonts::ID; _T2 = std::unique_ptr<sf::Font, std::default_delete<sf::Font> >]' is implicitly deleted because the default definition would be ill-formed:
       constexpr pair(const pair&) = default;
                 ^
/usr/include/c++/4.8/bits/stl_pair.h:127:17: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = sf::Font; _Dp = std::default_delete<sf::Font>]'
In file included from /usr/include/c++/4.8/memory:81:0,
                 from ../SFMLbook/scenenode.hpp:11,
                 from ../SFMLbook/entity.hpp:4,
                 from ../SFMLbook/aircraft.hpp:4,
                 from ../SFMLbook/world.hpp:4,
                 from ../SFMLbook/world.cpp:1:
/usr/include/c++/4.8/bits/unique_ptr.h:273:7: error: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^
make: *** [world.o] Error 1
22:31:47: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SFMLbook (kit: Desktop)
When executing step 'Make'

I've been going over my code and comparing it to the functioning source from the LaurentGomila GitHub page, but I'm just unable to find any difference in my own code.

So from what I can tell this has something to do with std::set, but it's difficult for me to figure out anything else than that, because this traceback message doesn't actually seem to explicitly show where the problem is in my source, but points to a standard library file instead. Following the error through the files ends up at the class declaration of ResourceHolder before going into stl_tree.h.

So please help me figure out what may be causing this error.

--

As an aside, here are some personal remarks not directly related to the issue: I'm using the book as a code along and intro to my first real C++ project. Having learnt programming in python, the transition to C++ was shocking in several ways, mostly due to the extreme complexity of the language and how frequently I must go digging for answers to things which were more or less intuitive in python. I don't have any inherent problem with complexity itself, because this technical kind of problem solving is part of why I enjoy programming so much. However, I do consider C++ a pretty awful language by modern standards, because the nature of it's complexity is that of baggage from decades ago, and implementing too many paradigms to be a good choice for anyone starting out these days.

Well, maybe people feel differently if they are given a formal education starting with C or Java, and can then proceed to view C++ as an improved or more powerful version of what they already knew, but I don't know if that's true.

I will stick with it until I have a solid understanding of `programming in C++` and feel that I'm comfortable using it to start any kind of project. I want to become a programmer and a game dev, so I think having a working knowledge of all the big daddy languages is a must, but I sure do hope I'll be able to code my own games in a more elegant and modern language than this.
« Last Edit: June 12, 2014, 12:13:29 am by Mårran »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: help decrypting error message
« Reply #1 on: June 12, 2014, 12:07:35 am »
Those errors are all in the standard library, so something is wrong with your environment/configuration, rather than your actual code.  Try reinstalling your toolchain.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: help decrypting error message
« Reply #2 on: June 12, 2014, 12:42:41 am »
Those errors are all in the standard library, so something is wrong with your environment/configuration, rather than your actual code.  Try reinstalling your toolchain.

Wouldn't I get the same error from the GitHub code as well if that was the case? I can compile the samples without any problems.

There is only one difference in my code from the samples. I've replaced all the instances of the FOREACH macro with C++11 style for (Type& type : container)
« Last Edit: June 12, 2014, 12:48:52 am by Mårran »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: help decrypting error message
« Reply #3 on: June 12, 2014, 03:59:57 am »
Where did you download the book source code from? If you got it from Packt's website then it is outdated and has issues (since some compilers don't properly implement the standard library as your original post shows).

Try downloading the latest source of the sample code from github and see if that fixes your issue. If that doesn't then something is messed up with your environment/configuration.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: help decrypting error message
« Reply #4 on: June 12, 2014, 06:59:07 am »
Where did you download the book source code from? If you got it from Packt's website then it is outdated and has issues (since some compilers don't properly implement the standard library as your original post shows).

Try downloading the latest source of the sample code from github and see if that fixes your issue. If that doesn't then something is messed up with your environment/configuration.
I was using the github samples.

But I don't understand how I could compile the samples if something were messed up in my environment. That's what lead me to believe that I had made some kind of very subtle mistake that I'm unable to catch by comparing the source from github to my own.

I can compile the the github samples without any problem, but cannot compile my own.

Anyway, I am going to test compiling on another system, and then tell you what happens.

Updated:

I tried compiling my code on another system, and failed with the same errors. I was also able to build the github code on the new system.

Tested on: OpenSuse 13.1, Fedora 20

Any more ideas?
« Last Edit: June 12, 2014, 07:39:00 am by Mårran »

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: help decrypting error message
« Reply #5 on: June 12, 2014, 07:42:16 am »
If anyone is up for it, I can create a repo of my own code, and you can test if it fails on your system as well. Let me know.

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: help decrypting error message
« Reply #6 on: June 12, 2014, 09:53:33 am »
Have you run your code through a difference checker? Like this one.

I'd start with comparing your world.cpp, and the world.cpp on Github.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: help decrypting error message
« Reply #7 on: June 13, 2014, 01:31:46 am »
I found the problem, as I suspected it was a problem with my source, rather than my stl libs.

In world.hpp I had forgot to add an & to the declaration of FontHolder& mFonts.

Now, while there were some small hints in the error message about ResourceHolder and something about sf::Font, it worries me that nowhere did the error point to the line where I had made the mistake.

The reason why this a little annoying to me is that if I didn't have the working source to help me, and this was an error in, say, some code I made myself, then I'm unsure of whether I EVER would have been able to fix it. But I guess that's a problem I will deal with in the future instead of now.

Thank you all for your help.