Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mac OS build instructions #536

Closed
cmahnke opened this issue Sep 18, 2023 · 12 comments
Closed

Update Mac OS build instructions #536

cmahnke opened this issue Sep 18, 2023 · 12 comments

Comments

@cmahnke
Copy link

cmahnke commented Sep 18, 2023

The current instructions to build tilemaker are outdated:

Warning: No available formula with the name "homebrew/core/lua51".

Compiling from source has known issues:

Since those are related, fixing this would close multiple issues, please give it a higher priority.

@systemed
Copy link
Owner

Thanks. I don't use Homebrew on my M2 mini so a PR here would be great.

@FunMiles
Copy link
Contributor

Related but taking another path, the CMakeLists.txt are woefully outdated. I have been able to modernize the CMakeLists and build tilemaker with CMake on my mac. I will try to make a PR for that. The trouble for addressing @cmahnke's problem is that I do a lot of development and thus some packages are already installed on my machine and may be different from his. Having someone try my approach on their machine and helping make sure we write complete correct instructions would be helpful. @cmahnke, would you be willing to help?

@dougkpowers
Copy link

dougkpowers commented Nov 3, 2023

This worked for me on osx Ventura

Start by installing homebrew https://brew.sh/

After homebrew is installed. Install the necessary dependencies. Note that an older version of protobuf is required
brew install brew install protobuf@21 boost lua@5.1 shapelib rapidjson

Clone Tilemaker
git clone https://github.com/systemed/tilemaker

Checkout tag v2.4.0 (this is the version I've verified these instructions against)
git checkout tags/v2.4.0

Update the Makefile (in the tilemaker directory) to include the specific path to protobuf
First, look for this line
protoc --proto_path=include --cpp_out=include $<
and replace it with to add a full path to protoc and specify the include path for protoc include files
/usr/local/opt/protobuf@21/bin/protoc --proto_path=include -I/usr/local/opt/protobuf@21/include --cpp_out=include $<

Second, look for this line
INC := -I$(PLATFORM_PATH)/include -isystem ./include -I./src $(LUA_CFLAGS)
and ensure the protobuf include folder is added. for example:
INC := -I/usr/local/opt/protobuf@21/include -I$(PLATFORM_PATH)/include -isystem ./include -I./src $(LUA_CFLAGS)

Third, look for this line
LIB := -L$(PLATFORM_PATH)/lib -lz $(LUA_LIBS) -lboost_program_options -lsqlite3 -lboost_filesystem -lboost_system -lboost_iostreams -lprotobuf -lshp -pthread
and ensure the protobuf lib folder is added. For example:
LIB := -L/usr/local/opt/protobuf@21/lib -L$(PLATFORM_PATH)/lib -lz $(LUA_LIBS) -lboost_program_options -lsqlite3 -lboost_filesystem -lboost_system -lboost_iostreams -lprotobuf -lshp -pthread

Build Tilemaker using the Makefile
cd ./tilemaker && make

@systemed
Copy link
Owner

systemed commented Nov 3, 2023

I think this should work:

https://github.com/systemed/tilemaker/tree/mac_build

It updates the instructions to use cmake and Lua 5.3. The fixes from #555 are now in trunk (slightly adjusted). I don't use Homebrew (too many bad experiences with it breaking everything) so would be interested to hear from anyone who tries it.

@dougkpowers
Copy link

@systemed I've got the new M3 on order and will try your mac_build branch with a clean install when it arrives.

@systemed
Copy link
Owner

systemed commented Nov 3, 2023

Thank you!

@dougkpowers
Copy link

CMake Error at /opt/homebrew/Cellar/cmake/3.28.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find LuaJIT (missing: LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.28.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindLuaJIT.cmake:57 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:49 (find_package)

@systemed
Copy link
Owner

Oh, that's interesting. It should only be looking for LuaJIT if it couldn't find plain vanilla Lua previously. Had brew install lua@5.3 installed Lua happily?

@dougkpowers
Copy link

dougkpowers commented Dec 10, 2023

The default version of lua is 5.4.6. If we explicitly install 5.3 (which I did), then we also have to explicitly add it to our path.

==> lua@5.3: stable 5.3.6 (bottled) [keg-only]
Powerful, lightweight programming language
https://www.lua.org/
/opt/homebrew/Cellar/lua@5.3/5.3.6 (28 files, 407.2KB)
  Poured from bottle using the formulae.brew.sh API on 2023-12-09 at 20:20:36
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/l/lua@5.3.rb
License: MIT
==> Caveats
You may also want luarocks:
  brew install luarocks

lua@5.3 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have lua@5.3 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/lua@5.3/bin:$PATH"' >> ~/.zshrc

For compilers to find lua@5.3 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/lua@5.3/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/lua@5.3/include"

For pkg-config to find lua@5.3 you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/lua@5.3/lib/pkgconfig"
==> Analytics
install: 292 (30 days), 601 (90 days), 10,636 (365 days)
install-on-request: 282 (30 days), 559 (90 days), 1,101 (365 days)
build-error: 0 (30 days)```

@systemed
Copy link
Owner

systemed commented Dec 10, 2023

Right, got it. Thank you.

I wonder if (for Mac + homebrew) it might be easiest if we just recommend brew install luajit rather than vanilla Lua. LuaJIT is reliable, fast, and homebrew should be capable of installing it properly without additional steps.

@FunMiles
Copy link
Contributor

I have a brand new Mac M3 and tried the instructions on it with cmake. Here are my observations:
First, there is an issue with compiling streamvbyte_arm_decode.c. It attempts to compile it as C++ and restrict is disliked. For now I added #define restrict __restrict to work around it.

brew install luajit will allow the code to compile but it will not link.
Removing luajit and doing brew install lua fixed it.
The current CMakeLists.txt is not looking for luajit but just lua. Did you modify the CMakeLists file, @dougkpowers?

@systemed
Copy link
Owner

v3 now builds and installs fine on an ARM Mac. I need to put my M2 through a deep cleanse after temporarily installing Homebrew to test :|

The manpages don't install because of SIP, but that's not really important because tilemaker --help serves just as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants