Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error during attempt to build the cabal tests #3

Open
codeweaverx opened this issue Mar 5, 2017 · 6 comments
Open

Linker error during attempt to build the cabal tests #3

codeweaverx opened this issue Mar 5, 2017 · 6 comments

Comments

@codeweaverx
Copy link

codeweaverx commented Mar 5, 2017

I tried building the test cases using cabal test. cabal test cubes didn't work either.

I managed to get as far as this output, after altering the cabal file for openvr-hs to point its extra include and extra library dirs at the spot where my OpenVR install was placed.

The resulting linker errors are below and relate to the functions VR_GetGenericInterface and VR_GetVRInitErrorAsEnglishDescription.

This may or may not be related to a separate problem: When I first tried to build the openvr-hs library, I ran into a complaint here in openvr_capi_fixed.h:

// #if defined( __WIN32 )
// typedef char bool;
// #else
#include <stdbool.h>
// #endif

Without the commenting-out, the compiler complains that bool is already defined, and it fails to even build, much less install, openvr-hs. But perhaps this is causing problems for the linker later on.

Advice?


$ cabal test
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring openvr-hs-0.1.0.0...
Preprocessing library openvr-hs-0.1.0.0...
[1 of 1] Compiling Graphics.VR.OpenVR ( src\Graphics\VR\OpenVR.hs, dist\build\Graphics\VR\OpenVR.o )
[1 of 1] Compiling Graphics.VR.OpenVR ( src\Graphics\VR\OpenVR.hs, dist\build\Graphics\VR\OpenVR.p_o )
Preprocessing test suite 'minimal' for openvr-hs-0.1.0.0...
[1 of 1] Compiling Main ( app\Minimal.hs, dist\build\minimal\minimal-tmp\Main.p_o )
Linking dist\build\minimal\minimal.exe ...
C:\msys64\home\Michael Jones\Documents\Programming\Haskell\OpenVR\openvr-hs\dist\build/libHSopenvr-hs-0.1.0.0-K5yHTjbmNrL7i9N4GDus50_p.a(openvr_capi_helper.p_o):openvr_capi_helper.cpp:(.text+0x2c): undefined reference to VR_GetGenericInterface(char const*, EVRInitError*)' C:\msys64\home\Michael Jones\Documents\Programming\Haskell\OpenVR\openvr-hs\dist\build/libHSopenvr-hs-0.1.0.0-K5yHTjbmNrL7i9N4GDus50_p.a(openvr_capi_helper.p_o):openvr_capi_helper.cpp:(.text+0x49): undefined reference to VR_GetVRInitErrorAsEnglishDescription(EVRInitError)'
collect2.exe: error: ld returned 1 exit status
gcc.exe' failed in phase Linker'. (Exit code: 1)

@codeweaverx codeweaverx changed the title Linker error on Windows, MSYS Linker error during attempt to build the cabal tests Mar 5, 2017
@codeweaverx
Copy link
Author

update to this one... I have now reconfigured my MSYS2 to avoid spaces in my path, and also put the various libraries and DLLs in place so now I have an absolutely stock cabal file for openvr-hs.

Same problems as above.

Windows 10, ghc 8.0.2 built in the same MSYS2 install, gcc reporting Rev2 built for the MSYS2 project, version 6.3.0

@lukexi
Copy link
Owner

lukexi commented Mar 8, 2017

Hi Michael! Ah, I have a guess - did you run copyLibWin.sh?

The bindings expect a particular version of OpenVR (which I probably need to update again, they've been moving fast) - so copyLibWin.sh will place the right version in /usr/local/bin so Cabal/Stack can find it.

@codeweaverx
Copy link
Author

I shall try that right away, and report back. Though it would be really weird for that to affect the above typedef problem wouldn't it?

@codeweaverx
Copy link
Author

codeweaverx commented Mar 17, 2017

Nope. Exactly the same result as before. With that typedef in its original form, openvr-hs fails to build. With that typedef the way I have it to get past that problem, openvr-hs builds fine, but cabal test still fails at the link stage on building minimal.exe with the following errors, which are the same as above as far as I can tell:

michaeljones@LongShot MINGW64 ~/Documents/Programming/Haskell/OpenVR/openvr-hs
$ ./copyLibWin.sh

michaeljones@LongShot MINGW64 ~/Documents/Programming/Haskell/OpenVR/openvr-hs
$ cabal test
Preprocessing library openvr-hs-0.1.0.0...
Preprocessing test suite 'minimal' for openvr-hs-0.1.0.0...
Linking dist\build\minimal\minimal.exe ...
C:\msys64\home\michaeljones\Documents\Programming\Haskell\OpenVR\openvr-hs\dist\build/libHSopenvr-hs-0.1.0.0-K5yHTjbmNrL7i9N4GDus50_p.a(openvr_capi_helper.p_o):openvr_capi_helper.cpp:(.text+0x2c): undefined reference to VR_GetGenericInterface(char const*, EVRInitError*)' C:\msys64\home\michaeljones\Documents\Programming\Haskell\OpenVR\openvr-hs\dist\build/libHSopenvr-hs-0.1.0.0-K5yHTjbmNrL7i9N4GDus50_p.a(openvr_capi_helper.p_o):openvr_capi_helper.cpp:(.text+0x49): undefined reference to VR_GetVRInitErrorAsEnglishDescription(EVRInitError)'
collect2.exe: error: ld returned 1 exit status
gcc.exe' failed in phase Linker'. (Exit code: 1)

@codeweaverx
Copy link
Author

Incidentally, the error that results from the typedef issue is as follows in case its related:

Preprocessing library openvr-hs-0.1.0.0...
[1 of 1] Compiling Graphics.VR.OpenVR ( src\Graphics\VR\OpenVR.hs, dist\build\Graphics\VR\OpenVR.o )

In file included from cbits\openvr_capi_missing.h:2:0: error:
0,
from cbits\openvr_capi_helper.cpp:1:

cbits\openvr_capi_fixed.h:48:14: error:
error: redeclaration of C++ built-in type 'bool' [-fpermissive]
typedef char bool;
^
gcc.exe' failed in phase C Compiler'. (Exit code: 1)

@codeweaverx
Copy link
Author

Okay, any further advice? It appears that I'm still getting this error having just re-downloaded and built your modules from the git repositories.

I still run into the same error.

There is no dll openvr_api.dll in any folder in the openvr-hs git repository, so the copyLibWin.sh fails to copy anything in to /usr/local/bin. Having found that file in the C++ openvr folder from Valve, I tried that.

However, you mentioned there was a specific version that was required, and I don't know where to get it.

I'm still at the point where, on attempting to build the test cubes in MSYS2 64 bit, and having fixed the broken bool section in that header above, I get:

ghc.exe: unable to load package `openvr-hs-0.1.0.0'

ghc.exe: C:\msys64\home\michaeljones\Documents\Programming\Haskell\OpenVR\openvr-hs\dist\build\HSopenvr-hs-0.1.0.0-LiBZHZGs2x88B234Gr5s3g.o: unknown symbol `_Z22VR_GetGenericInterfacePKcP12EVRInitError'

Advice? If all this really is down to the specific version of the DLL I'm using, where do I get it, and what parts of the build do I have to clean and rebuild? (I can do a clean git pull after solving that I suppose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants