user3266188
user3266188

Reputation: 161

Linking CGAL Library with XCode

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.

Upvotes: 6

Views: 2080

Answers (2)

drewish
drewish

Reputation: 9380

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

Upvotes: 8

tmlen
tmlen

Reputation: 9090

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)

Upvotes: 0

Related Questions