[英]How to add compiler option for mosquitto library in qt creator
so I am wanting to interface the mosquitto mqtt library into qt creator (c++), to create a graphical program for using mqtt.所以我想将 mosquitto mqtt 库连接到 qt creator (c++),以创建使用 mqtt 的图形程序。 I am trying to figure out how to add the -lmosquitto compiler option, I have seen similar posts about adding c++ compiler options by using line shown below inside the.pro file
我想弄清楚如何添加 -lmosquitto 编译器选项,我看到过类似的帖子,内容是通过在 .pro 文件中使用下面显示的行来添加 c++ 编译器选项
QMAKE_CXXFLAGS += compiler option here
I tried to add the -lmosquitto compiler option in the same way shown below我尝试以如下所示的相同方式添加 -lmosquitto 编译器选项
QMAKE_CXXFLAGS += -lmosquitto
but I still get errors saying undefined reference to 'function names'但我仍然收到错误消息,说未定义对“函数名称”的引用
Does anyone know how to add compiler options for libraries into qt有谁知道如何将库的编译器选项添加到 qt
FYI: I am using ubuntu, in qt creator I am creating widget application, and I am sure the -lmosquitto is the correct option as I can compile code wrote in text editor from command line using it.仅供参考:我正在使用 ubuntu,在 qt creator 我正在创建小部件应用程序,并且我确信 -lmosquitto 是正确的选项,因为我可以使用它从命令行编译在文本编辑器中编写的代码。
Any help with this would be great,任何帮助都会很棒,
Thanks in advance, Dean提前致谢,院长
As a general advice I would give you is, to use CMake
with QT
.作为一般建议,我会给你的是,将
CMake
与QT
一起使用。 QT
supports CMake
since QT5
IIRC, and since QT6
it is the standard build tool if I'm not mistaken. QT
自QT5
IIRC 起支持CMake
,如果我没记错的话,自QT6
起它就是标准构建工具。 The benefit of using CMake
is that you will find more answers to your questions.使用
CMake
的好处是您会找到更多问题的答案。
That being said, if you still wish to use qmake
instead of CMake
then last I checked, you will need to add a line like this to your .pro
file:话虽这么说,如果你仍然希望使用
qmake
而不是CMake
那么我最后检查过,你需要在你的.pro
文件中添加这样一行:
LIBS += -L/path/to/your/mosquitto_library -lmosquitto
Notice the -L
flag where you specify the library path.注意指定库路径的
-L
标志。 This is essentially what is missing from your CXX
flags.这基本上是您的
CXX
标志中缺少的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.