Statically linked Minetest executable?

Beerholder
Member
 
Posts: 33
Joined: Wed Aug 03, 2016 20:23
In-game: Beerholder

Statically linked Minetest executable?

by Beerholder » Sat Feb 11, 2017 13:56

Hi all, I am trying to compile a statically linked minetestserver to see if I can deploy it on a platform where I do not have much control over what is and what is not installed. FYI the platform is OpenShift and I was thinking of creating a minetest cartridge, possibly with another cartridge running redis. Anyways, platform aside, rather than satisfying all dependencies manually (uploading the .so's and putting them somewhere the dynamic linker can find them), I thought I'd give it a try to compile and statically link the executable on a local Ubuntu VM first.

Some of the things I did and found out sofar:
  • I am compiling on a local Ubuntu VM under my control so that I could apt-get all the dependencies, compile and then upload the statically linked executable to the cartridge
  • Statically linking *everything* causes a segfault on startup, not even a --version works. Stack trace points to it immediately crashing at pthread get_id. Some googling points out libpthread has issues when statically linked
  • I will therefore try to link most common libraries (things like stdc++, pthread, etc.) dynamically, the less common ones (hiredis, cURL, irrlicht, etc.) statically
  • To do this I will probably need to tinker with the ld arguments and pass something like -Wl,-Bdynamic -lpthread -letc. -Wl,-Bstatic to the linker
  • I found some stuff on StackOverflow talking about passing/ setting CMAKE_FIND_LIBRARY_SUFFIXES to ".a" and setting CMAKE_EXE_LINKER_FLAGS to something like "-static-libblabla -static-libetcetc" for CMake, which will probably then result in the correct arguments being passed to ld
Before I venture any further and possibly spending a lot of time fiddling around, I thought I'd ask around here first: Has anyone tried this before or would anyone have some idea what flags I could pass to CMake/ how to update the CMakeFiles.txt to control the static/ dynamic linking? (I must admit that I am not familiar with CMake, and my C/ C++ programming is a bit rusty these days -_-) Oh, and are there maybe other things that might not behave well when statically linked?

Thanks!
 

Beerholder
Member
 
Posts: 33
Joined: Wed Aug 03, 2016 20:23
In-game: Beerholder

Re: Statically linked Minetest executable?

by Beerholder » Sun Feb 12, 2017 14:00

Actually I am digging through the CMakeLists and I just realized the WIN32 build copies the dll's to the bin directory using install(FILES ${SOME_DLL} DESTINATION ${BINDIR}), so I might actually also want to try if I can do to copy the .so's to the bin dir using something like install(FILES ${SOME_LIBRARY} DESTINATION ${BINDIR}) so that I can tarball everything and deploy them in the cartridge. And then keep my fingers crossed hoping there are no other unresolved dependencies XD
 


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 1 guest

cron