Subject: Re: Linker error during compilation
Finally I've got maxr working on my mac.
A few changes to the sourcecode were necessary. Apples gcc seems to be more picky then GNUs gcc. Two small changes:
#include "game/data/player/playerbasicdata.h" in game/data/model.h
and
#include <string> in network.h
Finally I've moved the template definitions in chatcommand.h to a new file chatcommand.tpp and included that in ui/graphical/game/control/gameguicontroller.cpp. This seems to be the only place where the templates are used.
Although I've tested the final result and the game seems to be working, I have no idea what chatcommand is actually doing and therefore could not test if it's still working correctly.
This is the full patch of all my changes:
diff --git a/src/game/data/model.h b/src/game/data/model.h
index 2470cdb3..5f10523a 100644
--- a/src/game/data/model.h
+++ b/src/game/data/model.h
@@ -37,6 +37,7 @@
#include "game/logic/attackjob.h"
#include "game/logic/jobs/jobcontainer.h"
#include "game/logic/casualtiestracker.h"
+#include "game/data/player/playerbasicdata.h"
class cPlayerBasicData;
class cGameSettings;
diff --git a/src/network.h b/src/network.h
index 04f1476f..9423d7a5 100644
--- a/src/network.h
+++ b/src/network.h
@@ -21,6 +21,7 @@
#include <vector>
#include <SDL_net.h>
+#include <string>
#include "utility/thread/mutex.h"
diff --git a/src/ui/graphical/game/control/chatcommand/chatcommand.h b/src/ui/graphical/game/control/chatcommand/chatcommand.h
index 0f49a268..3c3d1342 100644
--- a/src/ui/graphical/game/control/chatcommand/chatcommand.h
+++ b/src/ui/graphical/game/control/chatcommand/chatcommand.h
@@ -60,18 +60,4 @@ private:
bool isServerOnly;
};
-//--------------------------------------------------
----------------------------
-template<typename NewArgument, typename... Args>
-cChatCommandParser<NewArgument> cChatCommand::addArgument(Args&&... args)
-{
- return cChatCommandParser<NewArgument>(cChatCommandParser<>(std::move(*this)), NewArgument(std::forward<Args>(args)...));
-}
-
-//--------------------------------------------------
----------------------------
-template<typename F>
-std::unique_ptr<cChatCommandExecutor> cChatCommand::setAction(F function)
-{
- return std::make_unique<cChatCommandExecutorImpl<F>>(std::move(function), cChatCommandParser<>(std::move(*this)));
-}
-
#endif // ui_graphical_game_control_chatcommand_chatcommandH
diff --git a/src/ui/graphical/game/control/chatcommand/chatcommand.tpp b/src/ui/graphical/game/control/chatcommand/chatcommand.tpp
new file mode 100644
index 00000000..2415eee8
--- /dev/null
+++ b/src/ui/graphical/game/control/chatcommand/chatcommand.tpp
@@ -0,0 +1,13 @@
+#include "ui/graphical/game/control/chatcommand/chatcommandparser.h"
+
+template<typename NewArgument, typename... Args>
+cChatCommandParser<NewArgument> cChatCommand::addArgument(Args&&... args)
+{
+ return cChatCommandParser<NewArgument>(cChatCommandParser<>(std::move(*this)), NewArgument(std::forward<Args>(args)...));
+}
+
+template<typename F>
+std::unique_ptr<cChatCommandExecutor> cChatCommand::setAction(F function)
+{
+ return std::make_unique<cChatCommandExecutorImpl<F>>(std::move(function), cChatCommandParser<>(std::move(*this)));
+}
diff --git a/src/ui/graphical/game/control/gameguicontroller.cpp b/src/ui/graphical/game/control/gameguicontroller.cpp
index a6e29cfe..3cb50714 100644
--- a/src/ui/graphical/game/control/gameguicontroller.cpp
+++ b/src/ui/graphical/game/control/gameguicontroller.cpp
@@ -22,6 +22,7 @@
#include "ui/graphical/game/control/gameguicontroller.h"
#include "ui/graphical/game/control/chatcommand/chatcommand.h"
+#include "ui/graphical/game/control/chatcommand/chatcommand.tpp"
#include "ui/graphical/game/control/chatcommand/chatcommandexecutor.h"
#include "ui/graphical/game/control/chatcommand/chatcommandparser.h"
#include "ui/graphical/game/control/chatcommand/chatcommandarguments.h"