spoutn1k/mcmap

MacOS Installation?

celina opened this issue · 16 comments

Are there installation instructions for MacOS?

I've installed homebrew, libpng (via brew), and gcc (via brew), but I'm not sure how to configure the Makefile.

Hey,

Sure ! On my test machine, the actual GNU compiler was installed as g++-10, and did not link with the brew-created files in /usr/local. I pushed to a new branch the changes that worked for me: please tell me if that works for you.

I pulled the new branch, but I'm having trouble getting the command to even run. I get an error that says permission denied: ./mcmap when I try to use the example command from the readme (adjusted to my own values). I'm using MacOS 10.15.6 Catalina.

This is the command I used as a test:

./mcmap -from 50 -50 -to 80 -80 /Users/myuser/Library/Application\ Support/minecraft/saves/example_save

Am I formatting it correctly?

Permission denied ? That's a first.

Please provide the output of ls -alh ./mcmap and make realClean && make && echo $?. What version of macOS are you compiling on ?

Also the options are almost perfect, except the coordinates are swapped, as the minZ coordinate is greater than the maxZ. The bounding area should look like -from 50 -80 -to 80 -50.

I'm using MacOS 10.15.6 Catalina.

My output:

$ ./mcmap -from 50 -80 -to 80 -50 /Users/myuser/Library/Application\ Support/minecraft/saves/example_save

zsh: permission denied: ./mcmap


$ ls -alh ./mcmap
total 120
drwxr-xr-x  15 celina  staff   480B Aug 17 20:37 .
drwxr-xr-x@ 25 celina  staff   800B Aug 17 19:46 ..
-rw-r--r--   1 celina  staff   3.8K Aug 17 19:46 .clang-format
-rw-r--r--   1 celina  staff   219B Aug 17 19:46 .format-ignore
drwxr-xr-x  12 celina  staff   384B Aug 17 19:46 .git
drwxr-xr-x   3 celina  staff    96B Aug 17 19:46 .github
-rw-r--r--   1 celina  staff    94B Aug 17 19:46 .gitignore
-rw-r--r--   1 celina  staff    34K Aug 17 19:46 LICENSE
-rw-r--r--   1 celina  staff   1.3K Aug 17 19:46 Makefile
-rw-r--r--   1 celina  staff   6.9K Aug 17 19:46 README.md
drwxr-xr-x   3 celina  staff    96B Aug 17 19:46 assets
drwxr-xr-x   2 celina  staff    64B Aug 17 20:37 build
drwxr-xr-x   3 celina  staff    96B Aug 17 19:46 contrib
drwxr-xr-x   9 celina  staff   288B Aug 17 20:10 scripts
drwxr-xr-x  21 celina  staff   672B Aug 17 19:46 src


