Linking a CGAL Library to Xcode

I installed CGAL using macports. I run CMake with an example and it works fine. So I tried to create a new project and inserted the code that I need from the example. Therefore, I have not linked the CGAL libraries yet and have been unable to run the code. I am not sure how to link it in the build settings. Hope someone can help me.

I am trying to run the envelope2.cpp file.

+6
source share
2 answers

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

Install libraries

 brew install cgal 

Add includes

  • Open the project settings.
  • Select a project.
  • Select the Build Settings tab.
  • Select the All filter.
  • Search for header search and you will find the correct setting: Found the setting
  • Double-click on the path (s) next to Header Search Paths
  • Click the + button in the drop-down menu: enter image description here
  • Type /usr/local/include/ .
  • Click outside the drop-down list to close it.

Add Libraries

  • Open the project settings.
  • Choose a goal.
  • Select the General tab.
  • In the Linked Frameworks and Libraries section, click the + button: enter image description here
  • A selection dialog box appears:
    Add Framework and Library dialog
  • Click the Add Other... button, and you will open a dialog box with an open file.
  • Press Option + / to go to a specific directory: Switch to / usr / local / lib
  • Type /usr/local/lib and press Go .
  • Select the following files (hold Command while pressing the button to select more than one at a time):
    • libboost_thread-mt.dylib
    • libCGAL.dylib
    • libCGAL_Core.dylib
    • libgmp.dylib
    • libmpfr.dylib
+8
source

If cgal installed on the system, the example/Envelope_2 (containing the CMakeLists.txt file) can be run as follows:

 cmake . make ./convex_hull 

Or to build outside the source:

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

This is OS X with cgal installed with brew, which is installed in /usr/local/... MacPorts may encounter a problem because it installs third-party packages in /opt .

According to How do I tell 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) 
0
source

Source: https://habr.com/ru/post/981140/


All Articles