6

I have installed CGAL using macports. I run CMake on an example and its running fine. So I tried to create a new project and pasted the code I needed from an example. So I have not link the CGAL libraries yet and unable to run the code. Im not sure how to link it in the build settings. Hope someone can guide me through.

Im trying to run the envelope2.cpp.

user3266188
  • 161
  • 1
  • 7

2 Answers2

8

You mentioned MacPorts but here are instructions for Homebrew. They should be pretty similar but you might need to alter some of the paths from /usr/local to /opt/local.

Install libraries

brew install cgal

Add the includes

  • Open the project settings.
  • Select the project.
  • Choose the Build Settings tab.
  • Select the All filter.
  • Search for header search and you'll find the right setting: Found the setting
  • Double click on the path(s) next to Header Search Paths
  • Click the + button on the detail popup: enter image description here
  • Enter /usr/local/include/.
  • Click outside the detail popup to close it.

Add the libraries

  • Open the project settings.
  • Select the target.
  • Choose the General tab.
  • In the Linked Frameworks and Libraries section click the + button: enter image description here
  • You'll get a selection dialog:
    Add Framework and Library dialog
  • Click the Add Other... button and you'll get an open file dialog.
  • Hit Option + / to go to a specific a directory: Switch to /usr/local/lib
  • Enter /usr/local/lib, and click Go.
  • Select the following files (hold Command while clicking to select more than one at at time):
    • libboost_thread-mt.dylib
    • libCGAL.dylib
    • libCGAL_Core.dylib
    • libgmp.dylib
    • libmpfr.dylib
drewish
  • 9,042
  • 9
  • 38
  • 51
  • 1
    Thanks for a detailed step-by-step answer. To further add on to this answer: I was still unable to compile my CGAL C++ program even after following above stepss. To make it work I made the following changes in the `Search Paths` tab: - `Always Search User Paths` ---> `Yes` - `User Header Search Paths `---> `/usr/local/include` and it worked! I don't understand why this extra steps were required, if anyone knows how to avoid these, please lemme know. – sinner Jul 17 '16 at 23:38
  • interesting,I'll add a note in next time I update these instructions for the new version. – drewish Jul 18 '16 at 04:06
  • For compiled code. If I copy paste the executable to another pc and copy paste the .dylib files, would the executable could run? For now such workflow does not work. – PetrasVestartasEPFL Apr 23 '22 at 16:36
0

When cgal is installed on the system, the example example/Envelope_2 (contains a CMakeLists.txt file) can be run like this:

cmake .
make
./convex_hull

Or for an out-of-source build:

mkdir build
cd build
cmake ..
make
mv ../ch_points.dat .
./convex_hull

This is on OS X with cgal installed using brew, which installs into /usr/local/.... With MacPorts there may be a problem because it installs the third-party packages into /opt.

According to How do I instruct CMake to look for libraries installed by MacPorts? , adding the following to the CMakeLists.txt file (before find_package) may help:

list(APPEND CMAKE_LIBRARY_PATH /opt/local/lib)
list(APPEND CMAKE_INCLUDE_PATH /opt/local/include)
Community
  • 1
  • 1
tmlen
  • 8,533
  • 5
  • 31
  • 84
  • For the bounty I was really looking for some XCode specific instructions. I should have mentioned I'm working with an existing Cinder project so I tried manually adding the libraries and include path and that fixed most of the errors that popped up but got hung up on ld throwing a `duplicate symbol __Z3foov` error. – drewish Feb 17 '15 at 00:13
  • Ah so a quick `c++filt __Z3foov` shows my problems was trying to stick my `foo()` test function in a header that got included twice. – drewish Feb 17 '15 at 00:21