Portage to OS X

All about Linux portage
mankoff
Posts: 26
Joined: Sat Oct 29, 2011 8:12 pm

Portage to OS X

Post by mankoff »

This is a great tool. Thank you for developing it and making it open source. I have used it with success on Windows, but I run Windows in VirtualBox on OS X and would like a native version. Can you help with OS X compilation? In my experience it does not have to be terribly different than Linux compilation. I've installed all the dependencies (not many! wonderful!) via 'brew' which puts them in /usr/local/

Currently I checked out the SVN source, run `qmake` in the CloudCompare directory which creates a makefile, and then I type "make". I get the following errors:

Code: Select all

CloudCompare $ make
g++ -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.7.4/mkspecs/macx-g++ -I. -I/usr/local/Cellar/qt/4.7.4/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.7.4/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.7.4/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.7.4/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.7.4/include -I. -IPCV -ICC/include -IqCC/msvc -IqCC/plugins/qPoissonRecon/PoissonRecon/Src -IqCC -IqCC/db_tree -IqCC/db -IqCC/fileIO -IqCC/db/msvc -IqCC/libs/CCFbo -IqCC/plugins -ICC/qhull/src -ICC/triangle -ICC/src -ICC/test -IqCC/ccViewer -IqCC/libs/qxt -IqCC/plugins/qBlur -IqCC/plugins/qDummyPlugin -IqCC/plugins/qEDL -IqCC/plugins/qHPR -IqCC/plugins/qKinect -IqCC/plugins/qKinect/libfreenect/include -IqCC/plugins/qPCV -IqCC/plugins/qPoissonRecon -IqCC/plugins/qRANSAC_SD -IqCC/plugins/qRANSAC_SD/RANSAC_SD_orig -IqCC/plugins/qRANSAC_SD/RANSAC_SD_orig/MiscLib -IqCC/plugins/qRANSAC_SD/RANSAC_SD_orig/GfxTL -IqCC/plugins/qSSAO -IqCC/plugins/qSSAO/Randomkit -I. -I. -F/usr/local/Cellar/qt/4.7.4/lib -o FloatIlluminationTools.o PCV/FloatIlluminationTools.cpp
In file included from CC/include/CCMiscTools.h:33,
                 from CC/include/DgmOctree.h:44,
                 from PCV/IlluminationStructures.h:28,
                 from PCV/FloatIlluminationTools.h:29,
                 from PCV/FloatIlluminationTools.cpp:25:
qCC/msvc/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
stdint.h (which is spewing the error) is included from CCMiscTools.h at this point:

Code: Select all

#if !defined(_WIN32) && !defined(WIN32) && defined(__GNUC__)
#include <stdint.h>
#define __int64 int64_t
#endif
It seems from the Makefile that _WIN32 and WIN32 are not defined and __GNUC__ is defined. Those definitions seem appropriate for OS X, but why is this causing an error?

If I comment out the #error directive in stdint.h it does not help, although the errors are slightly different.

Any help will be much appreciated.

Thanks,

-k.
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Portage to OS X

Post by daniel »

Hello,

For the first error, it appears that qmake has automatically included the folder where we have put a "stdint.h" file (qCC/msvc). I don't remember why right now, but I guess it must have something to do with the non official MS Visual project of CloudCompare. You should definitely remove it or prevent qmake from including it (I'm not very familiar with qmake).There's a default "stdint.h" file on Linux/OS X systems instead.

In fact, to avoid such errors, you shouldn't use qmake but Code::Blocks (binaries are provided for Mac OS X 10.4+) and follow the instructions that are in the trunk folder. Is there a particular reason why you didn't used Code::Blocks in the first place?
mankoff
Posts: 26
Joined: Sat Oct 29, 2011 8:12 pm

Re: Portage to OS X

Post by mankoff »

I didn't use Code::Blocks because I had never heard of it and it looked like some Perl module (I think the :: is a Perl thing?) and I thought it was a Qt project and qmake might work. Google has clarified what Code::Blocks is and I will try going that route.

Thanks,

-k.
mankoff
Posts: 26
Joined: Sat Oct 29, 2011 8:12 pm

Re: Portage to OS X

Post by mankoff »

Well Triangle and QHull both compiled just fine (although I could also install them system-wide with 'brew install triangle' and 'brew install qhull'). All I did was duplicate the Linux build settings and set targets to OSX or Mac.

I'm running into issues with Glew.

Code: Select all

-------------- Build: release.OSX in Lib - Glew ---------------

Linking dynamic library: ../../lib/mingw/glew32.dylib
ld: warning: option -s is obsolete and being ignored
ld: library not found for -lopengl32
collect2: ld returned 1 exit status
On OS X OpenGL is installed here:

Code: Select all

/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/
But I'm not sure how to tell the build system to find it...
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Portage to OS X

Post by daniel »

Indeed, if OS X behaves as Linux, you shouldn't have to build Glew.

To indicate where it lies, you can add this path to the 'include' and 'link' directories list in the qCC project (Right click on projet > Properties > Build targets > Build Options and then 'Search Directories' tab: 'Compiler' for include path, and 'Linker' for libraries path).

However, I've never played with OS X, so I won't be able to help you much more. Maybe another member?
mankoff
Posts: 26
Joined: Sat Oct 29, 2011 8:12 pm

Re: Portage to OS X

Post by mankoff »

Hi Daniel,

Your help has been invaluable so far. If you can continue to do so without too much time/trouble, I will be grateful. I am confident we can get an OS X build and will send a changelog to show what I did, and make the binaries available. Perhaps this will be useful for others. If you are not able to help I understand. Debugging without the system can be hard!

Currently I have "triangle", "Qhull", and "CCFbo" all compiling.

CCLib is giving the following error:

Code: Select all

-------------- Build: release.OSX in Lib - CCLib ---------------

Compiling: ../src/StatisticalTestingTools.cpp
CloudCompare/CC/src/StatisticalTestingTools.cpp: In static member function ‘static void CCLib::StatisticalTestingTools::computeLocalChi2DistAtLevel(const CCLib::DgmOctree::octreeCell&, void**)’:
CloudCompare/CC/src/StatisticalTestingTools.cpp:474: error: cast from ‘void*’ to ‘unsigned int’ loses precision
CloudCompare/CC/src/StatisticalTestingTools.cpp:475: error: cast from ‘void*’ to ‘unsigned int’ loses precision
Which is referring to these two lines:

Code: Select all

174	unsigned numberOfNeighbours			= (unsigned)additionalParameters[1];
175	unsigned numberOfChi2Classes		= (unsigned)additionalParameters[2];
Je vous merci,

-k.
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Portage to OS X

Post by daniel »

I believe that your OS X installation is 64bits?

In this case, we indeed have a problem, as pointers (void*) are also 64 bits and we are then trying to cast them to 32 bits (however, your compiler is a bit harsh to send an error instead of a warning).

Maybe simply casting into 'unsigned long' before copying the value will be sufficient (as we actually init the pointer (void*) with a 32 bits value - I realize it's a bit dirty now that some people are trying to compile on 64 bits OS:

Code: Select all

unsigned numberOfNeighbours = (unsigned long)additionalParameters[1];
Otherwise, you shall make your compiler less 'pedantic' (until we remove this mechanism and use the real value pointer instead of copying the value directly in the void* field - I was a bit lazy at the time I wrote this code).
Daniel, CloudCompare admin
mankoff
Posts: 26
Joined: Sat Oct 29, 2011 8:12 pm

Re: Portage to OS X

Post by mankoff »

Yes I was surprised this was an error and not a warning. I did not have many "-W..." flags set, so I thought it was already not pedantic. Anyway, your suggested code change has fixed this issue.

Onward...!

-k.
mankoff
Posts: 26
Joined: Sat Oct 29, 2011 8:12 pm

Re: Portage to OS X

Post by mankoff »

OK I've gotten everything through and including qCC compiling. There are some errors at the link stage for qCC that I am still working on, but it looks like this can run on OS X without too much trouble. 90% of the changes were to the build system, I only had to change about 10 lines of code.

-k.

P.S. You should submit your tool to the listing here: http://opentopo.sdsc.edu/gridsphere/gri ... =listTools
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Portage to OS X

Post by daniel »

Thanks for the feedback. Your final code::blocks project and the few code modifications will be very valuable.

We can create you a personnal svn account to push these modifications, or you can send them to me via email.

And thanks for the link, that's a great repository. I've already applied for a reference to CC (waiting for approval).
Post Reply