I am trying to write an OpenVR application using the openvr_capi.h file, and I'm having trouble linking all the files together. The program:
#include <stdio.h>
#include <stdlib.h>
#undef EXTERN_C
#include <openvr_capi.h>
intptr_t VR_InitInternal(EVRInitError *peError, EVRApplicationType eType);
void VR_ShutdownInternal();
bool VR_IsHmdPresent();
intptr_t VR_GetGenericInterface(const char *pchInterfaceVersion, EVRInitError *peError);
bool VR_IsRuntimeInstalled();
const char * VR_GetVRInitErrorAsSymbol(EVRInitError error);
const char * VR_GetVRInitErrorAsEnglishDescription(EVRInitError error);
int main() {
EVRInitError e;
uint32_t vrToken = VR_InitInternal(&e, EVRApplicationType_VRApplication_Scene);
if (e != EVRInitError_VRInitError_None) {
printf("There was an error initializing OpenVR's API.");
return -1;
}
printf("OpenVR initialized successfully!");
return 0;
}
The command I use to compile the program:
gcc -lshell32 -luser32 -lgdi32 -L../lib/ -lopenvr_api -I../inc/ ../src/main.c -o../bin/main.exe
The error I'm getting:
AppData\Local\Temp\cci1BZen.o:main.c:(.text+0x1a): undefined reference to 'VR_InitInternal'
I feel like I'm doing everything right, and it might be a software error I'm experiencing. There is too little documentation surrounding the API, so I have no reference point for what to do or the problem.
I am using Mingw-w64 on Windows and coding with VSCode.
I've tried redownloading the files, just in case I downloaded the wrong files or if any were corrupted. Same result. I've tried using the regular OpenVR library (openvr.h). Different error, but the same general problem. I've tried using the 32-bit OpenVR files. A completely different error that I can't even comprehend. I've tried moving around the files. Same result.