Comments (6)
注意:动态库的配置文件根据./test/mqtt_config.h配置的,在编译的时候就应该设置修改好配置文件~
from mqttclient.
我没有将test目录下的mqtt_config.h文件考到头文件目录下,你可以手动将它放过去,然后编译~
路径如下:https://github.com/jiejieTop/mqttclient/blob/master/test/mqtt_config.h
from mqttclient.
您好,依照指示复制了头文件
sudo cp -r test/mqtt_config.h /usr/include/
再次编译报错,
====================[ Build | app | Debug ]=====================================
/usr/bin/cmake --build /mnt/e/linux_c/cmake-build-debug --target app -- -j 8
Scanning dependencies of target app
[ 50%] Building C object CMakeFiles/app.dir/test.c.o
[100%] Linking C executable app
CMakeFiles/app.dir/test.c.o: In functiontopic1_handler': /mnt/e/linux_c/test.c:23: undefined reference to
salof'
/mnt/e/linux_c/test.c:23: undefined reference tosalof_get_tick' /mnt/e/linux_c/test.c:23: undefined reference to
salof'
/mnt/e/linux_c/test.c:23: undefined reference tosalof' /mnt/e/linux_c/test.c:23: undefined reference to
salof'
/mnt/e/linux_c/test.c:24: undefined reference tosalof' /mnt/e/linux_c/test.c:24: undefined reference to
salof_get_tick'
/mnt/e/linux_c/test.c:24: undefined reference tosalof' /mnt/e/linux_c/test.c:24: undefined reference to
salof'
/mnt/e/linux_c/test.c:24: undefined reference tosalof' /mnt/e/linux_c/test.c:25: undefined reference to
salof'
/mnt/e/linux_c/test.c:25: undefined reference tosalof_get_tick' /mnt/e/linux_c/test.c:25: undefined reference to
salof'
/mnt/e/linux_c/test.c:25: undefined reference tosalof' /mnt/e/linux_c/test.c:25: undefined reference to
salof'
CMakeFiles/app.dir/test.c.o: In functionmqtt_publish_thread': /mnt/e/linux_c/test.c:37: undefined reference to
mqtt_list_subscribe_topic'
/mnt/e/linux_c/test.c:42: undefined reference torandom_number' /mnt/e/linux_c/test.c:45: undefined reference to
mqtt_publish'
/mnt/e/linux_c/test.c:48: undefined reference tomqtt_publish' /mnt/e/linux_c/test.c:51: undefined reference to
mqtt_publish'
CMakeFiles/app.dir/test.c.o: In functionmain': /mnt/e/linux_c/test.c:65: undefined reference to
salof_init'
/mnt/e/linux_c/test.c:71: undefined reference totest_ca_get' /mnt/e/linux_c/test.c:78: undefined reference to
random_string'
/mnt/e/linux_c/test.c:79: undefined reference torandom_string' /mnt/e/linux_c/test.c:80: undefined reference to
random_string'
/mnt/e/linux_c/test.c:83: undefined reference tomqtt_init' /mnt/e/linux_c/test.c:85: undefined reference to
mqtt_connect'
/mnt/e/linux_c/test.c:87: undefined reference tomqtt_subscribe' /mnt/e/linux_c/test.c:88: undefined reference to
mqtt_subscribe'
/mnt/e/linux_c/test.c:89: undefined reference tomqtt_subscribe' /mnt/e/linux_c/test.c:91: undefined reference to
pthread_create'
/mnt/e/linux_c/test.c:93: undefined reference tosalof' /mnt/e/linux_c/test.c:93: undefined reference to
salof_get_tick'
/mnt/e/linux_c/test.c:93: undefined reference tosalof' /mnt/e/linux_c/test.c:93: undefined reference to
salof'
/mnt/e/linux_c/test.c:93: undefined reference to `salof'
collect2: error: ld returned 1 exit status
CMakeFiles/app.dir/build.make:94: recipe for target 'app' failed
make[3]: *** [app] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/app.dir/all' failed
make[2]: *** [CMakeFiles/app.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/app.dir/rule' failed
make[1]: *** [CMakeFiles/app.dir/rule] Error 2
Makefile:118: recipe for target 'app' failed
make: *** [app] Error 2
查看mqtt_config.h,里面是一些用户自定义设置相关的宏,应该与上文的错误无关。
实在疑惑,求教这个错误原因?
from mqttclient.
嗯,是我的问题,现在已经修复了,重新操作一下:
1.克隆代码,./make-libmqttclient.sh
编译库
2.进入libmqttclient目录,sudo cp -r include/* /usr/include/
,复制头文件
3.编写cmakelist.txt代码,需要动态链接POSIX线程库
cmake_minimum_required(VERSION 3.10)
project(linux_c C)
set(CMAKE_C_STANDARD 11)
link_libraries(mqttclient)
find_package("Threads")
link_libraries(${CMAKE_THREAD_LIBS_INIT})
add_executable(app test.c)
修复的内容主要是,能正确编译动态库、将./test/mqtt_config.h也放到了头文件中。
from mqttclient.
感谢您的回复和帮助。按照您的提示,问题已经解决。
一点建议:./make-libmqttclient.sh安装库后也安装头文件;另外build.sh也加入make install选项。
from mqttclient.
感谢您的回复和帮助。按照您的提示,问题已经解决。
一点建议:./make-libmqttclient.sh安装库后也安装头文件;另外build.sh也加入make install选项。
我主要是考虑到直接安装头文件会污染系统的东西,而install 库比较容易管理,不过这些都不是啥事情哈,你解决就可以了
from mqttclient.
Related Issues (20)
- 如何配置 TLS/SSL 以实现仅服务器加密而不进行服务器认证的方式,有实现案例嘛?
- 执行完./build.sh后,在./build/bin目录下没有emqx等执行文件 HOT 1
- 最新源码编译时mqttclient-master/common/log/salof_config.h:12:10: fatal error: mqtt_config.h: No such file or directory HOT 1
- 执行build.sh出现问题 HOT 3
- mqttclient连接上server后,断开网络, mqttclient会尝试重连,每次重连就会出现内存泄漏 HOT 6
- v1.2.0版本和master版本为何删除了test目录?目前执行make-libmqttclient.sh编译会失败 HOT 1
- 怎样增加windows的支持
- 目前有没有1.2.0版本的rt-thread。或者该分支支持rt-thread平台运行吗?
- 请问一下linux下还支持x509证书吗
- tls验证openssl CA证书失败 HOT 3
- ../mqttclient/mqttclient.c:951 mqtt_yield_thread()..., mqtt reconnect timeout....不自动重连的问题
- linux下,mqtt服务器一关闭程序就退出了?
- cleansession=false,无法接受离线消息
- cleansession=false,无法接受离线消息 HOT 1
- 怎么调用mqtt_subscribe使用同一个连接订阅多个主题,应该怎么调整相关代码,调整代码的思路是什么
- 自签名双向认证如何实现? HOT 1
- mqtt5.0
- mqtt_subscribe 缓存已经改成8192, 最大接受数据971个
- platform_net_socket_recv_timeout 区分超时与连接断开
- 枚举变量非对齐访问问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqttclient.