[6.x] Cant compile under Ubuntu
Ubuntu 14.04.2 LTS GCC - gcc (Ubuntu 4.8.4-2ubuntu1~14.04)
Rev. https://github.com/TrinityCore/TrinityCore/commit/6ace6aabbff91ebc487f43276d5b1861968c59db
Boost - 1.55 MySQL - Ver 14.14 Distrib 5.5.46, for debian-linux-gnu (x86_64) using readline 6.3 OpenSSL - OpenSSL 1.0.1f 6 Jan 2014 ZeroMQ - version: 2.2.0+dfsg-5
/home/wod_623/TrinityCore/src/server/game/Texts/CreatureTextMgr.cpp: In member function ‘uint32 CreatureTextMgr::SendChat(Creature_, uint8, const WorldObject_, ChatMsg, Language, CreatureTextRange, uint32, Team, bool, Player_)’:
/home/wod_623/TrinityCore/src/server/game/Texts/CreatureTextMgr.cpp:237:6: error: no matching function for call to ‘SelectRandomWeightedContainerElement(CreatureTextGroup&, CreatureTextMgr::SendChat(Creature_, uint8, const WorldObject_, ChatMsg, Language, CreatureTextRange, uint32, Team, bool, Player_)::lambda4)’
});
^
/home/wod_623/TrinityCore/src/server/game/Texts/CreatureTextMgr.cpp:237:6: note: candidates are:
In file included from /home/wod_623/TrinityCore/src/server/game/AI/CoreAI/UnitAI.h:24:0,
from /home/wod_623/TrinityCore/src/server/game/AI/CreatureAI.h:23,
from /home/wod_623/TrinityCore/src/server/game/Grids/Notifiers/GridNotifiers.h:33,
from /home/wod_623/TrinityCore/src/server/game/Texts/CreatureTextMgr.cpp:24:
/home/wod_623/TrinityCore/src/common/Utilities/Containers.h:82:36: note: template
make[1]: *** [src/server/game/CMakeFiles/game.dir/all] Error 2 make: *** [all] Error 2
with this commit https://github.com/TrinityCore/TrinityCore/commit/41d6460c75ce094e8ade92c88b603231aaa8e8a5 compile broke, I guess something was missed .
Strange, travis uses gcc 4.8 and compiles fine.
I'm on ubuntu 14.04.3 , and gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
same problem... (followed trinitycore.info guide (apt-get install freshly)
[ 15%] Building CXX object src/server/game/CMakeFiles/game.dir/Texts/CreatureTextMgr.cpp.o /home/.../.../src/server/game/Texts/CreatureTextMgr.cpp: In member function 'uint32 CreatureTextMgr::SendChat(Creature_, uint8, const WorldObject_, ChatMsg, Language, CreatureTextRange, uint32, Team, bool, Player_)': /home/.../.../src/server/game/Texts/CreatureTextMgr.cpp:237:6: error: no matching function for call to 'SelectRandomWeightedContainerElement(CreatureTextGroup&, CreatureTextMgr::SendChat(Creature_, uint8, const WorldObject_, ChatMsg, Language, CreatureTextRange, uint32, Team, bool, Player_)::__lambda4)' }); ^ compilation terminated due to -Wfatal-errors. make[2]: *** [src/server/game/CMakeFiles/game.dir/Texts/CreatureTextMgr.cpp.o] Error 1 make[1]: *** [src/server/game/CMakeFiles/game.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... Linking CXX shared module libScriptPCH.cpp_dephelp.so [ 15%] Built target ScriptPCH.cpp_dephelp [ 15%] Built target generate_bnetPCH.cpp [ 15%] Built target generate_worldPCH.cpp make: *** [all] Error 2
Cannot reproduce on a fully updated ubuntu 14.04.3 LTS.
@Shauren any idea? I re-installed Ubuntu 14.04, followed exactly 1:1 trinitycore.info - but CreatureTextMgr.cpp making some problems. And btw, I saw a commit where you improved random creature texts. Maybe there is something missing?
And now? 00c878e73a8c6b8ce3339d224ab5611df3bbd07c
Hi! nop :/ . I try compiling upgrading ubuntu, to kernel 3.16.0-57-generic,
- make clean
- make -j 4 but still happens:
/home/wow/TrinityCore/src/server/game/Texts/CreatureTextMgr.cpp: In member function ‘uint32 CreatureTextMgr::SendChat(Creature_, uint8, const WorldObject_, ChatMsg, Language, CreatureTextRange, uint32, Team, bool, Player_)’: /home/wow/TrinityCore/src/server/game/Texts/CreatureTextMgr.cpp:237:6: error: no matching function for call to ‘SelectRandomWeightedContainerElement(CreatureTextGroup&, CreatureTextMgr::SendChat(Creature_, uint8, const WorldObject_, ChatMsg, Language, CreatureTextRange, uint32, Team, bool, Player_)::__lambda4)’ }); ^ compilation terminated due to -Wfatal-errors. make[2]: *** [src/server/game/CMakeFiles/game.dir/Texts/CreatureTextMgr.cpp.o] Error 1
I will test it later, I'm not home currently.
apparently it didnt fix the problem @Shauren

What about this?
diff --git a/src/common/Utilities/Containers.h b/src/common/Utilities/Containers.h
index 13e5dc5..7e08f24 100644
--- a/src/common/Utilities/Containers.h
+++ b/src/common/Utilities/Containers.h
@@ -96,8 +96,8 @@ namespace Trinity
*
* Note: container cannot be empty
*/
- template <class C>
- typename C::const_iterator SelectRandomWeightedContainerElement(C const& container, std::function<double(typename C::value_type const&)> const& weightExtractor)
+ template <class C, class F>
+ typename C::const_iterator SelectRandomWeightedContainerElement(C const& container, F weightExtractor)
{
std::vector<double> weights;
weights.reserve(container.size());
It has the advantage of not forcing a conversion to std::function. The downside is that F is not expressed in terms of C or double however it will still error if std::transform is fed something that doesn't make sense.
Acceptable but as you said the reason std::function was used was to inform the programmer about return type/arguments
Does it Work? I can test if you Wish
Yes, test it please.
Hi Using @DDuarte patch works fine
It looks good, he dont show error anymore. I will wait till he finished for a final feedback. Thanks (obrigado) @DDuarte