【问题标题】:Codeblocks: Including library代码块:包括库
【发布时间】:2016-06-18 15:34:50
【问题描述】:

我正在尝试开始使用 VJoy 虚拟操纵杆,但无法启动和运行它。

我不断收到此错误:

main.cpp|14| undefined reference to `_imp__vJoyEnabled'

我正在尝试使用下面的代码运行它。

#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include "public.h"
#include "vjoyinterface.h"

using namespace std;

int main()
{
    // Get the driver attributes (Vendor ID, Product ID, Version Number)
    if (!vJoyEnabled())
    {
        cout << "Function vJoyEnabled Failed - make sure that vJoy is installed and enabled\n" << endl;

    }

    cout << "Hello world!" << endl;
    return 0;
}

在代码块中,我已将编译器设置为使用 C++11 进行编译。 同样在代码块中,我已经链接了库(项目构建选项-> 链接器设置-> 添加库) 我也尝试过使用搜索目录,但似乎无法正常工作。

任何想法我错过了什么?

【问题讨论】:

    标签: c++11 linker codeblocks


    【解决方案1】:

    我发现我链接到了错误的位置。不幸的是,没有明确的错误表明这一点。

    所以这个问题的解决方案(在我的例子中):
    - 确保链接到正确的图书馆位置
    -将库及其所有相关文件移动到代码块项目文件夹中
    - 将库添加到链接库(项目构建选项 -> 链接器设置 -> 链接库)
    - 将库位置添加到搜索目录(项目构建选项 -> 搜索目录 -> 链接器 -> 添加)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-13
      • 1970-01-01
      • 2015-12-19
      • 2012-08-02
      • 1970-01-01
      相关资源
      最近更新 更多