Skip to content

Conversation

@sipsorcery
Copy link
Contributor

@sipsorcery sipsorcery commented Mar 4, 2019

This PR has 90% all of the work done to allow the bitcoin Qt programs to be built with msvc and the appveyor script.

Outstanding issues:

  • There are 3 6 5 code tweaks required for the bitcoin Qt components to be built without warnings with msvc. They seem minor,
  • Building Qt as a static library for Windows is painful and time consuming. I doubt it will ever be possible to build Qt from source as part of an appveyor job (and it would probably take over an hour even if it was). My tentative solution is to build locally and upload the binaries as a github release. The msvc build is only for testing and tinkering but even so this doesn't feel like the ideal solution. Open to suggestions?
  • There is still an issue to sort out with the payment request URL handling. Building Qt with openssl is an extra headache. I will continue to work on getting this working.

The big benefit of this PR is the ability to run bitcoin-qt within a Visual Studio debugging session which could expedite tracking down issues on Windows.

On a side note the test-bitcoin-qt tests fail very early, probably due to *nix specific tests. I haven't dug into them at this point.

Update 28 Jun 2019: The ENABLE_BIP70 option is now off (it's flagged for removal as per #15584). With it disabled msbuild does not require any code changes to build the Bitcoin Core Qt applications.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 4, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15382 ([util] add runCommandParseJSON by Sjors)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@fanquake fanquake requested a review from ken2812221 March 4, 2019 23:05
@fanquake fanquake added the GUI label Mar 4, 2019
Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

My tentative solution is to build locally and upload the binaries as a github release. The msvc build is only for testing and tinkering but even so this doesn't feel like the ideal solution. Open to suggestions?

If this download is required, we can always host it on a more "official" repo etc.

@practicalswift
Copy link
Contributor

practicalswift commented Mar 5, 2019

Concept ACK

Thanks for doing this! Diversity in testing is good!

@ken2812221
Copy link
Contributor

Concept ACK.
Note that appveyor already have pre-built QT libraries

And the qt and vcpkg path could be arguments in msvc-autogen.py to generate the project file, so that the users could build qt on their own computer. like:

python build_msvc\msvc-autogen.py --qt=C:\Qt\5.9.7\msvc2017_64 --vcpkg=C:\Tools\vcpkg

@sipsorcery
Copy link
Contributor Author

sipsorcery commented Mar 6, 2019

Note that appveyor already have pre-built QT libraries

I did spot that but I'm pretty sure the appveyor Qt builds are dynamic linking and therefore incompatible with the static linking builds for all the other bitcoin core libraries.

And the qt and vcpkg path could be arguments in msvc-autogen.py to generate the project file, so that the users could build qt on their own computer. like:

python build_msvc\msvc-autogen.py --qt=C:\Qt\5.9.7\msvc2017_64 --vcpkg=C:\Tools\vcpkg

That's a good idea. I think I can consolidate the location to set global properties to the Directory.Build.props file which would also simplify things.

@sipsorcery
Copy link
Contributor Author

There are lots of warnings for the msvc build of libbitcoin_qt. A lot are generated from the Qt code templates however there is one that looks a bit nasty:

c:\projects\bitcoin-72c17\src\qt\walletmodel.cpp(490): warning C4717: 'WalletModel::UnlockContext::CopyFrom': recursive on all control paths, function will cause runtime stack overflow [C:\projects\bitcoin-72c17\build_msvc\libbitcoin_qt\libbitcoin_qt.vcxproj]
c:\projects\bitcoin-72c17\src\qt\walletmodel.h(199): warning C4717: 'WalletModel::UnlockContext::operator=': recursive on all control paths, function will cause runtime stack overflow [C:\projects\bitcoin-72c17\build_msvc\libbitcoin_qt\libbitcoin_qt.vcxproj]
Done Building Project "C:\projects\bitcoin-72c17\build_msvc\libbitcoin_qt\libbitcoin_qt.vcxproj" (default targets) -- FAILED.

The culprit method WalletModel::UnlockContext::CopyFrom doesn't appear to be used so I've refactored and commented it out. I thought it worth noting for anyone that may be more familiar with this portion of the code.

@laanwj
Copy link
Member

laanwj commented Mar 8, 2019

Concept ACK, I did get bitcoin-qt to build once on MSVC in 2012 or so so, and know how much trouble it is I feel your pain.

@sipsorcery sipsorcery force-pushed the qt_msvc branch 13 times, most recently from 751da0c to 5502529 Compare March 10, 2019 21:28
@sipsorcery sipsorcery changed the title WIP: Add Qt programs to msvc build Add Qt programs to msvc build Mar 10, 2019
@sipsorcery
Copy link
Contributor Author

PR no longer work in progress and ready for review.

@sipsorcery
Copy link
Contributor Author

ping @ken2812221.

Copy link
Contributor

@ken2812221 ken2812221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use shutil to copy the files. Also, use absolute file path instead.

.appveyor.yml Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WholeProgramOptimization is to make sure that the generated cache is not too big to reduce cache save/load time. I remember that the cache could be over 1GB without this setting so that we can't store it with free appveyor plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WholeProgramOptimization is off by default and I removed the cases where it was being set in individual project files.

.appveyor.yml Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change the python code not to use regular expression. It could be single slash here.

@practicalswift
Copy link
Contributor

Nit: A few of the files changed/added text files seem to be missing the expected \n as the last byte of each file.

@sipsorcery sipsorcery force-pushed the qt_msvc branch 2 times, most recently from cddccf6 to 997610f Compare August 10, 2019 17:27
@sipsorcery sipsorcery force-pushed the qt_msvc branch 2 times, most recently from c739577 to ada5dd9 Compare August 17, 2019 10:06
@sipsorcery
Copy link
Contributor Author

For anyone interested in testing this PR here are the bare minimum steps. First 6 are to download the required Qt5.9.7 static libraries. You can build Qt yourself (see the readme file in this PR) but that will a LOT of effort,

wget https://github.com/sipsorcery/qt_win_binary/releases/download/v1.0/sha256sum.asc
wget https://github.com/sipsorcery/qt_win_binary/releases/download/v1.0/Qt5.9.7_ssl_x64_static_vs2017.zip
gpg --search aaron@sipsorcery.com
gpg --verify sha256sum.asc
sha256sum --check sha256sum.asc
extract to C:\Qt5.9.7_ssl_x64_static_vs2017 (must be exactly this path due to Qt machinations)
Open "Developer Command Prompt for VS 2017"
cd bitcoin
py -3 build_msvc\msvc-autogen.py
msbuild /m build_msvc\bitcoin.sln /p:Configuration=Debug /p:Platform=x64 /t:build
build_msvc\x64\Debug\bitcoin-qt.exe -regtest

@NicolasDorier hint hint.

@fanquake
Copy link
Member

Thanks @sipsorcery. I'll be testing this again tomorrow.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ada5dd91d3a05d077727b7e831551ccc38c61502 - apologies for taking so long to get back to this. I've tested using your build instructions in a Windows 10 VM. Works as expected. Left a single comment; as I forgot to install double-conversion and was seeing build errors.

Windows_15529

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double-conversion is missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing! The secp256k1 and leveldb packages aren't required anymore either since they're now included as source projects. I'll fix it up.

@fanquake
Copy link
Member

fanquake commented Sep 8, 2019

@sipsorcery Looks like the windows build files might need some updates for recent changes:

Build FAILED.
       "C:\projects\bitcoin\build_msvc\bitcoin.sln" (default target) (1) ->
       "C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj" (default target) (22) ->
       (Link target) -> 
         libbitcoin_qt.lib(walletcontroller.obj) : error LNK2001: unresolved external symbol "public: __cdecl CreateWalletDialog::CreateWalletDialog(class QWidget *)" (??0CreateWalletDialog@@QEAA@PEAVQWidget@@@Z) [C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj]
         libbitcoin_qt.lib(walletcontroller.obj) : error LNK2001: unresolved external symbol "public: class QString __cdecl CreateWalletDialog::walletName(void)const " (?walletName@CreateWalletDialog@@QEBA?AVQString@@XZ) [C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj]
         libbitcoin_qt.lib(walletcontroller.obj) : error LNK2001: unresolved external symbol "public: bool __cdecl CreateWalletDialog::encrypt(void)const " (?encrypt@CreateWalletDialog@@QEBA_NXZ) [C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj]
         libbitcoin_qt.lib(walletcontroller.obj) : error LNK2001: unresolved external symbol "public: bool __cdecl CreateWalletDialog::disablePrivateKeys(void)const " (?disablePrivateKeys@CreateWalletDialog@@QEBA_NXZ) [C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj]
         libbitcoin_qt.lib(walletcontroller.obj) : error LNK2001: unresolved external symbol "public: bool __cdecl CreateWalletDialog::blank(void)const " (?blank@CreateWalletDialog@@QEBA_NXZ) [C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj]
         C:\projects\bitcoin\build_msvc\x64\Release\bitcoin-qt.exe : fatal error LNK1120: 5 unresolved externals [C:\projects\bitcoin\build_msvc\bitcoin-qt\bitcoin-qt.vcxproj]
    0 Warning(s)
    6 Error(s)
Time Elapsed 00:19:58.92
Command exited with code 1

@sipsorcery
Copy link
Contributor Author

@fanquake yep I'm on it.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 1619684 - AppVeyor looks ok now.

fanquake added a commit that referenced this pull request Sep 11, 2019
1619684 Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. (Aaron Clauson)

Pull request description:

  This PR has ~~90%~~ all of the work done to allow the bitcoin Qt programs to be built with msvc and the appveyor script.

  Outstanding issues:

  - ~~There are ~~3~~ ~~6~~ 5 code tweaks required for the bitcoin Qt components to be built without warnings with msvc. They seem minor~~,
  - Building Qt as a static library for Windows is painful and time consuming. I doubt it will ever be possible to build Qt from source as part of an appveyor job (and it would probably take over an hour even if it was). My tentative solution is to build locally and upload the binaries as a [github release](https://github.com/sipsorcery/qt_win_binary/releases). The msvc build is only for testing and tinkering but even so this doesn't feel like the ideal solution. Open to suggestions?
  - ~~There is still an issue to sort out with the payment request URL handling. Building Qt with openssl is an extra headache. I will continue to work on getting this working.~~

  The big benefit of this PR is the ability to run bitcoin-qt within a Visual Studio debugging session which could expedite tracking down issues on Windows.

  On a side note the test-bitcoin-qt tests fail very early, probably due to *nix specific tests. I haven't dug into them at this point.

  **Update 28 Jun 2019**: The ENABLE_BIP70 option is now off (it's flagged for removal as per #15584). With it disabled msbuild does not require any code changes to build the Bitcoin Core Qt applications.

ACKs for top commit:
  fanquake:
    re-ACK 1619684 - AppVeyor looks ok now.

Tree-SHA512: c0d3fd53b3ff99096b2505d519ed5ca6791bc4bce77addf9c520dc042eec5980a51a1fb9f0aa72e9cc53773085c43218793ca7a915a47806a3a1ffb84d9409f9
@fanquake fanquake merged commit 1619684 into bitcoin:master Sep 11, 2019
@sipsorcery sipsorcery deleted the qt_msvc branch September 11, 2019 06:44
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 12, 2019
…changes)

1619684 Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. (Aaron Clauson)

Pull request description:

  This PR has ~~90%~~ all of the work done to allow the bitcoin Qt programs to be built with msvc and the appveyor script.

  Outstanding issues:

  - ~~There are ~~3~~ ~~6~~ 5 code tweaks required for the bitcoin Qt components to be built without warnings with msvc. They seem minor~~,
  - Building Qt as a static library for Windows is painful and time consuming. I doubt it will ever be possible to build Qt from source as part of an appveyor job (and it would probably take over an hour even if it was). My tentative solution is to build locally and upload the binaries as a [github release](https://github.com/sipsorcery/qt_win_binary/releases). The msvc build is only for testing and tinkering but even so this doesn't feel like the ideal solution. Open to suggestions?
  - ~~There is still an issue to sort out with the payment request URL handling. Building Qt with openssl is an extra headache. I will continue to work on getting this working.~~

  The big benefit of this PR is the ability to run bitcoin-qt within a Visual Studio debugging session which could expedite tracking down issues on Windows.

  On a side note the test-bitcoin-qt tests fail very early, probably due to *nix specific tests. I haven't dug into them at this point.

  **Update 28 Jun 2019**: The ENABLE_BIP70 option is now off (it's flagged for removal as per bitcoin#15584). With it disabled msbuild does not require any code changes to build the Bitcoin Core Qt applications.

ACKs for top commit:
  fanquake:
    re-ACK 1619684 - AppVeyor looks ok now.

Tree-SHA512: c0d3fd53b3ff99096b2505d519ed5ca6791bc4bce77addf9c520dc042eec5980a51a1fb9f0aa72e9cc53773085c43218793ca7a915a47806a3a1ffb84d9409f9
laanwj added a commit to laanwj/bitcoin that referenced this pull request Sep 26, 2019
This part of the build system has been removed in bitcoin#15529 and thus no
longer needs to be updated.
laanwj added a commit that referenced this pull request Sep 26, 2019
8d841ad doc: Remove MSVC update step from translation process (Wladimir J. van der Laan)

Pull request description:

  This part of the build system has been removed in #15529 and thus no longer needs to be updated.

ACKs for top commit:
  MarcoFalke:
    ACK 8d841ad
  sipsorcery:
    ACK 8d841ad

Tree-SHA512: f561a6b1da806e8868a265c77725b94fabef60bc7b9d401e3f70c3d859323adc2e204e3d6fbfea4f1ff86e70667f8bd01157411106ea93974921c02d874e0083
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 26, 2019
…ocess

8d841ad doc: Remove MSVC update step from translation process (Wladimir J. van der Laan)

Pull request description:

  This part of the build system has been removed in bitcoin#15529 and thus no longer needs to be updated.

ACKs for top commit:
  MarcoFalke:
    ACK 8d841ad
  sipsorcery:
    ACK 8d841ad

Tree-SHA512: f561a6b1da806e8868a265c77725b94fabef60bc7b9d401e3f70c3d859323adc2e204e3d6fbfea4f1ff86e70667f8bd01157411106ea93974921c02d874e0083
HashUnlimited pushed a commit to HashUnlimited/chaincoin that referenced this pull request Nov 17, 2019
This part of the build system has been removed in bitcoin#15529 and thus no
longer needs to be updated.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.