用g ++编译一个dll

时间:2016-06-27 07:03:33

标签: c++ c g++ linker-errors undefined-reference

我一直试图用g ++在windows上编译这个项目: https://github.com/newhouseb/openvr-c

我的命令行:

g++ -c  -std=gnu++0x -DBUILDING_OPENVR_C openvr_c.cpp openvr_c.h
g++ -shared -o openvr_c.dll openvr_c.o  -std=gnu++0x -Wl,--out-implib,openvr_api.dll -L. -lopenvr_api

当我运行第二行时,我得到了这些错误:

  

openvr_c.o:openvr_c.cpp :(文本$ _ZN2vr14COpenVRContext10CheckClearEv [__ ZN2vr14COpenVRContext10CheckClearEv] + 0×12):   对_imp__VR_GetInitToken' openvr_c.o:openvr_c.cpp:(.text$_ZN2vr14COpenVRContext10CheckClearEv[__ZN2vr14COpenVRContext10CheckClearEv]+0x33): undefined reference to _ imp__VR_GetInitToken'的未定义引用   openvr_c.o:openvr_c.cpp :(文字$ _ZN2vr14COpenVRContext8VRSystemEv [__ ZN2vr14COpenVRContext8VRSystemEv] + 0x2B访问):   对_imp__VR_GetGenericInterface' openvr_c.o:openvr_c.cpp:(.text$_ZN2vr14COpenVRContext11VRChaperoneEv[__ZN2vr14COpenVRContext11VRChaperoneEv]+0x2c): undefined reference to _ imp__VR_GetGenericInterface'的未定义引用   openvr_c.o:openvr_c.cpp :(文字$ _ZN2vr14COpenVRContext16VRChaperoneSetupEv [__ ZN2vr14COpenVRContext16VRChaperoneSetupEv] + 0x2c上):   对_imp__VR_GetGenericInterface' openvr_c.o:openvr_c.cpp:(.text$_ZN2vr14COpenVRContext12VRCompositorEv[__ZN2vr14COpenVRContext12VRCompositorEv]+0x2c): undefined reference to _ imp__VR_GetGenericInterface'的未定义引用   openvr_c.o:openvr_c.cpp :(文字$ _ZN2vr14COpenVRContext9VROverlayEv [__ ZN2vr14COpenVRContext9VROverlayEv] + 0x2c上):   对_imp__VR_GetGenericInterface' openvr_c.o:openvr_c.cpp:(.text$_ZN2vr14COpenVRContext14VRRenderModelsEv[__ZN2vr14COpenVRContext14VRRenderModelsEv]+0x2c): more undefined references to _ imp__VR_GetGenericInterface'的未定义引用跟随   openvr_c.o:openvr_c.cpp :(文字$ _ZN2vr7VR_InitEPNS_12EVRInitErrorENS_18EVRApplicationTypeE [__ ZN2vr7VR_InitEPNS_12EVRInitErrorENS_18EVRApplicationTypeE] + 0×23):   对_imp__VR_InitInternal' openvr_c.o:openvr_c.cpp:(.text$_ZN2vr7VR_InitEPNS_12EVRInitErrorENS_18EVRApplicationTypeE[__ZN2vr7VR_InitEPNS_12EVRInitErrorENS_18EVRApplicationTypeE]+0x4c): undefined reference to _ imp__VR_IsInterfaceVersionValid'的未定义引用   openvr_c.o:openvr_c.cpp :(文字$ _ZN2vr7VR_InitEPNS_12EVRInitErrorENS_18EVRApplicationTypeE [__ ZN2vr7VR_InitEPNS_12EVRInitErrorENS_18EVRApplicationTypeE] + 0x61):   对_imp__VR_ShutdownInternal' openvr_c.o:openvr_c.cpp:(.text$_ZN2vr11VR_ShutdownEv[__ZN2vr11VR_ShutdownEv]+0x7): undefined reference to _ imp__VR_ShutdownInternal'的未定义引用collect2.exe:   错误:ld返回1退出状态

我不明白这些错误是什么,

有人可以启发我吗?

1 个答案:

答案 0 :(得分:0)

这看起来像链接器发生了很多错误。 确保正确链接到您的依赖项。

What is an undefined reference/unresolved external symbol error and how do I fix it?