Skip to content

Commit

Permalink
doc: exactly how to build GD in local machine (#1675)
Browse files Browse the repository at this point in the history
shenlebantongying authored Jul 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3f6cfb8 commit b795818
Showing 4 changed files with 97 additions and 32 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/PR-check-cmake.yml
Original file line number Diff line number Diff line change
@@ -10,11 +10,6 @@ on:
- master
- experimental
- staged
paths-ignore:
- "docs/**"
- "*.md"
- "locale/**"
- "website/**"
jobs:
job_ubuntu_build_check:
name: ubuntu Build and analyze
118 changes: 94 additions & 24 deletions website/docs/developer.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,104 @@
Developing GoldenDict is not hard.
If you know some C++ and optionally some Qt, you can start to modify GoldenDict right now.

If you know some C++ and optionally some Qt, you can start to modify GoldenDict right now:
This page is a brief introduction on how to get started.

## Install Qt and QtCreator
(On Linux, install dependencies)
For technical details see [how to build from source](howto/build_from_source.md).

## 1. Install Qt

To install Qt on macOS or Windows, uses the [Qt Online Installer](https://doc.qt.io/qt-6/get-and-install-qt.html). It can be downloaded from [Qt for Open Source](https://www.qt.io/download-open-source).

Those Qt components are needed

+ Qt
+ 6.7.2 (Or another version)
+ MSVC 2019 (or MSVC 2022)
+ Qt5 Compatible Module
+ Additional Libraries
+ Qt Image formats
+ Qt MultiMedia
+ Qt Positioning
+ Qt SerialPort (? super weird here, but it is needed.)
+ Qt Speech
+ Qt Webchannel
+ Qt Webengine
+ Qt Creator (optional)
+ CMake
+ Ninja

Note that MinGW is not supported.

CMake and Ninja are needed.

## 2. Install a compiler

For windows, MSVC can be obtained by [installing Visual Studio's "Desktop development with C++"](https://learn.microsoft.com/cpp/build/vscpp-step-0-installation).

For macOS, install [XCode](https://developer.apple.com/xcode/).

## 3. Obtain dependencies

For Windows, prebuilt libraries will be automatically downloaded.

For macOS, install [Homebrew](https://brew.sh/) and install related packages as described in [how to build from source](howto/build_from_source.md) or search `brew install` command in [macOS release's build file](https://github.com/xiaoyifang/goldendict-ng/blob/staged/.github/workflows/release-macos-homebrew.yml).

## 4. Build

First, get GoldenDict's source code by [Cloning a repository](https://docs.github.com/repositories/creating-and-managing-repositories/cloning-a-repository).

Then choose your favorite IDE/editor and load the `CMakeLists.txt`. If unsure, just use Qt Creator.

### Qt Creator

Open `CMakeLists.txt` from Qt Creator, then you wil choose a "Kit" which is pretty much a Qt installation.

Qt Creator usually can auto detect your Qt installation. In case it doesn't, check out "Kit" settings. Note that, the compiler must be set to MSVC on Windows.

By default everything will be built, you can disable ffmpeg, epwing...

![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/49f6a85e-50ec-4467-b0e4-cf088d218053)

Then, hit the "Run" button at bottom-right corner should build and run GoldenDict.

### Command Line only
See [how to build from source](howto/build_from_source.md).

[Qt's doc: Building projects on the command line](https://doc.qt.io/qt-6/cmake-build-on-cmdline.html)

### Visual Studio
VS2022 has CMake support. After opening the source code folder, VS will starts to configure CMake but likely won't succeed.

You need to add Qt's path and other options to "CMake command arguments". Then, "save" the dialog with Ctrl+S or click one of the many "(re)configure cache" buttons.

![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/33a52c52-2e8a-4b8c-bb05-4a753f95ff7e)

Click run will build the project, but the `.exe` would not run, because the dependencies are not copied.

Simply click "install", which is actually copying dependencies.

![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/02e843b1-0842-445c-919c-75618346aaaf)

### Visual Studio Code

Install [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools).

Then open GoldenDict's folder, and the CMake extension will kicks in.

Then add Qt's path and various other options to configure arguments.

Windows(qtcreator for example)
### Prerequisite
Install visual studio community ,choose C++ component.

QtCreator Packages:
```
[x]qtX.X.X version
[x]MSVC2019 /GCC
[x]Qt5 Compatible Module
[*]Additional
[x]Qt Image formats
[x]Qt MultiMedia
[x]Qt Positioning
[x]Qt speech
[x]Qt webchannel
[x]Qt webengine
-DCMAKE_PREFIX_PATH={Your Qt install path}\6.7.2\msvc2019_64
```

## Coding Standards
![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/bd87155e-2e61-41d5-81e2-7bfb1f13c4c4)

Please follow [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) and write modern C++ code.
### CLion
### XCode
### CMake GUI
### LSP + Editor?

Commit messages should follow [Conventional Commits](https://www.conventionalcommits.org)
## Related Things

Reformat changes with `clang-format` [how to use clang-format](https://github.com/xiaoyifang/goldendict/blob/staged/howto/how%20to%20use%20.clang-format%20to%20format%20the%20code.md)
Please follow [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) and write modern C++ code.

Remember to enable `clang-tidy` support on your editor so that `.clang-tidy` will be respected.
[Qt's documentation](https://doc.qt.io/)
4 changes: 2 additions & 2 deletions website/docs/howto/build_from_source.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
The `release-*` and `PR-check-*` workflow files under `.github` in the source code has actual build & commands for reference.

## Dependencies

* C++17 compiler (For windows it must be MSVC)
@@ -46,8 +48,6 @@ cmake --build build_dir
cmake --install ./build_dir/
```

The `release-*` and `PR-check-*` workflow files under `.github` in the source code has actual build & commands for reference.

### Feature flags

Append `-D{flag_names}=ON/OFF` to cmake's config step.
2 changes: 1 addition & 1 deletion website/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ nav:
- Report Bugs & Feedbacks: feedbacks.md
- Development Info:
- Start develop: developer.md
- Architecture: architecture.md
- Build from source: howto/build_from_source.md
- Architecture: architecture.md
- Customize the opencc: howto/how to customize the opencc.md
- Use .clang-format: howto/how to use .clang-format to format the code.md
- Breadpad crash analysis: howto/how to use breadpad crash analysis.md

0 comments on commit b795818

Please sign in to comment.