Skip to content

Compile

mhtvsSFrpHdE edited this page Mar 27, 2023 · 8 revisions

Windows

  1. Go to ThirdParty folder and look at things like *.version.txt,
    install these correspond version library to somewhere compiler can know.
  2. Go to prefetch folder and check README.md,
    install correspond version Qt to somewhere compiler can know.
  3. If you want to run "collect minimal release of compiled binary" script, install correspond version python,
    otherwize python is not necessary to install.
  4. Build system depends on vscode,
    download and put these vscode config to your workspace folder.
  5. Rename c_cpp_propertiesExample.json to c_cpp_properties.json and modify path information inside.
  6. Rename launchExample.json to launch.json and modify path information inside.
  7. Open vscode, use build command (usually is Ctrl+Alt+B), select one of option you prefer.
    Qt build all release require python to success ("collect minimal release of compiled binary"),
    or the last step will fail, but it is safe to ignore.

Find compiled binary in one of these folders:

  • prefetch\qpp\build-prefetch-Desktop_x86_windows_mingw4_8_2_32bit-Debug
  • prefetch\qpp\build-prefetch-Desktop_x86_windows_mingw4_8_2_32bit-Release
  • ...
  • prefetch\qpp\Pack ("minimal release of compiled binary")

Linux

You need GCC 4.8.2 and Qt 4.8.7.
Due to Linux distribution actual situation

  • Only one version package is allowed to install at the same time
  • A package can be dependency to other package

A dynamically linked binary does not likely to work across different distribution.
Therefore, static link everything is required, include GCC and Qt.

Get GCC

I do not recommend trying to compile old GCC on new Linux distribution.
For example, Fedora 37 ship with GCC 12.2.1, and most likely compile GCC 4.8.2 will fail.
All the extra compile option tweak, or find old dependency,
may even compile dependency's dependency's dependency is waste of time.
You can spend three days and still failed to compile in the end.

Instead, go virtual box and install Fedora 21, the one ship with GCC 4.8.2,
but will update to 4.9.2 after dnf upgrade.

Compile GCC 4.8.2 with these steps, nice and easy.
https://gcc.gnu.org/wiki/InstallingGCC

  1. Download gcc https://ftp.gnu.org/gnu/gcc/gcc-4.8.2
    https://gcc.gnu.org/install/download.html
    https://gcc.gnu.org/releases.html
    https://gcc.gnu.org/mirrors.html
    https://www.gnu.org/prep/ftp.html
  2. Set system proxy if needed
    export http_proxy=http://<ip>:<port>/;export https_proxy=http://<ip>:<port>/
  3. Set wget download proxy if needed
    nano ~/.wgetrc
    use_proxy=yes
    http_proxy=<ip>:<port>
    https_proxy=<ip>:<port>
  4. Set dnf proxy if needed
    sudo nano /etc/dnf/dnf.conf
    proxy=http://<ip>:<port>
  5. Install dependency
    sudo dnf install zlib-devel glibc glibc-devel glibc.i686 glibc-devel.i686
    cd gcc-4.8.2
    ./contrib/download_prerequisites
  6. Switch to build folder
    cd ..
    mkdir build-gcc-4.8.2
    cd build-gcc-4.8.2
  7. Tell where to install, for example $HOME/program/GCC-4.8.2
    install to program directory under home directory
    $PWD/../gcc-4.8.2/configure LDFLAGS='--static' --enable-static --prefix=$HOME/<where to install>/GCC-4.8.2 --enable-multilib --with-system-zlib --enable-lto --enable-languages=c,c++
  8. Compile
    make -j <thread number>
    make install
  9. Set environment variable to replace system gcc
    export PATH=$HOME/<where to install>/GCC-4.8.2:$PATH
    If you want ccache to accelerate the second time compile speed
    put ccache in front of gcc and system $PATH
    export PATH=<ccache install folder>:$PATH

Get Qt

  1. Document that still alive for read
    https://het.as.utexas.edu/HET/Software/html/requirements-x11.html
    https://het.as.utexas.edu/HET/Software/html/install-x11.html
  2. Download Qt https://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.zip
    https://download.qt.io/archive/qt/4.8/4.8.7/
  3. Install dependency
    sudo dnf install fontconfig-devel freetype-devel libX11-devel libXcursor-devel libXext-devel libXfixes-devel libXft-devel libXi-devel libXrandr-devel libXrender-devel
  4. Tell where to install, for example $HOME/program/Qt/4.8.7
    cd qt-everywhere-opensource-src-4.8.7
    ./configure -static --prefix=$HOME/<where to install>/Qt/4.8.7
  5. Compile
    gmake -j <thread number>
    gmake install

Use Qt Creator

The rest is simple, install Qt Creator with sudo dnf install qt-creator,
then open project prefetch_qt_creator_3_4_2.pro,
configure it on GUI with GCC 4.8.2 and Qt 4.8.7 mentioned above.
Also check https://github.com/mhtvsSFrpHdE/prefetch/tree/master/qpp/prefetch#qmake-build-profile
to know how to build prefetch_performance, prefetch_verbose other than just prefetch.

Compiled binary should be static and be able to copy and run on Fedora 37.
The prefetch.ini and translate folder is still needed to put together with binary.

In the meanwhile, drag compiled Qt to Fedora 37 will not work because you don't have old version
fontconfig-devel freetype-devel libX11-devel libXcursor-devel libXext-devel libXfixes-devel libXft-devel libXi-devel libXrandr-devel libXrender-devel

Compile option

These option can either modify compile DEFINES or the file itself directly.
Disable a feature equal to delete related code, so they won't even appear in compiled EXE file,
instead of do if-else statement at runtime.

If you modified after build, you may need to delete exist build completely and rebuild.
Or the build system may not be able to detect changes.

https://github.com/mhtvsSFrpHdE/prefetch/raw/master/qpp/prefetch/Source/Define/define.h