Issue compiling c++ source

405 Views Asked by At

I have a problem compiling a C++ program and I tried to find the issue and solve it but currently I wasn't able to find the source of the problem. I will appreciate if someone give me a hand :)

The error given is: (compiling under Centos 6.3 with gcc 4.4.7)

In file included from /home/server/Sources/MOP/MistCore/src/server/scripts/PrecompiledHeaders/ScriptPCH.h:25,
                 from /home/server/Sources/MOP/MistCore/src/server/game/Anticheat/AnticheatMgr.h:7,
                 from /home/server/Sources/MOP/MistCore/src/server/game/Anticheat/AnticheatData.h:4,
                 from /home/server/Sources/MOP/MistCore/src/server/game/Anticheat/AnticheatData.cpp:1:
/home/server/Sources/MOP/MistCore/src/server/game/Spells/SpellScript.h: In constructor ‘AuraScript::AuraScript()’:
/home/server/Sources/MOP/MistCore/src/server/game/Spells/SpellScript.h:619: error: no matching function for call to ‘std::shared_ptr<Aura>::shared_ptr(NULL)’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/shared_ptr.h:1263: note: candidates are: std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Tp>&&) [with _Tp = Aura]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/shared_ptr.h:1238: note:                 std::shared_ptr<_Tp>::shared_ptr() [with _Tp = Aura]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/shared_ptr.h:1236: note:                 std::shared_ptr<Aura>::shared_ptr(const std::shared_ptr<Aura>&)
make[2]: *** [src/server/game/CMakeFiles/game.dir/Anticheat/AnticheatData.cpp.o] Error 1
make[1]: *** [src/server/game/CMakeFiles/game.dir/all] Error 2
make: *** [all] Error 2

Files:

Yeah, it's a long piece of code.

2

There are 2 best solutions below

0
On

You can specifi the flag using -std=c++11

2
On

According to this site, std::shared_ptr was introduced in C++11.

Compiling C++11 with GCC requires it's version 4.7 or later.

Note that MistCore is based on the TrinityCore, that instead of using a C++11 specific define named AuraPtr uses a simple Aura* pointer. Reverting this to the original state should work just as it used to in the original project.

You can simply edit /src/server/game/SharedPtrs/SharedPtrs.h and undo the need of std::shared_ptr by replacing the defines with simple pointers. No guarantee that it will solve all problems though. Exemple.