0
我已使用此tutorial在我的Rpi中安裝了mosquitto lib
。 /usr/local/bin
有mosquitto_pub and mosquitto_sub
和蚊子服務器deamon在/usr/local/sbin
。如何鏈接到cmake中的mosquitto lib?
然後試圖鏈接我的cmake文件中的庫如下。
cmake_minimum_required(VERSION 2.6)
PROJECT(MosquittoTest)
# The version number.
set (VERSION_MAJOR 1)
set (VERSION_MINOR 0)
include_directories("${PROJECT_BINARY_DIR}")
# Linked libariries
#For MQTT
#location of raspicam's cmake file is /usr/src/raspicam-0.1.3/build
link_directories(/usr/local/sbin)
target_link_libraries (MosquittoTest mosquitto)
ADD_EXECUTABLE(MosquittoTest MosquittoTest.cpp)
# add the install targets
install (TARGETS MosquittoTest DESTINATION bin)
install (FILES MosquittoInterface.h DESTINATION include)
然後我有錯誤,因爲無法爲目標MosquittoTest指定鏈接庫。
總得有人鏈接在GCC的mosquitto LIB作出
CC = gcc
CFLAGS = -I
DEPS = mosquitto.h
LIBS = -llibmosquitto
%.o: %.c $(DEPS)
$(CC) -c -o [email protected] $< $(CFLAGS)
make: test.c
$(CC) -m32 -Wall -o [email protected] $^ $(CFLAGS) $(LIBS)
.PHONY: clean
可能是什麼毛病我cmake的文件?
現在解決了。我需要將libmosquittoop-dev安裝到我的系統中。 – batuman