Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
saimouli's avatar
saimouli
Explorer
10 years ago

Coding without Oculus

I don't own an oculus rift,but successfully ran some demos using config window from oculus runtime. I wanted to code and work without the hardware (temporarily). Using visual studio 2012 and Oculus SDK (0.8 beta). I tried to run following code:

#include <OVR.h>
#include<iostream>

int main(int argc, char ** argv) {
if (!ovr_Initialize()) {
return -1;
}

int hmdCount = ovrHmd_Detect();

for (int i = 0; i < hmdCount; ++i) {
ovrHmd hmd = ovrHmd_Create(i);
ovrHmd_Destroy(hmd);
}

ovrHmd hmd = ovrHmd_CreateDebug(ovrHmd_DK2);
ovrHmd_Destroy(hmd);
ovr_Shutdown();
return 0;
}


Installed the libraries into VS as following:

1) under solution properties-> VC++ directories ->include directories-> C:\Users\USERNAME\Desktop\FOLDER\OculusSDK\LibOVR\Include

2) under library directories-> C:\Users\USERNAME\Desktop\FOLDER\OculusSDK\LibOVR\Lib

3) under linker-> input-> LibOVR.lib

by the way I'm working under release win32.

When I compiled, I get the following errors:
Error 1 error C1083: Cannot open include file: 'Kernel/OVR_Types.h': No such file or directory C:\Users\ksaim\Desktop\ARM_IT\OculusSDK\LibOVR\Include\OVR.h 14 1 oculu 5 IntelliSense: cannot open source file "Kernel/OVR_Alg.h" c:\Users\ksaim\Desktop\ARM_IT\OculusSDK\LibOVR\Include\OVR.h 17 1 oculu 3 IntelliSense: cannot open source file "Kernel/OVR_RefCount.h" c:\Users\ksaim\Desktop\ARM_IT\OculusSDK\LibOVR\Include\OVR.h 15 1 oculu 4 IntelliSense: cannot open source file "Kernel/OVR_Std.h" c:\Users\ksaim\Desktop\ARM_IT\OculusSDK\LibOVR\Include\OVR.h 16 1 oculu 2 IntelliSense: cannot open source file "Kernel/OVR_Types.h" c:\Users\ksaim\Desktop\ARM_IT\OculusSDK\LibOVR\Include\OVR.h 14 1 oculu 8 IntelliSense: identifier "ovrHmd_Create" is undefined c:\Users\ksaim\OneDrive\Documents\Visual Studio 2012\Projects\oculu\oculu\oculu.cpp 12 14 oculu 10 IntelliSense: identifier "ovrHmd_CreateDebug" is undefined c:\Users\ksaim\OneDrive\Documents\Visual Studio 2012\Projects\oculu\oculu\oculu.cpp 15 14 oculu 9 IntelliSense: identifier "ovrHmd_Destroy" is undefined c:\Users\ksaim\OneDrive\Documents\Visual Studio 2012\Projects\oculu\oculu\oculu.cpp 13 1 oculu 11 IntelliSense: identifier "ovrHmd_Destroy" is undefined c:\Users\ksaim\OneDrive\Documents\Visual Studio 2012\Projects\oculu\oculu\oculu.cpp 16 1 oculu 7 IntelliSense: identifier "ovrHmd_Detect" is undefined c:\Users\ksaim\OneDrive\Documents\Visual Studio 2012\Projects\oculu\oculu\oculu.cpp 9 16 oculu 6 IntelliSense: too few arguments in function call c:\Users\ksaim\OneDrive\Documents\Visual Studio 2012\Projects\oculu\oculu\oculu.cpp 5 21 oculu


can someone please guide me.

