slajerek / RetroDebugger

Retro Debugger is a multiplatform debugger APIs host for retro computers: C64 (Vice), Atari800 and NES (NestopiaUE).
189 stars 23 forks source link

Clean build fails due to linking errors (undefined reference to ...) #29

Closed cellux closed 7 months ago

cellux commented 9 months ago

Describe the bug

If the executable is built from scratch via CMake, the build fails at the linking step due to lots of undefined reference errors.

To Reproduce

With MTEngineSDL checked out and built in a sibling directory:

mkdir -p build
cd build
cmake ..
make

Expected behavior

Builds artifact without errors.

Desktop (please complete the following information):

OS: Arch Linux Version: latest Git HEAD (0.64.66)

Additional context

I could fix the build by applying the following patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 827dd91..a651337 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1246,8 +1246,8 @@ add_executable(retrodebugger
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugSymbolsSegment.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugAsmSource.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugSymbols.cpp"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugMemoryMapCell.cpp"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugMemoryMap.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugMemory.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/Symbols/CDebugMemoryCell.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/C64/CDebugInterfaceC64.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/C64/CDiskImageD64.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/MenuItems/CDebugInterfaceMenuItem.cpp"
@@ -1256,13 +1256,18 @@ add_executable(retrodebugger
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/CDebugDataAdapter.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/CDebuggerEmulatorPlugin.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/CDebugInterface.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/DebugInterface/CDebugEventsHistory.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Screens/CViewC64.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Screens/CViewMainMenu.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewMemoryMap.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewEmulationState.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewEmulationCounters.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewFileBrowser.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewDataDump.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewDataMonitor.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewDataPlot.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewDataWatch.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewDebugEventsHistory.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewMonitorConsole.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewDisassembly.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/CViewSourceCode.cpp"
@@ -1338,11 +1343,12 @@ add_executable(retrodebugger
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64ColorRamScreen.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64StateSID.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64Disassembly.cpp"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewDrive1541FileD64.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64SidTrackerHistory.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewDrive1541StateCPU.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewDrive1541StateVIA.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewDrive1541Led.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewDrive1541Browser.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewDrive1541DiskData.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64StateVIC.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64SidPianoKeyboard.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Views/C64/CViewC64EmulationCounters.cpp"
@@ -1410,6 +1416,7 @@ add_executable(retrodebugger
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/libpsid64/libpsid-reloc65.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/libpsid64/libpsid-theme.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/libpsid64/libpsid-screen.cpp"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/C64SIDDump.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/C64SIDFrequencies.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/CGuiLockableList.cpp"

@@ -1430,7 +1437,7 @@ target_link_libraries(retrodebugger
     gobject-2.0
     gio-2.0
     dbus-1
-    /usr/lib/x86_64-linux-gnu/libsndio.so
+    sndio
     dl
     m
     pthread
slajerek commented 9 months ago

That looks awesome, thank you. I'll add this patch to CMakeLists.txt

On Sat, Feb 24, 2024 at 8:10 PM Ruzsa Balázs @.***> wrote:

Assigned #29 https://github.com/slajerek/RetroDebugger/issues/29 to @slajerek https://github.com/slajerek.

— Reply to this email directly, view it on GitHub https://github.com/slajerek/RetroDebugger/issues/29#event-11911400816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZOVY3CGBRDE2SNX3HTNDYVI3KRAVCNFSM6AAAAABDYG6VT6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRHEYTCNBQGA4DCNQ . You are receiving this because you were assigned.Message ID: @.***>

-- Marcin Skoczylas

slajerek commented 9 months ago

They finally added sndio to libraries recognised by CMake, nice :)

On Sun, Feb 25, 2024 at 3:41 AM Marcin Skoczylas @.***> wrote:

That looks awesome, thank you. I'll add this patch to CMakeLists.txt

On Sat, Feb 24, 2024 at 8:10 PM Ruzsa Balázs @.***> wrote:

Assigned #29 https://github.com/slajerek/RetroDebugger/issues/29 to @slajerek https://github.com/slajerek.

— Reply to this email directly, view it on GitHub https://github.com/slajerek/RetroDebugger/issues/29#event-11911400816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZOVY3CGBRDE2SNX3HTNDYVI3KRAVCNFSM6AAAAABDYG6VT6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRHEYTCNBQGA4DCNQ . You are receiving this because you were assigned.Message ID: @.***>

-- Marcin Skoczylas

-- Marcin Skoczylas

slajerek commented 9 months ago

I've updated this. The error was due a bad copy from my other repo, I forgot to copy the CMakeLists.txt. Please let me know if that works for you now (the patch is actually almost identical as yours).

cellux commented 9 months ago

RetroDebugger seems fine now, but MTEngineSDL broke, probably due to the enforcing of C++ 17?:

/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x5f9): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: /home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x77b): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: /home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x7dd): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_int() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x959): undefined reference to `internalJSONNode::operator long() const'
/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0xc22): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_int() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x16e2): undefined reference to `internalJSONNode::operator long() const'
/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x170c): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: /home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x1865): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_int() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x1c20): undefined reference to `internalJSONNode::operator long() const'
/usr/bin/ld: /home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x1c89): undefined reference to `internalJSONNode::operator long() const'
/usr/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x1d67): undefined reference to `internalJSONNode::operator double() const'
/usr/bin/ld: /home/rb/aur/retro-debugger-git/src/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x1ebb): undefined reference to `internalJSONNode::operator double() const'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/retrodebugger.dir/build.make:3034: retrodebugger] Error 1
make[1]: *** [CMakeFiles/Makefile2:198: CMakeFiles/retrodebugger.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
slajerek commented 9 months ago

Hmm, that's interesting. I'll check what happens now. I think I had this error before and applied a fix. Maybe when I set to support C++20. MTEngineSDL uses C++17 for quite long time already. This comes from libjson library that I wanted to drop support anyway as I switched to hjson already :)