$ make realClean && make && echo $?
make: *** No rule to make target `realClean'.  Stop.

Oh that makes sense !

To use make you have to be in the same directory as a Makefile file. As you are not in the mcmap directory, executing ./mcmap executes the folder, and not the generated executable, thus the permission denied error.

The fix is simple. Enter the directory using cd mcmap, then compile using make realClean && make. A new executable, called mcmap, should appear in there. Use this generated file when calling ./mcmap. It is confusing as both the repertory and executable are called mcmap, but hopefully this will get the program working.

I ran the make realClean && make command from the mcmap folder but there are errors.

$ cd mcmap

$ make realClean && make
find src -name *o -exec rm {} \;
/Library/Developer/CommandLineTools/usr/bin/make -C scripts clean
find . -name '*o' -exec rm -fr {} \;
rm -fr mcmap output.png src/colors.bson
/Library/Developer/CommandLineTools/usr/bin/make -C scripts realClean
find . -name '*o' -exec rm -fr {} \;
rm -fr json2bson nbt2json regionReader extractChunk
/Library/Developer/CommandLineTools/usr/bin/make -C scripts json2bson
g++ -O3 -c -std=c++17 -Wall -I../src/include -g json2bson.cpp -o json2bson.default.o
g++ -O3 -c -std=c++17 -Wall -I../src/include -g ../src/include/fmt/format.cpp -o ../src/include/fmt/format.default.o
g++ json2bson.default.o ../src/include/fmt/format.default.o -lstdc++fs -o json2bson
ld: library not found for -lstdc++fs
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [json2bson] Error 1
make[1]: *** [src/colors.bson] Error 2
make: *** [all] Error 2

That is more like the errors I was expecting. Try removing the -lstdc++fs from Makefile and scripts/Makefile.

I've removed -lstdc++fs from the two Makefiles and now my output after running make realClean && make results in an error for clang: error: unsupported option '-fopenmp'.

Full output included below:

$ make realClean && make
find src -name *o -exec rm {} \;
/Library/Developer/CommandLineTools/usr/bin/make -C scripts clean
find . -name '*o' -exec rm -fr {} \;
rm -fr mcmap output.png src/colors.bson
/Library/Developer/CommandLineTools/usr/bin/make -C scripts realClean
find . -name '*o' -exec rm -fr {} \;
rm -fr json2bson nbt2json regionReader extractChunk
/Library/Developer/CommandLineTools/usr/bin/make -C scripts json2bson
g++ -O3 -c -std=c++17 -Wall -I../src/include -g json2bson.cpp -o json2bson.default.o
g++ -O3 -c -std=c++17 -Wall -I../src/include -g ../src/include/fmt/format.cpp -o ../src/include/fmt/format.default.o
g++ json2bson.default.o ../src/include/fmt/format.default.o  -o json2bson
./scripts/json2bson src/colors.json > src/colors.bson
g++ -O3 -std=c++17 -c -Wall -fomit-frame-pointer -pedantic -DWITHPNG -D_FILE_OFFSET_BITS=64 -fopenmp -Isrc/include src/canvas.cpp -o src/canvas.default.o
clang: error: unsupported option '-fopenmp'
make[1]: *** [src/canvas.default.o] Error 1
make: *** [all] Error 2

Interesting, are you on the macOS branch ? The output shows that g++ is used, when I specify g++-10 in the Makefiles of the macOS branch. Please include the output of git branch.

In any case, you can take that off, and the threaded support will be dropped without breaking much else. This is a flag to use openMP, supported by the GNU compilers, but not the ones shipping by default on macOS.

Well that's my bad, I thought I had grabbed the right branch but I must have still be on default. I switched to the macOS branch and went through the steps we discussed previously.

The output from running make realClean && make is attached as a .txt file.

mcmap-macOS-output-20200818-2226.txt

Looking online, this smells like a macOS incompatibility on the compiler's end, not mine. I experimented on an older macOS version, so I'm going blind; but I'll try to make it work for you.

Another project had the same build issues, and this is the commit that fixed it. So all I can advise for now is:

  • Install libomp via brew for openMP. Apparently it has to be installed, if that fixes it great, if not it can't hurt.
  • Install GNU's gcc version 9 using brew install gcc@9, and replace g++-10 by g++-9 in the Makefiles. Apparently gcc 9 had a patch for that very issue.

I am sorry for not having a real solution, but if everything fails, I'll prepare a cross-platform executable and put it on github. Let me know how it went.

Yeah, it's definitely looking like a macOS and gcc issue. I tried your suggestions but I still get the same errors.
Thank you for trying!

I'd love to give a cross-platform executable a try in the future.

Attached to this comment is an executable compiled on macOS 10.14 with -static. It looks like it still loads dynamic libraries, but hopefully it will work for you, if the libraries are at the same locations.
mcmap.zip

The executable works! This is such a fun little tool. Having maps for my old worlds is going to make it so much easier to organize and reference my old builds. Thank you again!

I'm glad we worked it out ! I'll try to find a way to distribute binaries then, once I feel the tool is stable enough. Enjoy !

Can you try compiling with the new macOS branch ? I found a way to compile in an macOS Catalina VM, you need to enable the fixes by running OS=MACOS make.

I did some ugly commit rewriting, so you might wanna git commit reset --hard HEAD~5 && git pull.