我已经使用本教程安装mosquitto lib
在我的 Rpi 中。
已经和 mosquitto 服务器守护进程在./usr/local/bin
mosquitto_pub and mosquitto_sub
/usr/local/sbin
然后尝试在我的 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 make 中的 mosquitto lib 链接为
CC = gcc
CFLAGS = -I
DEPS = mosquitto.h
LIBS = -llibmosquitto
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
make: test.c
$(CC) -m32 -Wall -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
我的 cmake 文件可能有什么问题?