未定义的引用
我有以下问题:
我在 64 位 Ubuntu 上使用 32 位版本的 Qt。在我的项目中,我想包含 FCam 库,以便为诺基亚 N900 手机的相机进行编程。当我在项目文件中包含库的路径时,Qt 似乎没有找到它或者只是不使用它,因为我收到以下错误消息:
undefined reference to "FCam::Image::Image(FCam::Image const&)"
My Libs-linelookslikethis:
LIBS += -lpthread -ljpeg -Llib -L/home/username/FCam
I don't idea Why this does不起作用,因为我有另一个它可以工作的示例项目。我也尝试过该行的一些变体,但徒劳无功。
感谢您的回答, 茨维季
I have the following problem:
I use a 32 bit version of Qt on a 64 bit Ubuntu. In my Project I want to include the library FCam in order to program for the camera of a Nokia N900 mobile phone. When I include the path to the library in my project file, it seems that Qt does not find it or just does not use it because I get the following error message:
undefined reference to "FCam::Image::Image(FCam::Image const&)"
My Libs-line looks like this:
LIBS += -lpthread -ljpeg -Llib -L/home/username/FCam
I have no idea why this does not work, because I have another example project on which it works. I have also tried some variations of the line, but in vain.
Thanks for your answers,
Tsveti
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 -L/home/username/FCam 您告诉链接器在查找时查找该目录
对于它应该链接的库。您还需要告诉它要再次链接哪个库(通过 -l 完成)。
我不知道你的库,但似乎你应该添加 --lfcam 或类似的东西。
With -L/home/username/FCam you are telling the linker to look in that directory when looking
for the libraries it should link against. You also need to tell it what library to link agains (that is done with -l).
I do not know your lib, but it seems you should add a --lfcam or something like it.
看来你混淆了 libs 语句的正确顺序 - 从我得到的少量信息来看,我希望这样:
为什么按这个顺序?
因为首先您必须通过 -L[MY_LIB_DIR] 定义库的位置。
接下来,您必须通过 -lMyLib 添加库 - 您的库文件必须命名为 libMyLib.a 或 libMyLib.so。
最后添加系统库,因为您的应用程序或库很可能依赖于系统库,例如 pthread 和 jpeg。
只要尝试一下新订单,我相信您会得到它;)
ciao,
克里斯
It seems you mixed up the correct order of your libs statement - from the few information I got I would expect this:
Why in this order?
Because first you have to define where the libs are by -L[MY_LIB_DIR].
Next you have to add your libs by -lMyLib - where your library file MUST be named libMyLib.a or libMyLib.so.
At last you add the system libs, because it's likely to happen that your app or your libs have dependencies to the system libs lik pthread and jpeg.
Just try the new order and I'm sure you'll get it ;)
ciao,
Chris