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

(Windows/mingw64) Can't link static binary #1769

Closed
autofire372 opened this issue May 30, 2020 · 7 comments
Closed

(Windows/mingw64) Can't link static binary #1769

autofire372 opened this issue May 30, 2020 · 7 comments

Comments

@autofire372
Copy link

autofire372 commented May 30, 2020

I am at my wit's end. I am trying to build mGBA as a static binary on Windows via mingw64. I have installed qt5-static, and installed ffmpeg 4.2.3 from source. I then invoke the following cmake command:

cmake -DCMAKE_EXE_LINKER_FLAGS=-static -DUSE_MINIZIP=OFF -DZLIB_LIBRARY_RELEASE=/mingw64/lib/libz.a -DEPOXY_LIBRARIES=/mingw64/lib/libepoxy.a -DPNG_LIBRARY_RELEASE=/mingw64/lib/libpng.a -DSQLite3_LIBRARY=/mingw64/lib/libsqlite3.a -DQt5Core_DIR=/mingw/qt5-static/lib/cmake/Qt5Core -DQt5Gui_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5Gui -DQt5LinguistTools_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5LinguistTools -DQt5Multimedia_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5Multimedia -DQt5Network_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5Network -DQt5OpenGL_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5OpenGL -DQt5Widgets_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5Widgets -DQt5_DIR:PATH=/mingw64/qt5-static/lib/cmake/Qt5 -DQTPCRE:FILEPATH=/mingw64/qt5-static/lib/libqtpcre2.a -DBUILD_STATIC=ON -DBUILD_SHARED=OFF .. -G "MSYS Makefiles"

The SDL binary builds fine (though it refuses to run outside minGW), but the Qt binary trips at the finish line:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqwindows C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqwindows collect2.exe: error: ld returned 1 exit status make[2]: *** [qt/CMakeFiles/mgba-qt.dir/build.make:1755: qt/mGBA.exe] Error 1 make[1]: *** [CMakeFiles/Makefile2:513: qt/CMakeFiles/mgba-qt.dir/all] Error 2 make: *** [Makefile:172: all] Error 2

I can't use Docker as I am on Windows 10 Home. What am I doing wrong?

@endrift
Copy link
Member

endrift commented May 30, 2020

uh, wow that's a lot of flags. Usually I'd just do -DCMAKE_PREFIX_PATH=/mingw/qt5-static instead of that mess.

@autofire372
Copy link
Author

autofire372 commented May 31, 2020

Condensed it down to the following:

cmake -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_PREFIX_PATH=/mingw64/qt5-static -DUSE_MINIZIP=OFF -DBUILD_STATIC=ON -DBUILD_SHARED=OFF .. -G "MSYS Makefiles"

The SDL build now runs outside of mingw, but I still get the cannot find -lqwindows error when linking the qt build.

EDIT: I just tried again from a fresh mingw64 setup and still got the same exact errors at link time:

[100%] Linking CXX executable mGBA.exe C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqwindows C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqwindows collect2.exe: error: ld returned 1 exit status make[2]: *** [qt/CMakeFiles/mgba-qt.dir/build.make:1753: qt/mGBA.exe] Error 1 make[1]: *** [CMakeFiles/Makefile2:513: qt/CMakeFiles/mgba-qt.dir/all] Error 2 make: *** [Makefile:172: all] Error 2

@Dimensional
Copy link

Dimensional commented May 31, 2020 via email

@autofire372
Copy link
Author

autofire372 commented May 31, 2020

You could install a version of Docker that uses virtualbox instead, and get pretty much the same results. https://docs.docker.com/toolbox/toolbox_install_windows/ There might be a few bugs when using even the latest version of Docker Toolbox, so try going a version or two older, but will be useful since you can't install Hyper-V in Windows 10 Home. Some of the issue pages on their github page explain which version will work if you have issues.

On 5/30/2020 7:02 PM, autofire372 wrote: Condensed it down to the following: |cmake -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_PREFIX_PATH=/mingw64/qt5-static -DUSE_MINIZIP=OFF -DBUILD_STATIC=ON -DBUILD_SHARED=OFF .. -G "MSYS Makefiles"| I still get the |cannot fine -lqwindows| error atthe qt build's link time. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1769 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGLLYJHNALS4KDX7LBQZDLRUGNBFANCNFSM4NO4U5LQ.

You actually can install Hyper-V (and Docker Desktop) on Windows 10 Home, but Docker still won't let you run Windows container images unless you upgrade to Pro.

@endrift
Copy link
Member

endrift commented Jun 1, 2020

Can you see if changing qwindows to Qt5::QWindowsIntegrationPlugin on line 292 of src/platform/qt/CMakeLists.txt fixes this?

@autofire372
Copy link
Author

autofire372 commented Jun 1, 2020

Unfortunately, that just resulted in a bunch of undefined references to things like __imp__ZN10QArrayData10deallocateEPS_yy and __imp__ZN14QSystemLibrary4loadEPKwb.

@endrift
Copy link
Member

endrift commented Jun 1, 2020

I managed to reproduce this, after a lot of fighting with my Windows VM. I'll have a fix tonight. Unfortuantely several of the libraries that it depends on still aren't static so you'll need to package a few DLLs (e.g. SDL) but it's way fewer than before.

@endrift endrift closed this as completed in 57ad735 Jun 2, 2020
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