尝试在 Ubuntu 中使用带有 g++ 的 ibdev 并出现链接器错误 [英] Trying to use ibdev with g++ in Ubuntu and getting linker error

查看:50
本文介绍了尝试在 Ubuntu 中使用带有 g++ 的 ibdev 并出现链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Xubuntu 14.04.1 LTS 和 3.13.0-35-generic 内核中的 NI GPIB-USB-B 适配器开发代码来控制一些仪器.
在这一点上,我只是想用 ib.h 库中的函数 ibdev() 进行概念验证.当我输入以下命令时:

I am trying to develop code to control some instruments using the NI GPIB-USB-B adapter in Xubuntu 14.04.1 LTS and the 3.13.0-35-generic kernel.
At this point I am simply going for proof of concept with the function ibdev() in the ib.h library. When I enter the following command:

我收到以下问题:对‘ibdev’的未定义引用".
我假设 ib.h 库位于正确的位置,因为编译器不会抱怨找不到它.
我认为很可能我没有在我的 g++ 命令中输入正确的开关来包含这个库,因为我之前在 time.h 库中遇到过类似的问题,当我需要包含 -lrt 时.我一直在寻找几个小时,尽管它很简单,但找不到解决方案.我查看了 ib.h 文件,它确实包含这些函数原型(尽管使用了extern"),但我不知道在哪里可以找到它们的源代码.这似乎是一个非常简单的解决方案的基本问题,如果您能提供任何帮助,我将不胜感激.

I receive the following for my trouble: "undefined reference to `ibdev'".
I am assuming that the ib.h library is in the correct location as the compiler does not complain about not being able to find it.
I think it is likely that I am not entering the correct switch in my g++ command to include this library as I have had similar problems before with the time.h library, when I needed to include -lrt. I have been looking for hours and cannot find a solution to this despite its simplicity. I have looked in the ib.h file and it does contain these function prototypes (although using 'extern'), but I do not know where to look for their source code. This seems like a very basic issue with a very simple solution and I would appreciate any help that can be given.

这是我的简单程序:

#include "visa.h"
#include <gpib/ib.h>
#include <iostream>

int main() {
    int dev;
    dev = ibdev(0, 5, 0, 13, 1, 0);

    std::cout << "Press any key\n";
    std::cin.ignore();

    return 0;
}

推荐答案

您是否尝试包含 -lgpib ?如果它不在标准路径中,请使用 -L 指定 libgpib 的路径

Did you try including -lgpib ? If its not in a standard path, use -L to specify the path to libgpib

另外,请确保使用 -I

Also, make sure you are including the correct gpib/ib.h using -I

这篇关于尝试在 Ubuntu 中使用带有 g++ 的 ibdev 并出现链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