Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
509 stars 128 forks source link

Trouble compiling on Ubuntu with Ruby 2.6 #218

Closed Marin-MK closed 2 years ago

Marin-MK commented 5 years ago

I've been following a guide that was posted here (https://docs.google.com/document/d/1xBHq2qccczn1ZcG4uc3DDGHhK0YxfmxI9TNRqjBLzFw/edit) and everything's fine until I try to compile mkxp. I've followed the guide exactly with 2 exceptions: at the start, libpng12-dev I had to change to libpng-dev, and the more relevant change, I got Ruby 2.6 instead of the Ruby 2.2 used in the guide. It could of course be that it's changed so much between 4 minor versions that the guide is no longer applicable, but if it isn't I'd love to know how to fix that.

I built Ruby statically as the guide also did, and I changed MRIVERSION to 2.6 and added /usr/local/lib/libruby-static.a under ${PLATFORM_LIBRARIES} in mkxp's CMakeLists.txt. Here's the log when trying to build it.

marin@MarinPC:~/source/mkxp$ mkdir build && cd build

marin@MarinPC:~/source/mkxp/build$ cmake ..
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'sigc++-2.0'
--   Found sigc++-2.0, version 2.10.0
-- Checking for module 'pixman-1'
--   Found pixman-1, version 0.34.0
-- Checking for module 'physfs>=2.1'
--   Found physfs, version 3.1.0
-- Checking for module 'vorbisfile'
--   Found vorbisfile, version 1.3.5
-- Checking for module 'sdl2'
--   Found sdl2, version 2.0.9
-- Checking for module 'SDL2_ttf'
--   Found SDL2_ttf, version 2.0.15
-- Checking for module 'SDL2_image'
--   Found SDL2_image, version 2.0.4
-- Checking for module 'SDL_sound'
--   Found SDL_sound, version 1.0.1
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   program_options
-- Found OpenAL: /usr/lib/x86_64-linux-gnu/libopenal.so  
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Checking for module 'ruby-2.6'
--   Found ruby-2.6, version 2.6.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marin/source/mkxp/build