7 Replies

  • Matlock's avatar
    Matlock
    Honored Guest
    you need to add C:\Users\USERNAME\Desktop\FOLDER\OculusSDK\LibOVR\Src to include directories
  • Thanks matlock, that fixed half issue. I changed my code to fit 0.8 beta version
    #include <OVR.h>
    #include<iostream>

    int main(int argc, char ** argv) {
    if (!ovr_Initialize()) {
    return -1;
    }

    int hmdCount = ovr_Detect();

    for (int i = 0; i < hmdCount; ++i) {
    ovrHmd hmd = ovr_Create(i);
    ovr_Destroy(hmd);
    }

    ovrHmd hmd = ovrHmd_CreateDebug(ovrHmd_DK2);
    ovr_Destroy(hmd);
    ovr_Shutdown();
    return 0;
    }


    ovr_Detect(),ovr_Create(i) and ovrHmd_CreateDebug functions are not taking by the VS. Besides that I've this new error
    Error 1 error LNK1561: entry point must be defined C\.....\visual studio 2012\Projects\oculu\oculu\LINK oculu
  • What kind of project is it? A win32 console app or a windows app?
    The link error is saying it can't find the starting function. The default is...
    Console:
    int main(int argc, char ** argv)

    Window:
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )

    So either your project is the wrong type (properties/linker/system/subsystem) or you have a different entry point function set (properties/linker/advanced/entry point).

    Some other issues:
    ovr_Initialize returns 0 or higher if successful, not true.
    ovrHMD doesn't exist any more. It's now ovrSession.
    ovr_Detect doesn't exist. There can only be one headset. Call ovr_GetHmdDesc(NULL) to query if the headset exists.
    ovr_Create doesn't return the hmd, it uses an ovrSession pointer out parameter and returns an error value.
    There is no CreateDebug function. As far as I know this is done in the oculus config utility (under tools / service / debug type).

    So the code would be more like: (not tested)
        #include <OVR.h>
    #include<iostream>

    int main(int argc, char ** argv) {
    if (ovr_Initialize() < 0) {
    return -1;
    }

    ovrSession hmd;
    ovrGraphicsLuid luid;

    ovrResult result = ovr_Create(&hmd, &luid);
    ovr_Destroy(hmd);

    ovr_Shutdown();
    return 0;
    }
  • @kojack, thank you for updating code to 0.8 version. Where to look for updated functions? Also, I checked properties/linker/system/subsystem to console. I used your code and got 5 errors:

    Severity Code Description Project File Line Suppression State
    Error (active) cannot open source file "Kernel/OVR_Types.h" Oculus_test c:\OculusSDK\LibOVR\Include\OVR.h 14
    Error (active) cannot open source file "Kernel/OVR_RefCount.h" Oculus_test c:\OculusSDK\LibOVR\Include\OVR.h 15
    Error (active) cannot open source file "Kernel/OVR_Std.h" Oculus_test c:\OculusSDK\LibOVR\Include\OVR.h 16
    Error (active) cannot open source file "Kernel/OVR_Alg.h" Oculus_test c:\OculusSDK\LibOVR\Include\OVR.h 17
    Error C1083 Cannot open include file: 'Kernel/OVR_Types.h': No such file or directory Oculus_test c:\oculussdk\libovr\include\ovr.h 14


    By the way I selected empty project at the beginning of creating a project. I also tried adding libOVRKernel into the librray directories and still same errors.
  • Those are compile errors, not link errors, so changing your library path won't help you in any way.

    If you want to use OVR.h, you need to also add the LibOVRKernel\Src from the SDK to your include path.

    However, unless you need all the C++ types in those extra files (which are listed as deprecated) you should not include OVR.h at all, but instead include OVR_CAPI.h, which just has the C API.
  • @jherico, I did add LIBOVRKernel\Src and also replaced ovr.h with OVR_CAPI.h got the following errors:

    Error 6 error LNK1120: 4 unresolved externals ....\visual studio 2012\Projects\Minimal oculus\Debug\Minimal oculus.exe 1 1 Minimal oculus
    Error 4 error LNK2019: unresolved external symbol _ovr_Create referenced in function _main ...\visual studio 2012\Projects\Minimal oculus\Minimal oculus\main.obj Minimal oculus
    Error 5 error LNK2019: unresolved external symbol _ovr_Destroy referenced in function _main ...\visual studio 2012\Projects\Minimal oculus\Minimal oculus\main.obj Minimal oculus
    Error 2 error LNK2019: unresolved external symbol _ovr_Initialize referenced in function _main ...\visual studio 2012\Projects\Minimal oculus\Minimal oculus\main.obj Minimal oculus
    Error 3 error LNK2019: unresolved external symbol _ovr_Shutdown referenced in function _main ....\documents\visual studio 2012\Projects\Minimal oculus\Minimal oculus\main.obj Minimal oculus
    Warning 1 warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification ...\visual studio 2012\Projects\Minimal oculus\Minimal oculus\main.obj Minimal oculus
  • "saimouli" wrote:
    @jherico, I did add LIBOVRKernel\Src and also replaced ovr.h with OVR_CAPI.h got the following errors:

    Error	6	error LNK1120: 4 unresolved externals	....\visual studio 2012\Projects\Minimal oculus\Debug\Minimal oculus.exe	1	1	Minimal oculus


    OK, now you have link errors. You're missing the LibOVR.lib library. You need to add it to the 'Additional Dependencies' of the project. In VS2013 you right click on the project and select properties. It's under Configuration Properties, Linker, Input. It's probably somewhere similar in VS2012.

    If you then get another error about not being able to find the LibOVR.lib file, you need to go into the 'VC++ directories' part of the project properties and add the appropriate path to your Library Directories entry. It's in `LibOVR\Lib\Windows\x64\Release\VS2012` of the Oculus SDK.