代码块:包括库
Codeblocks: Including library
我正在尝试开始使用 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;
}
在 Codeblocks 中,我已将编译器设置为使用 C++11 进行编译。
同样在 Codeblocks 中,我已经链接了库(项目构建选项 -> 链接器设置 -> 添加库)
我也试过使用搜索目录,但似乎无法正常工作。
知道我遗漏了什么吗?
我发现我 link 去错了地方。不幸的是,没有明确的错误表明这一点。
所以这个问题的解决方案(在我的例子中):
-确保你link到正确的图书馆位置
- 将库及其所有相关文件移动到代码块项目文件夹中
- 将库添加到 linked 库(项目构建选项 -> Linker 设置 -> Link 库)
- 将库位置添加到搜索目录(项目构建选项 -> 搜索目录 -> Linker -> 添加)
我正在尝试开始使用 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;
}
在 Codeblocks 中,我已将编译器设置为使用 C++11 进行编译。 同样在 Codeblocks 中,我已经链接了库(项目构建选项 -> 链接器设置 -> 添加库) 我也试过使用搜索目录,但似乎无法正常工作。
知道我遗漏了什么吗?
我发现我 link 去错了地方。不幸的是,没有明确的错误表明这一点。
所以这个问题的解决方案(在我的例子中):
-确保你link到正确的图书馆位置
- 将库及其所有相关文件移动到代码块项目文件夹中
- 将库添加到 linked 库(项目构建选项 -> Linker 设置 -> Link 库)
- 将库位置添加到搜索目录(项目构建选项 -> 搜索目录 -> Linker -> 添加)