marin@MarinPC:~/source/mkxp/build$ make
[  1%] Generating XXD for assets/icon.png
[  2%] Generating XXD for shader/common.h
[  3%] Generating XXD for shader/transSimple.frag
[  4%] Generating XXD for shader/trans.frag
[  5%] Generating XXD for shader/hue.frag
[  6%] Generating XXD for shader/sprite.frag
[  7%] Generating XXD for shader/plane.frag
[  9%] Generating XXD for shader/gray.frag
[ 10%] Generating XXD for shader/bitmapBlit.frag
[ 11%] Generating XXD for shader/flatColor.frag
[ 12%] Generating XXD for shader/simple.frag
[ 13%] Generating XXD for shader/simpleColor.frag
[ 14%] Generating XXD for shader/simpleAlpha.frag
[ 15%] Generating XXD for shader/simpleAlphaUni.frag
[ 17%] Generating XXD for shader/flashMap.frag
[ 18%] Generating XXD for shader/minimal.vert
[ 19%] Generating XXD for shader/simple.vert
[ 20%] Generating XXD for shader/simpleColor.vert
[ 21%] Generating XXD for shader/sprite.vert
[ 22%] Generating XXD for shader/tilemap.vert
[ 23%] Generating XXD for shader/tilemapvx.vert
[ 25%] Generating XXD for shader/blur.frag
[ 26%] Generating XXD for shader/blurH.vert
[ 27%] Generating XXD for shader/blurV.vert
[ 28%] Generating XXD for shader/simpleMatrix.vert
[ 29%] Generating XXD for assets/liberation.ttf
Scanning dependencies of target mkxp
[ 30%] Building CXX object CMakeFiles/mkxp.dir/src/main.cpp.o
[ 31%] Building CXX object CMakeFiles/mkxp.dir/src/audio.cpp.o
[ 32%] Building CXX object CMakeFiles/mkxp.dir/src/bitmap.cpp.o
[ 34%] Building CXX object CMakeFiles/mkxp.dir/src/eventthread.cpp.o
[ 35%] Building CXX object CMakeFiles/mkxp.dir/src/filesystem.cpp.o
[ 36%] Building CXX object CMakeFiles/mkxp.dir/src/font.cpp.o
[ 37%] Building CXX object CMakeFiles/mkxp.dir/src/input.cpp.o
[ 38%] Building CXX object CMakeFiles/mkxp.dir/src/plane.cpp.o
[ 39%] Building CXX object CMakeFiles/mkxp.dir/src/scene.cpp.o
[ 40%] Building CXX object CMakeFiles/mkxp.dir/src/sprite.cpp.o
[ 42%] Building CXX object CMakeFiles/mkxp.dir/src/table.cpp.o
[ 43%] Building CXX object CMakeFiles/mkxp.dir/src/tilequad.cpp.o
[ 44%] Building CXX object CMakeFiles/mkxp.dir/src/viewport.cpp.o
[ 45%] Building CXX object CMakeFiles/mkxp.dir/src/window.cpp.o
[ 46%] Building CXX object CMakeFiles/mkxp.dir/src/texpool.cpp.o
[ 47%] Building CXX object CMakeFiles/mkxp.dir/src/shader.cpp.o
[ 48%] Building CXX object CMakeFiles/mkxp.dir/src/glstate.cpp.o
[ 50%] Building CXX object CMakeFiles/mkxp.dir/src/tilemap.cpp.o
[ 51%] Building CXX object CMakeFiles/mkxp.dir/src/autotiles.cpp.o
[ 52%] Building CXX object CMakeFiles/mkxp.dir/src/graphics.cpp.o
[ 53%] Building CXX object CMakeFiles/mkxp.dir/src/gl-debug.cpp.o
[ 54%] Building CXX object CMakeFiles/mkxp.dir/src/etc.cpp.o
[ 55%] Building CXX object CMakeFiles/mkxp.dir/src/config.cpp.o
[ 56%] Building CXX object CMakeFiles/mkxp.dir/src/settingsmenu.cpp.o
[ 57%] Building CXX object CMakeFiles/mkxp.dir/src/keybindings.cpp.o
[ 59%] Building CXX object CMakeFiles/mkxp.dir/src/tileatlas.cpp.o
[ 60%] Building CXX object CMakeFiles/mkxp.dir/src/sharedstate.cpp.o
[ 61%] Building CXX object CMakeFiles/mkxp.dir/src/gl-fun.cpp.o
[ 62%] Building CXX object CMakeFiles/mkxp.dir/src/gl-meta.cpp.o
[ 63%] Building CXX object CMakeFiles/mkxp.dir/src/vertex.cpp.o
[ 64%] Building CXX object CMakeFiles/mkxp.dir/src/soundemitter.cpp.o
[ 65%] Building CXX object CMakeFiles/mkxp.dir/src/sdlsoundsource.cpp.o
[ 67%] Building CXX object CMakeFiles/mkxp.dir/src/alstream.cpp.o
[ 68%] Building CXX object CMakeFiles/mkxp.dir/src/audiostream.cpp.o
[ 69%] Building CXX object CMakeFiles/mkxp.dir/src/rgssad.cpp.o
[ 70%] Building CXX object CMakeFiles/mkxp.dir/src/bundledfont.cpp.o
[ 71%] Building CXX object CMakeFiles/mkxp.dir/src/vorbissource.cpp.o
[ 72%] Building CXX object CMakeFiles/mkxp.dir/src/windowvx.cpp.o
[ 73%] Building CXX object CMakeFiles/mkxp.dir/src/tilemapvx.cpp.o
[ 75%] Building CXX object CMakeFiles/mkxp.dir/src/tileatlasvx.cpp.o
[ 76%] Building CXX object CMakeFiles/mkxp.dir/src/autotilesvx.cpp.o
[ 77%] Building CXX object CMakeFiles/mkxp.dir/src/midisource.cpp.o
[ 78%] Building CXX object CMakeFiles/mkxp.dir/src/fluid-fun.cpp.o
[ 79%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/binding-mri.cpp.o
[ 80%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/binding-util.cpp.o
[ 81%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/table-binding.cpp.o
[ 82%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/etc-binding.cpp.o
[ 84%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/bitmap-binding.cpp.o
[ 85%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/font-binding.cpp.o
[ 86%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/graphics-binding.cpp.o
[ 87%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/input-binding.cpp.o
[ 88%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/sprite-binding.cpp.o
[ 89%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/viewport-binding.cpp.o
[ 90%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/plane-binding.cpp.o
[ 92%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/window-binding.cpp.o
[ 93%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/tilemap-binding.cpp.o
[ 94%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/audio-binding.cpp.o
[ 95%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/module_rpg.cpp.o
[ 96%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/filesystem-binding.cpp.o
[ 97%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/windowvx-binding.cpp.o
[ 98%] Building CXX object CMakeFiles/mkxp.dir/binding-mri/tilemapvx-binding.cpp.o
[100%] Linking CXX executable mkxp.bin.x86_64
/usr/bin/ld: /usr/local/lib/libruby-static.a(mjit.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/mkxp.dir/build.make:1766: recipe for target 'mkxp.bin.x86_64' failed
make[2]: *** [mkxp.bin.x86_64] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mkxp.dir/all' failed
make[1]: *** [CMakeFiles/mkxp.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
carstene1ns commented 5 years ago

General question is why do you link ruby statically and not dynamically like the rest? This way you either need to build ruby without dlopen capability, or add -ldl to the linker.

Marin-MK commented 5 years ago

I'm completely in the dark without a guide, and the guide author says he had trouble with doing it dynamically. Since I don't even know how that works, I'm just following the guide I linked.

Could you either tell me where I should add -ldl to the linker, or how to build Ruby dynamically (and how to then include it mkxp or whatever)? Thanks for you help.

carstene1ns commented 5 years ago

For a quick fix, you can add it like you added the static ruby library (just add another line with -ldl in CMakeLists.txt after it). Also, can you upload your CMakeCache.txt? Just drag/drop it into the editor field here, it will be uploaded.

Marin-MK commented 5 years ago

CMakeCache.txt

Marin-MK commented 5 years ago

I'm now getting a different error:

/usr/bin/ld: /usr/local/lib/libruby-static.a(thread.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/mkxp.dir/build.make:1766: recipe for target 'mkxp.bin.x86_64' failed
make[2]: *** [mkxp.bin.x86_64] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mkxp.dir/all' failed
make[1]: *** [CMakeFiles/mkxp.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

New CMakeCache: CMakeCache.txt

Bottom of my CMakeLists.txt:

target_link_libraries(${PROJECT_NAME}
    ${SIGCXX_LIBRARIES}
    ${SDL2_LIBRARIES}
    ${SDL2_IMAGE_LIBRARIES}
    ${SDL2_TTF_LIBRARIES}
    ${SDL_SOUND_LIBRARIES}
    ${PHYSFS_LIBRARIES}
    ${PIXMAN_LIBRARIES}
    ${Boost_LIBRARIES}
    ${MRI_LIBRARIES}
    ${VORBISFILE_LIBRARIES}
    ${FLUID_LIBRARIES}
    ${OPENAL_LIBRARY}
    ${ZLIB_LIBRARY}

    ${PLATFORM_LIBRARIES}
    /usr/local/lib/libruby-static.a
    -ldl
)

PostBuildMacBundle(${PROJECT_NAME} "" "${PLATFORM_COPY_LIBS}")
Ancurio commented 5 years ago

Looks like the MRI pkg-config file needs to be updated with -ldl and -lpthread?

2019年3月3日(日) 21:34 Marin notifications@github.com:

I'm now getting a different error:

/usr/bin/ld: /usr/local/lib/libruby-static.a(thread.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12' //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/mkxp.dir/build.make:1766: recipe for target 'mkxp.bin.x86_64' failed make[2]: [mkxp.bin.x86_64] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mkxp.dir/all' failed make[1]: [CMakeFiles/mkxp.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Ancurio/mkxp/issues/218#issuecomment-469061348, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHpPkJxS9QfTxFQ4NcpSjN7_H4zhI9tks5vTDHdgaJpZM4bbMV4 .

carstene1ns commented 5 years ago

Well this does only matter, because of manually adding the static library. The pkg-config file has them included.

Marin-MK commented 5 years ago

Added -lpthread underneath -ldl and it raises yet another error.

/usr/bin/ld: /usr/local/lib/libruby-static.a(thread.o): undefined reference to symbol 'timer_settime@@GLIBC_2.3.3'
//lib/x86_64-linux-gnu/librt.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/mkxp.dir/build.make:1766: recipe for target 'mkxp.bin.x86_64' failed
make[2]: *** [mkxp.bin.x86_64] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mkxp.dir/all' failed
make[1]: *** [CMakeFiles/mkxp.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I clearly don't know what I'm doing anymore, so could someone explain how to dynamically link Ruby instead of statically? And then any differences with compiling mkxp with ruby statically and dynamically. That'd be very much appreciated.

Ancurio commented 5 years ago

@Marin-MK The manpages tell me timer_settime requires -lrt. You could alternatively try using the dependency kit as described in the Readme, if you're just trying to hack on mkxp.

TomTheDragon commented 5 years ago

I basicly tried the same thing as @Marin-MK but i only could get it to work with Ruby v2.2.x - v2.5.x (i tried v2.1.x, v2.2.x, v2.3.x, v2.4.x, v2.5.x and v2.6.x) But even then, i still encountered a strange problem, as you can see here --> https://github.com/Ancurio/mkxp/issues/217 If i finally get it to work, i plan on making something like a docker container, which should make compiling much easier.

Marin-MK commented 5 years ago

@Marin-MK The manpages tell me timer_settime requires -lrt. You could alternatively try using the dependency kit as described in the Readme, if you're just trying to hack on mkxp.

My main goal is to slightly alter mkxp's source code. For that I wanted to use the hack at first, but I couldn't get it to work either. That's why I tried compiling it from source.

Having added -lrt, -lgmp, and -lcrypt, it's now fully compiled and it looks like it works perfectly!

Only thing is that it keeps asking me how to run the file as you can see. I did check the "Allow to execute this file" checkbox in Permissions, and I also tried via the command line with sudo chmod +x ./mkxpa.x86_64. Any idea how I can get rid of that?

Ancurio commented 5 years ago

Any idea how I can get rid of that?

No clue; seems like it's related to the executable bit. You can check with ls -l if it's properly set.

My main goal is to slightly alter mkxp's source code.

That's precisely why I made the depkit for..

Marin-MK commented 5 years ago

Using ls -l returns: -rwxr-xr-x 1 marin marin 22788256 9 20:39 mkxp.x86_64

The prebuilt mkxp.amd64 and mkxp.x86 both have -rwxrwx---.

Notable is also that the file type is "Unknown" as opposed to "Program", and that it doesn't have a thumbnail in the file explorer.

sorlok commented 2 years ago

I realize it's been forever, but thanks to @Marin-MK for tracking this down and debugging it. I've updated the guide with your notes.