title: clang: error: linker command failed with exit code 1 (use -v to see invocation) when linking library in cmake
body: <p>I'm trying to link <a href="https://github.com/thp/psmoveapi" rel="nofollow noreferrer">this</a> library to my project, I'm using CLion as my IDE and CMake to link. I have tried to follow all kinds of tutorials but no result. Is there another way of doing this? I'm a beginner in C++ and I come from a more higher level language. Thank you in advance</p>
  
  <p>CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.12)
  
  project(psapitest)
  
  add_library(
      psmoveapi-lib
      ${PROJECT_SOURCE_DIR}/main.cpp
      ${PROJECT_SOURCE_DIR}/psmoveapi/build/psmove_config.h
      ${PROJECT_SOURCE_DIR}/psmoveapi/include/psmove.h
  )
  
  add_executable(test-app main.cpp)
  
  target_link_libraries(test-app PRIVATE psmoveapi-lib)
  </code></pre>
  
  <p>Project structure:
  <a href="https://i.stack.imgur.com/21blS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/21blS.png" alt="enter image description here"></a></p>
  
  <p>Console error:</p>
  
  <pre><code>====================[ Build | test-app | Debug ]================================
   /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build.    /Users/admin/CLionProjects/psapitest/build --target test-app -- -j 2
  Scanning dependencies of target psmoveapi-lib
  [ 25%] Building CXX object CMakeFiles/psmoveapi-lib.dir/main.cpp.o
  [ 50%] Linking CXX static library libpsmoveapi-lib.a
  [ 50%] Built target psmoveapi-lib
  Scanning dependencies of target test-app
  [ 75%] Building CXX object CMakeFiles/test-app.dir/main.cpp.o
  [100%] Linking CXX executable test-app
  Undefined symbols for architecture x86_64:
    "_psmove_connect", referenced from:
    _main in main.cpp.o
    "_psmove_connection_type", referenced from:
    _main in main.cpp.o
    "_psmove_count_connected", referenced from:
    _main in main.cpp.o
    "_psmove_disconnect", referenced from:
    _main in main.cpp.o
    "_psmove_get_accelerometer", referenced from:
    _main in main.cpp.o
     "_psmove_get_battery", referenced from:
    _main in main.cpp.o
    "_psmove_get_buttons", referenced from:
    _main in main.cpp.o
    "_psmove_get_gyroscope", referenced from:
    _main in main.cpp.o
    "_psmove_get_magnetometer", referenced from:
    _main in main.cpp.o
    "_psmove_get_serial", referenced from:
    _main in main.cpp.o
   "_psmove_get_temperature", referenced from:
    _main in main.cpp.o
    "_psmove_get_temperature_in_celsius", referenced from:
    _main in main.cpp.o
    "_psmove_get_trigger", referenced from:
    _main in main.cpp.o
    "_psmove_init", referenced from:
    _main in main.cpp.o
    "_psmove_poll", referenced from:
    _main in main.cpp.o
    "_psmove_set_leds", referenced from:
    _main in main.cpp.o
    "_psmove_set_rumble", referenced from:
    _main in main.cpp.o
    "_psmove_update_leds", referenced from:
    _main in main.cpp.o
    "_psmove_util_sleep_ms", referenced from:
    _main in main.cpp.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[3]: *** [test-app] Error 1
  make[2]: *** [CMakeFiles/test-app.dir/all] Error 2
  make[1]: *** [CMakeFiles/test-app.dir/rule] Error 2
  make: *** [test-app] Error 2
  </code></pre>