简体   繁体   English

在Qt Creator中进行编译时在Qt中出现Libvirt错误

[英]Libvirt in Qt error while compiling in Qt Creator

Why is it that i get this error 为什么我得到这个错误

error: undefined reference to `virConnectOpen'

whenever I compile it and many other functions too? 每当我编译它以及许多其他功能时?

After some research I found this: http://comments.gmane.org/gmane.comp.emulators.libvirt/62812 经过一些研究,我发现了这一点: http : //comments.gmane.org/gmane.comp.emulators.libvirt/62812
but I don't know how to include that -lvirt option for gcc in Qt Creator. 但是我不知道如何在Qt Creator中为gcc包含-lvirt选项。

Assuming you have a qmake project, open the .pro file, and this line to include that library: 假设您有一个qmake项目,请打开.pro文件,并在以下行中包含该库:

LIBS += -lvirt

Also, you can look at the actual gcc compile commands in the Compile Output view, which you can select from the bottom of the screen. 另外,您可以在“编译输出”视图中查看实际的gcc编译命令,您可以从屏幕底部选择该命令。 After adding that, you should see -lvirt added to the link command (last gcc or g++ command in the output). 添加-lvirt之后,您应该看到-lvirt添加到链接命令(输出中最后一个gccg++命令)。 It's useful to learn how to look at that output, when solving problems like this, where you need to get some options added for the compiler or linker, and want to see what options are actually given to it. 在解决诸如此类的问题时,了解如何查看该输出非常有用,您需要在其中为编译器或链接器添加一些选项,并希望查看实际为其提供了哪些选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM