DEV Community

Discussion on: Writing Super Mario Bros in C++

Collapse
 
sswam profile image
Sam Watkins • Edited

Thanks for sharing, it's interesting to read about the entity component system method. Your game is very playable and feels the same as the original as far as I can tell.

FYI, I had to make these minor changes to get it to build on Linux. There's a case-sensitivity issue with SDL_ttf, and I had to list some extra secondary libraries on target_link_libraries. I don't know why that latter was necessary, and I suppose that there is a better way to do it.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d987ba..6511ffb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,5 +26,5 @@ set_property(TARGET smb PROPERTY CXX_STANDARD 17)
 set_target_properties(smb PROPERTIES OUTPUT_NAME smb-${CMAKE_BUILD_TYPE})
 target_include_directories(smb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
 target_include_directories(smb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
-target_link_libraries(smb PRIVATE ${SDL2_MIXER_LIBRARY} ${SDL2} ${SDL2_IMAGE} ${SDL2_TTF})
+target_link_libraries(smb PRIVATE ${SDL2_MIXER_LIBRARY} ${SDL2} ${SDL2_IMAGE} ${SDL2_TTF} jpeg png tiff webp freetype harfbuzz)

diff --git a/cmake/FindSDL2_ttf.cmake b/cmake/FindSDL2_ttf.cmake
index 7caf028..fea142e 100644
--- a/cmake/FindSDL2_ttf.cmake
+++ b/cmake/FindSDL2_ttf.cmake
@@ -1,5 +1,5 @@
 # Find path to the include (header) files #########
-find_path(SDL2_TTF_INCLUDE_DIR SDL_TTF.h PATH_SUFFIXES SDL2 include/SDL2 include)
+find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h PATH_SUFFIXES SDL2 include/SDL2 include)
 set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})

 # Find path to the library (static) ###############
@@ -15,7 +15,7 @@ endif ()
 list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/bzip2/bin/")


-find_library(SDL2_TTF_LIBRARY NAMES SDL2_TTF PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX})
+find_library(SDL2_TTF_LIBRARY NAMES SDL2_ttf PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX})

 # SDL2_TTF intrinsic dependencies
 find_library(FREETYPE freetype PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX})
Enter fullscreen mode Exit fullscreen mode
Collapse
 
feresr profile image
Raviola

Thanks for reading Sam! glad you could make it work!

"It works in my machine"™ - I barely understand how cmake works.
I'll add those dependencies in for the next person who wants to give it atry.

ps: there's a WASM version now: feresr.github.io/smb/smb-.html