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

Issues when building on Mingw #5375

Closed
guigzzz opened this issue Nov 29, 2018 · 10 comments
Closed

Issues when building on Mingw #5375

guigzzz opened this issue Nov 29, 2018 · 10 comments

Comments

@guigzzz
Copy link
Contributor

guigzzz commented Nov 29, 2018

I followed the steps here and running make fails at the very end.

The error I get is:

make[2]: *** No rule to make target 'discord-rpc/src/libdiscord-rpc.a', needed by 'bin/rpcs3.exe'.  Stop.

Looking in rpcs3_build/rpcs3/CMakeFiles/rpcs3.dir/build.make, I found: bin/rpcs3.exe: discord-rpc/src/libdiscord-rpc.a
Also the path used in the linking is ../discord-rpc/src/libdiscord-rpc.a

I noticed that other 3rdparty ressources had their paths prepended with 3rdparty/.
Trying this, I make the following changes to the build.make:

  • bin/rpcs3.exe: discord-rpc/src/libdiscord-rpc.a -> bin/rpcs3.exe: 3rdparty/discord-rpc/src/libdiscord-rpc.a
  • ../discord-rpc/src/libdiscord-rpc.a -> ../3rdparty/discord-rpc/src/libdiscord-rpc.a

As expected, these changes fix this error.

Running make again, I then get another error:

../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x2dc): undefined reference to `__imp_SetupDiGetClassDevsA'         
../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x2eb): undefined reference to `__imp_SetupDiEnumDeviceInfo'        
../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x306): undefined reference to `__imp_SetupDiGetDeviceRegistryPrope rtyA'                                                                                                                                  
../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x346): undefined reference to `__imp_SetupDiEnumDeviceInterfaces'  
../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x376): undefined reference to `__imp_SetupDiGetDeviceInterfaceDeta ilA'                                                                                                                                   
../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x3b4): undefined reference to `__imp_SetupDiGetDeviceInterfaceDeta ilA'                                                                                                                                   
../3rdparty/hidapi/windows/libhidapi-hid.a(hid.c.obj):hid.c:(.text+0x4f5): undefined reference to `__imp_SetupDiDestroyDeviceInfoList' 
collect2.exe: error: ld returned 1 exit status

Searching online, I found this stackoverflow thread and tried adding -lsetupapi -lhid to the end of the massive g++ command contained in the build.make.
With this change, I finally get everything to link up correctly and the executable to build.

I'm not very familiar with C++ build tools and I have no idea what generates these paths and commands so unfortunately I can't fix this myself. But hopefully someone who knows a bit more than me will be able to figure it out.

@jobs-git
Copy link

Why build it your self using an unusual compiler if you can build it using travis or appveyor?

@guigzzz
Copy link
Contributor Author

guigzzz commented Nov 30, 2018

Because I want to eventually contribute to the project which means setting up a dev environment and I don't want to use visual studio.

@jobs-git
Copy link

That is Genuine, but the best development compiler for windows is of course its native development compiler, that means visual studio.

There is a free version of visual studio for those contributing to open source dev. check this out https://visualstudio.microsoft.com/downloads/.

If it does not fit your needs, you can set up a development environment ONLINE using appveyor. That save you the hassle of building using that unusual compiler.

By the way, in appveyor, just change the code that you want to contribute on your branch and appveyor will compile it for you, hassle free & easy compiling.

Those are few of the things that can do in the mean time while you are waiting for mingw experts to check this out. Good luck! :)

@guigzzz
Copy link
Contributor Author

guigzzz commented Nov 30, 2018

Right I'm aware of visual studio community, however I prefer using VSCode, and if I can get away with not installing VS that would be great. And I didn't know appveyor had online dev environments (if I'm understanding correctly), that sounds pretty cool but I'd rather have a local environment.

Now even if there are better ways on windows of getting the dev environment up and running, the instructions for setting up the environment on MinGW are literally on the front page of this repo in the README. If they don't work what's the point of having them there.

So even if I don't end up using this in the future, this is also a way of contributing: making sure that the bootstrap instructions on the FRONT PAGE work for everybody and are fool proof.

I hope this makes sense

@janisozaur
Copy link
Contributor

janisozaur commented Nov 30, 2018

@guigzzz most likely https://github.com/RPCS3/hidapi/blob/4c2750112e89bf579e7752285ad56e69d15549df/windows/CMakeLists.txt#L1 needs additional line:

diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt
index 387ac02..873216a 100644
--- a/windows/CMakeLists.txt
+++ b/windows/CMakeLists.txt
@@ -1 +1,2 @@
-add_library(hidapi-hid hid.c)
\ No newline at end of file
+add_library(hidapi-hid hid.c)
+target_link_libraries(hidapi-hid setupapi)

and then you may need to re-run cmake. That should address the linkage problems, I'm not sure about discord yet.

@janisozaur
Copy link
Contributor

@guigzzz See #5379 for the discord-rpc fix and see if it works for you.

@guigzzz
Copy link
Contributor Author

guigzzz commented Nov 30, 2018

cheers I'll check it out now

@guigzzz
Copy link
Contributor Author

guigzzz commented Nov 30, 2018

yeap seems like it's working now (I reran CMake and make and the executable linked fine). Thanks guys

@janisozaur
Copy link
Contributor

I've submitted RPCS3/hidapi#5

@guigzzz guigzzz closed this as completed Dec 1, 2018
@janisozaur
Copy link
Contributor

This is not entirely fixed yet, the hidapi PR is not merged yet

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

3 participants