bitcoin-core / gui

Bitcoin Core GUI staging repository
https://github.com/bitcoin/bitcoin
MIT License
593 stars 259 forks source link

src/qt/README.md is unclear/incomplete regarding "Setup Qt Creator" #240

Closed benliepert closed 3 years ago

benliepert commented 3 years ago

I'm going through the gui/src/qt/README.md to set up a development environment in Ubuntu. I had 2 issues:

  1. I got errors for every "#include <qt/. . .>". I believe this is because creator has no sense of where the qt directory is when it's the absolute path of the project (step 4), as the root directory of the project is named "bitcoin-qt". Removing "qt/" from relevant includes, or importing the project with absolute path of gui/ or gui/src resolves this.

  2. I got "file not found" errors for all of the Qt core #includes (QApplication, QDebug, QSettings, etc)

For what it's worth, I had identical behavior in Arch Linux.

hebasto commented 3 years ago

cc @jarolrod

jarolrod commented 3 years ago

Just went through the whole build process and qtcreator set up on a clean install of Ubuntu 20.04.1. Tested that I can run the executable from qtcreator, I can make changes and build with qtcreator. Cannot replicate the errors described.

Screen Shot 2021-03-05 at 3 08 28 PM

Here are some notes on setting up the project in qt creator:

Performing these steps should get you up and running. After verifying these steps, please let us know if this is still a problem.

benliepert commented 3 years ago

I tried with a clean install of Ubuntu 20.04 (virtualbox 6.1.18). I am able to build and run without issues in qtcreator. However, I have the same errors for almost every include:

file-not-found

This is my full system history:

    1  reboot
    2  sudo apt install gcc make
    3  cd /media/ben/
    4  ll
    5  cd VBox_GAs_6.1.18/
    6  ll
    7  ./VBoxLinuxAdditions.run 
    8  sudo ./VBoxLinuxAdditions.run 
    9  shutdown now
   10  sudo apt install git
   11  git clone git@github.com:bitcoin-core/gui.git
   12  git clone https://github.com/bitcoin-core/gui.git
   13  cd gui/
   14  ll
   15  sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3
   16  sudo apt-get install libevent-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev
   17  sudo apt install libsqlite3-dev
   18  sudo apt install libminiupnpc-dev libnatpmp-dev
   19  sudo apt-get install libzmq3-dev
   20  sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools
   21  sudo apt-get install libqrencode-dev
   22  ./contrib/install_db4.sh `pwd`
   23  history
   24  export BDB_PREFIX='/home/ben/gui/db4'
   25  ./autogen.sh
   26  ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --enable-debug
   27  make -j6
   28  sudo apt install qtcreator
   29  qtcreator &

After that, import existing project, title "bitcoin-qt", path /home/ben/gui/src/qt. Selected the forms folder and added to git. Compilers (GCC), debugger (GDB) and executable are set.

This is what my end of my ./configure output looks like:

Build Options:
  with ecmult precomp     = yes
  with external callbacks = no
  with benchmarks         = no
  with tests              = yes
  with openssl tests      = no
  with coverage           = no
  module ecdh             = no
  module recovery         = yes
  module extrakeys        = yes
  module schnorrsig       = yes

  asm                     = x86_64
  bignum                  = no
  ecmult window size      = 15
  ecmult gen prec. bits   = 4

  valgrind                = no
  CC                      = gcc
  CFLAGS                  = -O2 -fvisibility=hidden -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings -W -g
  CPPFLAGS                = 
  LDFLAGS                 = 

Options used to compile and link:
  external signer = no
  multiprocess    = no
  with libs       = yes
  with wallet     = yes
    with sqlite   = yes
    with bdb      = yes
  with gui / qt   = yes
    with qr       = yes
  with zmq        = yes
  with test       = yes
  with bench      = yes
  with upnp       = yes
  with natpmp     = yes
  use asm         = yes
  ebpf tracing    = no
  sanitizers      = 
  debug enabled   = yes
  gprof enabled   = no
  werror          = no

  target os       = linux
  build os        = linux-gnu

  CC              = gcc
  CFLAGS          = -pthread -g -O2
  CPPFLAGS        =  -DDEBUG -DDEBUG_LOCKORDER -DABORT_ON_FAILED_ASSUME   -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -DPROVIDE_FUZZ_MAIN_FUNCTION
  CXX             = g++ -std=c++17
  CXXFLAGS        =  -O0 -g3 -ftrapv  -fstack-reuse=none -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection  -Wall -Wextra -Wformat -Wformat-security -Wvla -Wswitch -Wredundant-decls -Wunused-variable -Wdate-time -Wsign-compare -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override  -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-deprecated-copy    -fno-extended-identifiers
  LDFLAGS         = -lpthread  -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -pie  
  ARFLAGS         = cr
jarolrod commented 3 years ago

In project->manage kits, what do you see under Qt versions?

benliepert commented 3 years ago

Under Manage Kits...->Kits->Desktop (default)-> Qt version: Qt 5.12.8 in PATH (System) There's also an option for Qt 5.12.8 in PATH (qt5)

jarolrod commented 3 years ago

@benliepert confirming I can replicate the issue with includes, [#1]() in OP is fixed by using gui/ as root instead of gui/src/qt, [#2]() is still an issue and may require what the OP states

benliepert commented 3 years ago

I'm editing my initial comment to avoid confusion, as I was wrong about resolving #2: it seems some Qt constructs aren't found/known but I can't see a consistent pattern

jarolrod commented 3 years ago

@hebasto I think this can be closed.

Upon the removal of the bitcoin-qt.pro file in https://github.com/bitcoin/bitcoin/pull/21695, it can be said that we do not actively promote the use of Qt Creator as an IDE. That being said it does provide a convenient way to make changes to the *.ui files, and the current instructions will get you to a point where you can do so.