PotreeConverter icon indicating copy to clipboard operation
PotreeConverter copied to clipboard

Issues building in macOS

Open gosukiwi opened this issue 3 years ago • 25 comments

Hi guys. I tried following the instructions in the README. I made a new ./build folder, cd into it, ran cmake ../ but it raised an error:

CMake Error at CMakeLists.txt:54 (find_package):
  By not providing "FindTBB.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "TBB", but
  CMake did not find one.

I fixed it by running brew install tbb. But then, when I run make, I get:

Scanning dependencies of target laszip
[  3%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/arithmeticdecoder.cpp.o
[  6%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/arithmeticencoder.cpp.o
[ 10%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/arithmeticmodel.cpp.o
[ 13%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/integercompressor.cpp.o
[ 16%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasindex.cpp.o
[ 20%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasinterval.cpp.o
[ 23%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasquadtree.cpp.o
[ 26%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasreaditemcompressed_v1.cpp.o
[ 30%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasreaditemcompressed_v2.cpp.o
[ 33%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasreaditemcompressed_v3.cpp.o
[ 36%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasreaditemcompressed_v4.cpp.o
[ 40%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasreadpoint.cpp.o
[ 43%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/lasunzipper.cpp.o
[ 46%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laswriteitemcompressed_v1.cpp.o
[ 50%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laswriteitemcompressed_v2.cpp.o
[ 53%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laswriteitemcompressed_v3.cpp.o
[ 56%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laswriteitemcompressed_v4.cpp.o
[ 60%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laswritepoint.cpp.o
[ 63%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laszip.cpp.o
[ 66%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laszip_dll.cpp.o
[ 70%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/laszipper.cpp.o
[ 73%] Building CXX object Converter/libs/laszip/CMakeFiles/laszip.dir/src/mydefs.cpp.o
[ 76%] Linking CXX shared library ../../../liblaszip.dylib
[ 76%] Built target laszip
Scanning dependencies of target PotreeConverter
[ 80%] Building CXX object CMakeFiles/PotreeConverter.dir/Converter/src/chunker_countsort_laszip.cpp.o
In file included from /Users/gosukiwi/Beezwax/PotreeConverter/Converter/src/chunker_countsort_laszip.cpp:10:
In file included from /Users/gosukiwi/Beezwax/PotreeConverter/./Converter/include/chunker_countsort_laszip.h:8:
In file included from /Users/gosukiwi/Beezwax/PotreeConverter/./Converter/include/Attributes.h:10:
/Users/gosukiwi/Beezwax/PotreeConverter/./Converter/modules/unsuck/unsuck.hpp:418:3: error: use of undeclared identifier 'fseek_64_all_platforms'
                fseek_64_all_platforms(file, start, SEEK_SET);
                ^
/Users/gosukiwi/Beezwax/PotreeConverter/./Converter/modules/unsuck/unsuck.hpp:427:3: error: use of undeclared identifier 'fseek_64_all_platforms'
                fseek_64_all_platforms(file, start, SEEK_SET);
                ^
/Users/gosukiwi/Beezwax/PotreeConverter/./Converter/modules/unsuck/unsuck.hpp:445:3: error: use of undeclared identifier 'fseek_64_all_platforms'
                fseek_64_all_platforms(file, start, SEEK_SET);
                ^
/Users/gosukiwi/Beezwax/PotreeConverter/./Converter/modules/unsuck/unsuck.hpp:449:3: error: use of undeclared identifier 'fseek_64_all_platforms'
                fseek_64_all_platforms(file, start, SEEK_SET);
                ^
In file included from /Users/gosukiwi/Beezwax/PotreeConverter/Converter/src/chunker_countsort_laszip.cpp:22:
/Users/gosukiwi/Beezwax/PotreeConverter/./Converter/include/PotreeConverter.h:4:10: fatal error: 'execution' file not found
#include <execution>
         ^~~~~~~~~~~
5 errors generated.
make[2]: *** [CMakeFiles/PotreeConverter.dir/Converter/src/chunker_countsort_laszip.cpp.o] Error 1
make[1]: *** [CMakeFiles/PotreeConverter.dir/all] Error 2
make: *** [all] Error 2

Does this converter work in macOS or only Linux/Windows? Or maybe it's just me messing things up :)

gosukiwi avatar Sep 04 '20 16:09 gosukiwi

Hi,

The problem is that this file only implements functionality for linux and windows: https://github.com/potree/PotreeConverter/blob/develop/Converter/modules/unsuck/unsuck_platform_specific.cpp

This file queries available and free RAM, as well as number of CPU cores/threads and usage. Some of that info is necessary to know how many threads to spawn or when to stop loading new data. Since I don't have mac os, I didn't implement it yet.

potree avatar Sep 04 '20 17:09 potree

The file also links to a stackoverflow post that describes how to query RAM and CPU data on linux and windows. If you find a way to do that on mac, just try appending #elif defined( MAC? ) section at the bottom. Let me know if you find something that works.

potree avatar Sep 04 '20 17:09 potree

The trivial way to get it to work would be to add an else section and hardcode the memory and CPU data, if needed.

potree avatar Sep 04 '20 17:09 potree

Ah and you also need to add a mac define for fseek here, which is actually the part that throws the error: https://github.com/potree/PotreeConverter/blob/develop/Converter/modules/unsuck/unsuck.hpp#L42

potree avatar Sep 04 '20 17:09 potree

I see, thanks. I have no issue using Linux/Windows in the meantime. Just making sure if macOS was supported so I can use my regular development environment.

Thanks for the quick reply :)

Unfortunately I have very limited knowledge of C++ so I really can't help with that.

gosukiwi avatar Sep 04 '20 17:09 gosukiwi

The file also links to a stackoverflow post that describes how to query RAM and CPU data on linux and windows. If you find a way to do that on mac, just try appending #elif defined( MAC? ) section at the bottom. Let me know if you find something that works.

hi, maybe this repo can help? https://github.com/thewtex/tmux-mem-cpu-load, it says it support Mac OSX.

funshine avatar Jan 03 '21 13:01 funshine

I can't really help either since I never coded in C++, but is there any chance to get this fixed? 😅

brudi4550 avatar Apr 21 '22 11:04 brudi4550

I wouldn't trust this too much as my c++ skills is questionable at best, but I got it to compile on my machine.

Here is the modified source. https://github.com/LeftOfHere/PotreeConverter

Just converted an 12 GB .las file, so seems to work fine. The RAM and CPU reporting just doesn't seem to work.

LeftOfHere avatar Apr 22 '22 15:04 LeftOfHere

I wouldn't trust this too much as my c++ skills is questionable at best, but I got it to compile on my machine.

Here is the modified source. https://github.com/LeftOfHere/PotreeConverter

Just converted an 12 GB .las file, so seems to work fine. The RAM and CPU reporting just doesn't seem to work.

Thanks so much! Just tried it out, works like a charm.

brudi4550 avatar Apr 22 '22 19:04 brudi4550

@LeftOfHere thanks. Homebrew contributor could probably clean this up for us in 30 seconds. Did you guys build on intel or apple silicon?

rromanchuk avatar May 14 '22 08:05 rromanchuk

@rromanchuk It was built on M1 mac pro max or whatever the thing is called., but most of the code samples I found/used referenced intel macs, so should work on both. I have some time today/tomorrow, and will clean the code a bit and make a PR for scrutiny.

LeftOfHere avatar May 14 '22 09:05 LeftOfHere

Yup, it worked fine (intel iMac Pro). Chomping through about 20G just fine.

On Sat, May 14, 2022 at 02:13 LeftOfHere @.***> wrote:

@rromanchuk https://github.com/rromanchuk It was built on M1 mac pro max or whatever the thing is called., but most of the code samples I found/used referenced intel macs, so should work on both. I have some time today/tomorrow, and will clean the code a bit and make a PR for scrutiny.

— Reply to this email directly, view it on GitHub https://github.com/potree/PotreeConverter/issues/444#issuecomment-1126677199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAY6LCXZS7HCOZPSEVDAD3VJ5VE7ANCNFSM4QY5ID5A . You are receiving this because you were mentioned.Message ID: @.***>

rromanchuk avatar May 14 '22 09:05 rromanchuk

Made a PR.

If @potree or someone can have a look and comment that would be great.

LeftOfHere avatar May 16 '22 06:05 LeftOfHere

@LeftOfHere I tried your solution with Mac M1 and 1.7PRE but I'm getting multiple errors like this: /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/exception:99:29: note: 'exception' declared here class _LIBCPP_EXCEPTION_ABI exception

Any chance you can help me figure it out?

FrancoCorleone avatar Jul 07 '22 21:07 FrancoCorleone

@FrancoCorleone Hi. was a bit busy. I will have a look this week. Just a couple of questions. I assume the issues come from building this branch leftofhere:develop

What is 1.7PRE?

Also, can you give more lines of the exception. That line just says an exception was thrown. The previous or next lines should be what caused it.

LeftOfHere avatar Jul 17 '22 21:07 LeftOfHere

Hey, 1.7PRE is a version of Potree we're currently using for a project. You can have a look into tags. I tried to build it on my Mac, but you know how it is with gcc dependencies... whatever I did I always ended up with a missing library problem. I don't know if it's worth a hassle tbh

FrancoCorleone avatar Jul 17 '22 21:07 FrancoCorleone

Ah. I only updated the latest dev, PotreeConverter 2.x.

I'll have a look. It should be easy enough to port the changes, but will happen closer to the weekend.

It's basically removing the parellel code as macs clang doesn't include it and adding a mac specific resource logging, which can just be faked to make it easier.

LeftOfHere avatar Jul 19 '22 10:07 LeftOfHere

Any solution to this? Has any branch got it working on Mac?

pviejo avatar Oct 17 '22 12:10 pviejo

https://github.com/LeftOfHere/PotreeConverter

This branch should work on mac. latest dev. Only for potree convert 2.X. Not older versions. Haven't had the time to fix older versions, but we aren't using it anymore, so don't know if I ever will.

LeftOfHere avatar Oct 17 '22 18:10 LeftOfHere

Thank you kind stranger! Your repo works like a charm 💙 @LeftOfHere

sladg avatar Feb 16 '23 21:02 sladg

@LeftOfHere How do you build a macOS portable binaries with your fork ?

I try command explain in readme but the cmake build result is not portable (there are symlink).

ketourneau avatar Oct 06 '23 09:10 ketourneau

@ketourneau You'll have to check with someone with more knowledge about cmake for that. Pretty sure you can just add some post build command in the cmake file to copy the file to replace the links. There are only 6 of them, all in one folder, and they are referencing files in the folder (Converter/libs/brotli).

add_custom_command( TARGET PotreeConverter POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy build/Converter/libs/brotli/libbrotlicommon.1.0.9.dylib build/Converter/libs/brotli/libbrotlicommon.1.dylib)

Something like this. Again, I have very close to 0 experience with cmake, but maybe this works.

LeftOfHere avatar Oct 10 '23 07:10 LeftOfHere

@LeftOfHere Ok thank you for your answer ! It seems good !

We got another error with "liblaszip.dylib" when we try to use build folder on another mac :

dyld[16103]: Library not loaded: @rpath/liblaszip.dylib Referenced from: <45A61BF5-ACD3-3FE1-9C4C-E94F1D8913FC> /Users/.../Downloads/build2/PotreeConverter Reason: tried: '/Users/.../Git/PotreeConverter/build/liblaszip.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/.../Git/PotreeConverter/build/liblaszip.dylib' (no such file), '/Users/.../Git/PotreeConverter/build/liblaszip.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/.../Git/PotreeConverter/build/liblaszip.dylib' (no such file)

Maybe it missing cmake config ?

ketourneau avatar Oct 18 '23 08:10 ketourneau

We find a solution by modifying library linking after build :

install_name_tool -change @rpath/liblaszip.dylib @executable_path/liblaszip.dylib PotreeConverter

We can now use PotreeConverter on another mac.

ketourneau avatar Oct 18 '23 11:10 ketourneau

I wouldn't trust this too much as my c++ skills is questionable at best, but I got it to compile on my machine.

Here is the modified source. https://github.com/LeftOfHere/PotreeConverter

Just converted an 12 GB .las file, so seems to work fine. The RAM and CPU reporting just doesn't seem to work.

Just work fine on my MacBook with M2 Pro under Sonoma 14.2.1! Thanks ;-)

xaliphostes avatar Jan 27 '24 11:01 xaliphostes