Oculus OVR_CAPI.cpp error
Oculus OVR_CAPI.cpp error
我目前正在做一个项目,我需要读取Oculus Rift DK2传感器。我已经在网上搜索了可用的样本,遗憾的是,我能找到的唯一样本导致我在SDK版本等方面遇到了很多麻烦。我找到了一个教程,关于如何实现一些基本的c++代码来读取pitch, roll & &;偏航。我使用了Windows V1.8.0的SDK。
#include "stdafx.h"
#include <iostream>
#include "../../OculusSDK/LibOVR/Include/OVR_CAPI.h"
#include <thread>
#include <iomanip>
#define COLW setw(15)
using namespace std;
int main()
{
// Initialize our session with the Oculus HMD.
if (ovr_Initialize(nullptr) == ovrSuccess)
{
ovrSession session = nullptr;
ovrGraphicsLuid luid;
ovrResult result = ovr_Create(&session, &luid);
if (result == ovrSuccess)
{ // Then we're connected to an HMD!
// Let's take a look at some orientation data.
ovrTrackingState ts;
while (true)
{
ts = ovr_GetTrackingState(session, 0, true);
ovrPoseStatef tempHeadPose = ts.HeadPose;
ovrPosef tempPose = tempHeadPose.ThePose;
ovrQuatf tempOrient = tempPose.Orientation;
cout << "Orientation (x,y,z): " << COLW << tempOrient.x << ","
<< COLW << tempOrient.y << "," << COLW << tempOrient.z
<< endl;
// Wait a bit to let us actually read stuff.
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
ovr_Destroy(session);
}
ovr_Shutdown();
// If we've fallen through to this point, the HMD is no longer
// connected.
}
return 0;
}
(据我所知)这部分没有问题。
当我包含OVR_CAPI.h时,OVR_CAPI.cpp神奇地出现在OVR_CAPI.h所在的文件夹中。该CPP文件包含以下内容:
#include "stdafx.h"
#include "OVR_CAPI.h"
OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams * params)
{
return OVR_PUBLIC_FUNCTION(ovrResult)();
}
当我试图构建时,错误:"期望的表达式"answers"C2062(类型'int' unexpected)"出现,都在第6行。有人熟悉这个问题吗,或者有人能给我一些建议,告诉我如何开始使用Oculus软件吗?
您已经包含了LibOVR的源代码。你必须在visual studio中将LibOVR编译为.lib文件,然后将其添加到你的项目中。
步骤1在LibOVR文件夹中,应该有一个"Projects文件夹"。打开visual studio版本的版本。
步骤2编译LibOVR项目(在发布模式下),这应该不会给出任何错误。如果是,则库可能已损坏。请尝试从oculus网站重新下载源代码或尝试不同的版本。
步骤3成功时复制LibOVR。从build文件夹和"Include"文件夹中创建"lib "文件到你自己的项目(我建议在你的项目目录中创建一个新的"libs"文件夹)。
步骤4关闭LibOVR项目并打开自己的项目。打开项目的属性窗口,在vc++目录中添加"Include"文件夹到"Include Directories"。同时将.lib文件所在的文件夹添加到"Library Directories"中。
最后在"链接器->输入"设置中添加LibOVR。
步骤5
添加到main.cpp文件
#include <OVR_CAPI.h>
尝试编译您的项目。
- .cpp和.h文件中的模板专用化声明
- "error: no matching function for call to"构造函数错误
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- Linux的Cpp上的计时器
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- 命名空间中具有.h和.cpp文件的类
- 内置函数可查看CPP中的成员变量
- Compile Error with Eluna - QueryResult.cpp
- \main.cpp|103|error: 与"operator<<"不匹配(操作数类型为"std::ostream {aka std::basic_ostream<char&g
- 如何在安装了 WSL 的 Visual Studio Code 中修复"g++: error: helloworld.cpp: No such file or directory"?
- 编译 CPP 应用程序时出错。 "error: 'posix_memalign' was not declared in this scope"
- OpenCV: grabcut.cpp error
- 类标头和在我的类.cpp文件中使用构造函数:"error: class 'Test' does not have any field named 'counter'"
- main.cpp|45|error:"int" 和 "double" 之前的预期主表达式
- "complex-functions.cpp:57:25: error: expected initializer before ‘add’" 这是什么意思?
- 使用main.cpp、node.cpp/.h和slist.cpp/.h[var SLNode未命名类型:error]构建
- source.cpp:LINE:COL: error:这里不允许定义函数
- Oculus OVR_CAPI.cpp error
- 在编译main.cpp:3:1时,我一直得到这个错误:error: ' do '之前的expected unqual