DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.88k stars 478 forks source link

isoworld on Linux doesn't seem to compile against (external) Agui due to linking errors #961

Open TC01 opened 8 years ago

TC01 commented 8 years ago

I've been attempting to get isoworld to build against system libraries, and have run into some difficulty. I was able to fix the first two issues, but now I appear to be stuck.

First off, for Linux, isoworld redefines and accepts the -DSTONESENSE_INTERNAL_SO argument instead of -DISOWORLD_INTERNAL_SO, which meant that I didn't even realize I was telling isoworld to build against external libraries. I think this should be ISOWORLD_INTERNAL_SO for consistency with the Apple section (which uses the variable ISOWORLD_INTERNAL_DYLIB).

Once I realized that was the problem, I found that I needed to install Agui-- there is a bundled copy of Agui, but it doesn't seem like the cmake configuration for isoworld attempts to do anything with it non-Windows platforms, unless I am horribly confused. With ISOWORLD_INTERNAL_SO set and without Agui installed, my build was failing with the error that Agui/Agui.hpp couldn't be found.

So, I built the last release of Agui from source and installed it. I then added "agui" and "agui_allegro5" to PROJECT_LIBS and attempted to build again. I then was able to get all the way through the build, but linking failed with the following notes:

CMakeFiles/isoworld.dir/UserInterface.cpp.o: In function `MainScreen::MainScreen(agui::Gui*)':
UserInterface.cpp:(.text+0x20f): undefined reference to `agui::Button::setText(std::string const&)'
UserInterface.cpp:(.text+0x2bf): undefined reference to `agui::Button::setText(std::string const&)'
UserInterface.cpp:(.text+0x371): undefined reference to `agui::Button::setText(std::string const&)'
UserInterface.cpp:(.text+0x423): undefined reference to `agui::Widget::setText(std::string const&)'
CMakeFiles/isoworld.dir/UserInterface.cpp.o: In function `MainScreen::UpdateText()':
UserInterface.cpp:(.text+0x668): undefined reference to `agui::Button::setText(std::string const&)'
UserInterface.cpp:(.text+0x6c5): undefined reference to `agui::Button::setText(std::string const&)'
UserInterface.cpp:(.text+0x753): undefined reference to `agui::Button::setText(std::string const&)'
UserInterface.cpp:(.text+0x7b3): undefined reference to `agui::Button::setText(std::string const&)'
CMakeFiles/isoworld.dir/UserInterface.cpp.o: In function `initializeAgui()':
UserInterface.cpp:(.text+0x9fc): undefined reference to `agui::Font::load(std::string const&, int, agui::FontFlags, float, agui::Color)'
CMakeFiles/isoworld.dir/UserInterface.cpp.o: In function `MainScreen::UpdateTilesetList(MapSection*)':
UserInterface.cpp:(.text+0xc9c): undefined reference to `agui::DropDown::addItem(std::string const&)'
collect2: error: ld returned 1 exit status

I thought perhaps that some of these symbols changed upstream, but that does not seem to be the case. Button::setText, for example, looks the same to me.

Any ideas? This is on Fedora 23, using gcc 5.3.1; I'm at a bit of a loss on how to proceed further.

lethosor commented 8 years ago

It could be a version mismatch - what external version of Agui are you using?

TC01 commented 8 years ago

I tried the latest (and only one tagged on github, anyway) stable release, 0.2.1, and also the latest commit. I'm not sure if versions are tracked anywhere else; presumably there were previous releases but I'm not sure where to find them.

TC01 commented 8 years ago

Hm, I tested with this commit, which is from March 2013. Agui was added to the isoworld tree in April 2013, it appears, so... this is probably the right version, I would think. It still doesn't work though.

This (zipped) patch is what I've done so far, source below, if anyone wants to try and reproduce this.

diff -rupN dfhack/plugins/isoworld/CMakeLists.txt dfhack-fork/plugins/isoworld/CMakeLists.txt
--- dfhack/plugins/isoworld/CMakeLists.txt      2016-07-07 16:43:07.000000000 -0400
+++ dfhack-fork/plugins/isoworld/CMakeLists.txt 2016-07-12 22:04:41.787097086 -0400
@@ -56,8 +56,8 @@ IF(UNIX)
                ENDIF()
        ELSE(APPLE)
        #linux
-               OPTION(STONESENSE_INTERNAL_SO "Link with prebuilt internal allegro libs and headers." ON)
-               IF(STONESENSE_INTERNAL_SO)
+               OPTION(ISOWORLD_INTERNAL_SO "Link with prebuilt internal allegro libs and headers." ON)
+               IF(ISOWORLD_INTERNAL_SO)
                        FILE(DOWNLOAD http://dethware.org/dfhack/download/allegro509b.tar.bz2
                                                  ${CMAKE_CURRENT_SOURCE_DIR}/allegro509b.tar.bz2
                                                  EXPECTED_MD5 74ead5d95a83a03a301cdc76fa0a3df8)
@@ -90,6 +90,8 @@ IF(UNIX)
                                allegro_dialog
                                allegro_image
                                allegro_ttf
+                               agui
+                               agui_allegro5
                                ${PROJECT_LIBS}
                        )
                ENDIF()
lethosor commented 8 years ago

@JapaMala, any ideas?

RosaryMala commented 8 years ago

I have no idea, really.

lethosor commented 8 years ago

Hm. How up-to-date is isoworld, anyway? I don't remember ever actually building it (although isoworldremote is a default plugin, so I've built that successfully).

@TC01, what's the current state of that patch? Does it still fail to link the same symbols? Does Agui match the architecture you're building for?

RosaryMala commented 8 years ago

I relatively recently fixed loading maps with the new naming scheme, but I never even committed the changes, so no, it hasn't been updated in a very long time.

TC01 commented 8 years ago

@lethosor

Still having the same issues with the above patch (now using Fedora 24 though). I just verified that everything fails when I have 32-bit Agui installed in a 32-bit chroot.

I had to provide another patch for isoworld (probably due to a newer gcc / set of default compiler flags) to ensure was included in a file (otherwise the compiler couldn't resolve the "sqrt" symbol) to get as far as the above linking failure at all though.

diff -rupN dfhack/plugins/isoworld/DetailedTile.cpp dfhack-fork/plugins/isoworld/DetailedTile.cpp
--- dfhack/plugins/isoworld/DetailedTile.cpp    2016-09-25 22:58:38.603797808 -0400
+++ dfhack-fork/plugins/isoworld/DetailedTile.cpp       2016-09-25 22:59:13.050852941 -0400
@@ -4,6 +4,7 @@
 #include "UserConfig.h"
 #include "ColorList.h"
 #include "TileSet.h"
+#include <cmath>
 #include <sstream>

 using namespace isoworldremote;
@@ -468,4 +469,4 @@ void load_detailed_tiles(ALLEGRO_PATH *
     }
     al_destroy_fs_entry(base_folder);
     al_destroy_path(tile_path);
-}
\ No newline at end of file
+}
BenLubar commented 4 years ago

I've fixed some of this in https://github.com/DFHack/isoworld/compare/fbbf9e46458e41707c27f2a4438452a579490db1...c2dad13d97dd9f5959e8761ac8a399f820f401b6, but I stopped because isoworld contains a precompiled 32-bit version of allegro and therefore won't link on 64-bit linux.

TC01 commented 4 years ago

I think I had deleted the prebuilt allegro and was trying to link against the system one-- but it's been a while, so I'm not entirely sure.