Reputation: 277
I am building an app using bluez
in C.
I am using CLion as my dev environment with two targets - A raspberry Pi 4B and my Linux machine.
This is my CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(bluetooth_client C)
set(CMAKE_C_STANDARD 11)
set (CMAKE_C_FLAGS "-lbluetooth")
add_executable(bluetooth_client main.c)
When I run this targeting the raspberry pi (aka remote host), it works fine. When I run it targeting the local host (Linux on intel) it shows this build message:
I tried to verify if I have the exact libraries installed. When I edit code while targeting the Linux dev it correctly sees all the Bluetooth libraries (bluetooth/hci/hci_lib).
The code I run is from Edison-Playground
Upvotes: 0
Views: 161
Reputation: 141533
set (CMAKE_C_FLAGS "-lbluetooth")
is putting the library before the executable, which results in an invalid order and linker doesn't find your symbol.
Do not use CMAKE_C_FLAGS
directly at all, forget it exists - use various add_*
facilities instead, like add_compile_options
, add_link_options
. Use target_link_libraries(bluetooth_client PRIVATE bluetooth)
for linking.
Upvotes: 1