title: Linking ports libraries under FreeBSD
body: <p>I have built some libraries (<code>gtk3</code>, <code>qt5</code>, ...) through the ports collection under <code>FreeBSD 11.2</code>. In order to test them I just built minimal examples. Each time the linker complains about not finding these libraries.</p>
  
  <p>Correct me if I am wrong, but under <code>FreeBSD</code>, regular packages (those which are setup with <code>pkg</code>) are installed under <code>/usr/include</code> and <code>/usr/lib</code>, however ports lie, by default, under <code>/usr/local/include</code> and <code>/usr/local/lib</code>.</p>
  
  <p>Is there a simple way to tell the compiler to search under these directories rather than having huge compilation commands with the <code>-I</code> and <code>-L</code> options? </p>
  
  <p>Thank you for your answers.</p>
  
  <h2>Edit</h2>
  
  <p>Here is my <code>CMakeLists.txt</code>:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.12)
  project(gtk-test)
  
  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
  
  find_package(GTK3 REQUIRED)
  
  include_directories(${GTK3_INCLUDE_DIRS})
  link_directories(${GTK3_LIBRARY_DIRS})
  
  add_executable(gtk-test gtk-test.c)
  target_link_libraries(gtk-test ${GTK3_LIBRARIES})
  </code></pre>
  
  <p>I have solved the dependencies issue by grabbing the following <code>CMake</code> script:
  <a href="https://github.com/eiskaltdcpp/eiskaltdcpp/blob/master/cmake/FindGTK3.cmake" rel="nofollow noreferrer">https://github.com/eiskaltdcpp/eiskaltdcpp/blob/master/cmake/FindGTK3.cmake</a></p>
  
  <p>However, another problem has pop up:</p>
  
  <pre><code>[100%] Linking C executable gtk-test
  /usr/lib/crt1.o: In function `_start':
  crt1.c:(.text+0x91): undefined reference to `main'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>I am stupid, I even did not notice that there was no <code>main</code> function in the sample. It works fine except that, by default, <code>CMake</code> cannot locate <code>GTK3</code> library and its dependencies.</p>
  
  <p>Here is the content of my CMake config scripts:</p>
  
  <pre><code>Qt5         
  Qt53DQuick      
  Qt53DRender     
  Qt5DataVisualization    
  Qt5Location     
  Qt5OpenGLExtensions 
  Qt5QuickTest        
  Qt5SerialBus        
  Qt5UiPlugin     
  Qt5WebKit       
  Qt5XmlPatterns
  Qt53DAnimation      
  Qt53DQuickAnimation 
  Qt5Bluetooth        
  Qt5Designer     
  Qt5Multimedia       
  Qt5Positioning      
  Qt5QuickWidgets     
  Qt5SerialPort       
  Qt5UiTools      
  Qt5WebKitWidgets    
  assimp-4.1
  Qt53DCore       
  Qt53DQuickExtras    
  Qt5Charts       
  Qt5Gamepad      
  Qt5MultimediaWidgets    
  Qt5PrintSupport     
  Qt5Script       
  Qt5Sql          
  Qt5WebChannel       
  Qt5WebSockets       
  harfbuzz
  Qt53DExtras     
  Qt53DQuickInput     
  Qt5Concurrent       
  Qt5Gui          
  Qt5Network      
  Qt5Qml          
  Qt5ScriptTools      
  Qt5Svg          
  Qt5WebEngine        
  Qt5Widgets      
  libxml2
  Qt53DInput      
  Qt53DQuickRender    
  Qt5Core         
  Qt5Help         
  Qt5Nfc          
  Qt5Quick        
  Qt5Scxml        
  Qt5Test         
  Qt5WebEngineCore    
  Qt5X11Extras
  Qt53DLogic      
  Qt53DQuickScene2D   
  Qt5DBus         
  Qt5LinguistTools    
  Qt5OpenGL       
  Qt5QuickControls2   
  Qt5Sensors      
  Qt5TextToSpeech     
  Qt5WebEngineWidgets 
  Qt5Xml
  </code></pre>