mrdudz commented 8 months ago

I just tried to build from scratch and it complains about missing libsndio:

[100%] Linking CXX executable retrodebugger
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsndio: Datei oder Verzeichnis nicht gefunden
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsndio: Datei oder Verzeichnis nicht gefunden
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[2]: *** [CMakeFiles/retrodebugger.dir/build.make:3033: retrodebugger] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:198: CMakeFiles/retrodebugger.dir/all] Fehler 2
make: *** [Makefile:91: all] Fehler 2

after installing libsndio:

[ 85%] Linking CXX executable retrodebugger
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x5f9): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x77b): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x7dd): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_int() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x959): undefined reference to `internalJSONNode::operator long() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0xc22): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_int() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x16e2): undefined reference to `internalJSONNode::operator long() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x170c): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x1865): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_int() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x1c20): undefined reference to `internalJSONNode::operator long() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:671:(.text+0x1c89): undefined reference to `internalJSONNode::operator long() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/retrodebugger.dir/src/Views/JukeboxPlaylist/CJukeboxPlaylist.cpp.o: in function `JSONNode::as_float() const':
/home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x1d67): undefined reference to `internalJSONNode::operator double() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/groepaz/Desktop/c64stuff/retrodebugger/RetroDebugger/../MTEngineSDL/src/Engine/Libs/libjson/_internal/Source/JSONNode.h:676:(.text+0x1ebb): undefined reference to `internalJSONNode::operator double() const'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[2]: *** [CMakeFiles/retrodebugger.dir/build.make:3033: retrodebugger] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:198: CMakeFiles/retrodebugger.dir/all] Fehler 2
make: *** [Makefile:91: all] Fehler 2
slajerek commented 7 months ago

I've updated CMakeLists, and this compiles for me on my Debian. Please check.

mrdudz commented 7 months ago

Now it links :) Is there a way to increase the font size in the various windows? its so tiny, i cant use it (not the UI font, the one used for memory dumps etc)

edit: nvm, found it :)

slajerek commented 7 months ago

Thanks.

cellux commented 7 months ago

FYI: I managed to build current master branch without issues on Arch Linux, so I can confirm that your changes fixed the build.