Mechanized Assault & eXploration Reloaded



#1 Jul 09, 2019 7:16 pm
MickeyKnox Offline
Mitglied
Registered since: Nov 08, 2010
Posts: 11


Subject: Linker error during compilation
I was trying to compile maxr on my mac. Everything compiled fine until the linking stage:

$ make
[ 1%] Linking CXX executable maxr
Undefined symbols for architecture x86_64:
"std::runtime_error::what() const", referenced from:
cSavegame::loadSaveInfo(int) in savegame.cpp.o
cMenuControllerMultiplayerHost::startSavedGame() in menucontrollermultiplayerhost.cpp.o
cWindowSinglePlayer::loadGameClicked()::{lambda(cS
aveGameInfo const&)#1}::operator()(cSaveGameInfo const&) const in windowsingleplayer.cpp.o
...
tinyxml2::DynArray<tinyxml2::MemPoolT<104>::Block*, 10>::EnsureCapacity(int) in tinyxml2.cpp.o
tinyxml2::DynArray<tinyxml2::MemPoolT<72>::Block*, 10>::EnsureCapacity(int) in tinyxml2.cpp.o
"___dynamic_cast", referenced from:
cMouseCursorAmount::equal(cMouseCursor const&) const in mousecursoramount.cpp.o
cMouseCursorAttack::equal(cMouseCursor const&) const in mousecursorattack.cpp.o
cMouseCursorSimple::equal(cMouseCursor const&) const in mousecursorsimple.cpp.o
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in connectionmanager.cpp.o
Dwarf Exception Unwind Info (__eh_frame) in dedicatedserver.cpp.o
Dwarf Exception Unwind Info (__eh_frame) in drawingcache.cpp.o
Dwarf Exception Unwind Info (__eh_frame) in eventmanager.cpp.o
Dwarf Exception Unwind Info (__eh_frame) in extendedtinyxml.cpp.o
Dwarf Exception Unwind Info (__eh_frame) in base.cpp.o
Dwarf Exception Unwind Info (__eh_frame) in gamesettings.cpp.o
...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [maxr] Error 1
make[1]: *** [CMakeFiles/maxr.dir/all] Error 2
make: *** [all] Error 2

I'm using gcc-9:

$ gcc-9 -v
Using built-in specs.
COLLECT_GCC=gcc-9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.1.0/libexec/gcc/x86_64-apple-darwin18/9.1.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with: ../configure --build=x86_64-apple-darwin18 --prefix=/usr/local/Cellar/gcc/9.1.0 --libdir=/usr/local/Cellar/gcc/9.1.0/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.1.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Thread model: posix
gcc version 9.1.0 (Homebrew GCC 9.1.0)

Why is this happening? What can I do about it?
↑  ↓

#2 Jul 14, 2019 8:15 pm
Sal Sal Offline
, G-Mod
Registered since: Jun 07, 2004
Posts: 1,524


Subject: Re: Linker error during compilation
Hey, I asked in the discord channel for you
(here https://discord.gg/4QzcnzG )

Alzi said, it looks like you are building without Exception handling/RTTI
It could be its missing compile flags

If you could
'make clean' and
'make VERBOSE=1'

and post the complete log here, we could know more.

Cheers =)

and thanks to alzi :*
A.H.
- easy logic -
↑  ↓

#3 Jul 20, 2019 1:45 am
MickeyKnox Offline
Mitglied
Registered since: Nov 08, 2010
Posts: 11


Subject: Re: Linker error during compilation
Thanks for the invite, I've joined discord now.

I think the problem is that I tried to compile with GNU gcc and then link with Apples linker. That doesn't seem to work.
If you think that should work I will try again with VERBOSE=1 and post here.

I've been trying something different in the meantime: use Apples gcc. It simply seems to be more picky about forward declarations
with non-pointer variables. I could solve a few issues with just an #include, but in the case of chatcommand and chatcommandparser they
need each other. So I was thinking about refactoring that a little. I run make with -k and this seems to be the only issue left.
↑  ↓

#4 Feb 02, 2020 9:50 pm
MickeyKnox Offline
Mitglied
Registered since: Nov 08, 2010
Posts: 11


Subject: Re: Linker error during compilation
Sorry for the delay, but her is the output:

$ make VERBOSE=1
/usr/local/Cellar/cmake/3.15.5/bin/cmake -S/Users/ingmar/src/maxr -B/Users/ingmar/src/maxr/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_progress_start /Users/ingmar/src/maxr/build/CMakeFiles /Users/ingmar/src/maxr/build/CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/maxr.dir/build.make CMakeFiles/maxr.dir/depend
cd /Users/ingmar/src/maxr/build && /usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_depends "Unix Makefiles" /Users/ingmar/src/maxr /Users/ingmar/src/maxr /Users/ingmar/src/maxr/build /Users/ingmar/src/maxr/build /Users/ingmar/src/maxr/build/CMakeFiles/maxr.dir/DependInfo.cmake --color=
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/maxr.dir/build.make CMakeFiles/maxr.dir/build
[ 1%] Building CXX object CMakeFiles/maxr.dir/src/ui/graphical/game/control/chatcommand/chatcommand.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++ -DHAVE_AUTOVERSION_H -I/Users/ingmar/src/maxr/src -I/Users/ingmar/src/maxr/build -I/usr/local/include/SDL2 -std=c++1y -stdlib=libc++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -o CMakeFiles/maxr.dir/src/ui/graphical/game/control/chatcommand/chatcommand.cpp.o -c /Users/ingmar/src/maxr/src/ui/graphical/game/control/chatcommand/chatcommand.cpp
In file included from /Users/ingmar/src/maxr/src/ui/graphical/game/control/chatcommand/chatcommand.cpp:20:
/Users/ingmar/src/maxr/src/ui/graphical/game/control/chatcommand/chatcommand.h:67:41: error: implicit instantiation of
undefined template 'cChatCommandParser<>'
return cChatCommandParser<NewArgument>(cChatCommandParser<>(std::move(*this)), NewArgument(std::forward<...
^
/Users/ingmar/src/maxr/src/ui/graphical/game/control/chatcommand/chatcommand.h:27:7: note: template is declared here
class cChatCommandParser;
^
/Users/ingmar/src/maxr/src/ui/graphical/game/control/chatcommand/chatcommand.h:74:76: error: implicit instantiation of
undefined template 'cChatCommandParser<>'
return std::make_unique<cChatCommandExecutorImpl<F>>(std::move(function), cChatCommandParser<>(std::move...
^
/Users/ingmar/src/maxr/src/ui/graphical/game/control/chatcommand/chatcommand.h:27:7: note: template is declared here
class cChatCommandParser;
^
2 errors generated.
make[2]: *** [CMakeFiles/maxr.dir/src/ui/graphical/game/control/chatcommand/chatcommand.cpp.o] Error 1
make[1]: *** [CMakeFiles/maxr.dir/all] Error 2
make: *** [all] Error 2

This is not gcc-9 anymore, but Apples gcc.
This post has been edited 1 times. Last edit on Feb 02, 2020 10:07 pm by MickeyKnox. ↑  ↓

#5 Feb 04, 2020 6:45 pm
MickeyKnox Offline
Mitglied
Registered since: Nov 08, 2010
Posts: 11


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"
↑  ↓

#6 Feb 04, 2020 9:48 pm
Sal Sal Offline
, G-Mod
Registered since: Jun 07, 2004
Posts: 1,524


Subject: Re: Linker error during compilation
Wow, glad it worked! Maybe this could be implemented in maxr src code as a template.

Thanks for posting, this also can help other people.

Cheers!
Sal
A.H.
- easy logic -
↑  ↓

#7 Feb 10, 2020 7:17 pm
MickeyKnox Offline
Mitglied
Registered since: Nov 08, 2010
Posts: 11


Subject: Re: Linker error during compilation
I think I've celebrated too soon. Recently I've startet a multiplayer game in my local network with two players. The other player was on Ubuntu with the latest nightly build. Everything seemed to be working nicely until I hit the End Turn button. The game crashed immediately with the following error:

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: XML_ERROR_FILE_COULD_NOT_BE_OPENED /Users/ingmar/.maxr/saves/Save010.xml
Abort trap: 6


I've checked, there is no Save010.xml, neither is there a saves folder in .maxr. However, these files aren't present on the Ubuntu machine either, where the game did not crash.

Could this be happening due to my changes? Or is there another problem?
This post has been edited 1 times. Last edit on Feb 10, 2020 7:18 pm by MickeyKnox. ↑  ↓

#8 Feb 13, 2020 10:00 am
beko beko Offline
Developer, Administrator
Registered since: Jun 04, 2004
Posts: 2,279


Subject: Re: Linker error during compilation
As sorted out on the Discord: Current develop has a bug. The save folder has to be created manually. There's a pending PR to fix the issue.
Bernd Kosmahl
"Sir, we are surrounded!" - "Great - we can attack in any direction."
↑  ↓

Pages (1): 1


All times are GMT +01:00. Current time: 11:55 am.