-
Notifications
You must be signed in to change notification settings - Fork 970
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
Update build system so it will compile on Windows 10 #1039
Conversation
1859c48
to
a0ad458
Compare
c109930
to
806cb0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting there, but there are still some things that need to be conditional.
92340cb
to
d164808
Compare
@CendioOssman Can this be accepted or are there more changes you would like to see? I have additional fixes I want to submit after this is accepted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting there, thank you. :)
Some minor things to tweak, but the big issue is p11-kit. See my comments.
set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -Wl,-Bdynamic") | ||
|
||
if(UNISTRING_LIBRARY) | ||
set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -lunistring") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assume this also needs to be statically linked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem with the unistring library in MSYS2 that prevents static linking from working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What specific problem? Is that static version of the library missing from MSYS2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I receive the following linking errors when I link unistring statically.
[ 59%] Linking CXX executable vncconfig.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-iconv.o):(.text+0x2a0): undefined reference to `__imp_uninorm_nfc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x127): undefined reference to `__imp_UC_CATEGORY_Ll'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x155): undefined reference to `__imp_UC_CATEGORY_Lu'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x17a): undefined reference to `__imp_UC_CATEGORY_Lo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x1a9): undefined reference to `__imp_UC_CATEGORY_Nd'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x1d8): undefined reference to `__imp_UC_CATEGORY_Lm'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x207): undefined reference to `__imp_UC_CATEGORY_Mn'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x236): undefined reference to `__imp_UC_CATEGORY_Mc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x265): undefined reference to `__imp_UC_CATEGORY_Lt'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x294): undefined reference to `__imp_UC_CATEGORY_Nl'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x2c3): undefined reference to `__imp_UC_CATEGORY_No'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x2f2): undefined reference to `__imp_UC_CATEGORY_Me'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x321): undefined reference to `__imp_UC_CATEGORY_Sm'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x350): undefined reference to `__imp_UC_CATEGORY_Sc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x37f): undefined reference to `__imp_UC_CATEGORY_So'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x3ae): undefined reference to `__imp_UC_CATEGORY_Sk'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x3dd): undefined reference to `__imp_UC_CATEGORY_Pc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x40c): undefined reference to `__imp_UC_CATEGORY_Pd'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x43b): undefined reference to `__imp_UC_CATEGORY_Ps'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x46a): undefined reference to `__imp_UC_CATEGORY_Pe'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x499): undefined reference to `__imp_UC_CATEGORY_Pi'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x4c8): undefined reference to `__imp_UC_CATEGORY_Pf'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x4f7): undefined reference to `__imp_UC_CATEGORY_Po'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x538): undefined reference to `__imp_UC_CATEGORY_Zs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x55a): undefined reference to `__imp_UC_CATEGORY_Cc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x5f3): undefined reference to `__imp_UC_CATEGORY_Zs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x856): undefined reference to `__imp_uninorm_nfkc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libgnutls.a(str-unicode.o):(.text+0x978): undefined reference to `__imp_uninorm_nfc'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [win\vncconfig\CMakeFiles\vncconfig.dir\build.make:150: win/vncconfig/vncconfig.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:637: win/vncconfig/CMakeFiles/vncconfig.dir/all] Error 2
mingw32-make: *** [Makefile:149: all] Error 2
I believe the cause is the unistring library requires the static libraries to be compiled separately from the dynamic libraries. MSYS2 compiles the dynamic and static libraries at the same time.
One potential workaround is linking statically first and then linking dynamically. This should cause the dynamic linking to only be required when static linking doesn't find everything it needs, right?
@@ -58,6 +77,10 @@ if(BUILD_STATIC) | |||
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32") | |||
# And sockets | |||
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lws2_32") | |||
# link ncrypt and unistring statically | |||
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bstatic -lncrypt -Wl,-Bdynamic") | |||
# p11-kit only available as dynamic library for MSYS2 on Windows and dynamic linking of unistring is required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic as we don't want to force a p11-kit dependency on people that are trying to get a properly static build.
I think we need to better detect if p11-kit is required by GnuTLS in such a case. And really test if a static library is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that would be more robust. However, I don't know how to do that in CMAKE. The current codebase doesn't compile for Windows without modification. This will at least allow one setup to compile for Windows. Unless you know of a setup that currently compiles without modification that this breaks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks at least our Linux mingw builds. So it would cause problems for existing users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't highlight the p11-kit code. However, I did make the p11-kit include dependent on finding the p11-kit library. That is not the same as determining if GnuTLS requires p11-kit. However, is that sufficient to prevent breaking your build?
f089cad
to
77721d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the latest checks it at least doesn't break our mingw build here. I'm still concerned about some libraries being dynamically linked, but perhaps we can test this and roll it back if there are reported issues.
With this commit, TigerVNC will compile for Windows using MSYS2, MinGW-w64 and Inno Setup 6. The resulting binaries have some dll dependencies (even with BUILD_STATIC). The required dll dependencies are not included in the installer. Unfortunately, the latest version of MSYS2 and MinGW-w64 do not produce a working executable for Windows 7.
Sorry for dropping the ball here. Should be ready to merge so I'll do a final test and get it done. |
With this commit, TigerVNC will compile for Windows using MSYS2, MinGW-w64 and Inno Setup 6. The resulting binaries have some dll dependencies (even with BUILD_STATIC) and those are included in the installer.
Unfortunately, the latest version of MSYS2 and MinGW-w64 do not produce a working executable for Windows 7.