ubuntu下編譯為知筆記


先把為知筆記官方的教程放在前面

一、 准備環境

Linux (Ubuntu)

Qt

安裝 5.7.0 for Linux 64-bit (715 MB) 或者更高版本
http://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-linux-x64-5.7.0.run
下載下來的安裝文件,更改權限為可執行,然后執行安裝程序。不要用管理員權限安裝,直接安裝到home目錄即可,例如~/Qt5.7.0

Git

  1. sudo apt-get install git

編譯工具

  1. sudo apt-get install build-essential

CMake

  1. sudo apt-get install cmake

zlib

    1. sudo apt-get install zlib1g-dev

二、Clone為知筆記源代碼

可以直接clone。然后切換到分支v2.4.0或者更新的分支。也可以直接使用master分支(通常代碼不是最新的)

對於Mac/Linux,可以在終端中運行:

  1. cd ~
  2. mkdir WizTeam
  3. cd WizTeam
  4. git clone https://github.com/WizTeam/WizQTClient.git
  5. cd WizQTClient
  6. git checkout v2.4.4

三、編譯源代碼

運行QtCreator,選擇打開~/WizTeam/WizQTClient/CMakeLists.txt這個文件

注:通常QtCreator在安裝路徑下面的Tools/QtCreator/bin這個文件夾里面

如果出現運行CMake對話框,在參數中,輸入下面的參數:(如果不設置參數,則會按照Release方式編譯)。

  1. -DCMAKE_BUILD_TYPE=Debug

點擊安裝Run CMake,此時將會開始配置工程。等待1分鍾左右后,如果沒有錯誤,Done按鈕將可以點擊。點擊Done(Finish)按鈕。

如果沒有出現 CMake 對話框,在QtCreator左側導航欄,點擊左下角Project構建按鈕,選擇 Build Debug->Run WizNote,然后點擊左下角Build按鈕,就可以開始編譯WizNote源代碼了。

幾分鍾后,就可以開始調試或者運行為知筆記客戶端了。

若出現錯誤:No CMAKE_CXX_COMPILER could be found. mac qt

點擊「項目」,打開「構建設置」,在 CMake 構建目錄中添加以下兩個參數,重新構建即可:
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++

 

Let's GO

在下載的時候安裝其他的軟件,順利

yongqian@yongqian-ThinkPad-T450s:~$ sudo apt-get install git
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關系樹       
正在讀取狀態信息... 完成       
將會同時安裝下列軟件:
  git-man liberror-perl
建議安裝:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-cvs git-mediawiki git-svn
下列【新】軟件包將被安裝:
  git git-man liberror-perl
升級了 0 個軟件包,新安裝了 3 個軟件包,要卸載 0 個軟件包,有 99 個軟件包未被升級。
需要下載 3,823 kB 的歸檔。
解壓縮后會消耗 25.6 MB 的額外空間。
您希望繼續執行嗎? [Y/n] y
獲取:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB]
獲取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.1 [735 kB]
獲取:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.1 [3,068 kB]
已下載 3,823 kB,耗時 4秒 (945 kB/s)
正在選中未選擇的軟件包 liberror-perl。
(正在讀取數據庫 ... 系統當前共安裝有 219466 個文件和目錄。)
正准備解包 .../liberror-perl_0.17-1.2_all.deb  ...
正在解包 liberror-perl (0.17-1.2) ...
正在選中未選擇的軟件包 git-man。
正准備解包 .../git-man_1%3a2.7.4-0ubuntu1.1_all.deb  ...
正在解包 git-man (1:2.7.4-0ubuntu1.1) ...
正在選中未選擇的軟件包 git。
正准備解包 .../git_1%3a2.7.4-0ubuntu1.1_amd64.deb  ...
正在解包 git (1:2.7.4-0ubuntu1.1) ...
正在處理用於 man-db (2.7.5-1) 的觸發器 ...
正在設置 liberror-perl (0.17-1.2) ...
正在設置 git-man (1:2.7.4-0ubuntu1.1) ...
正在設置 git (1:2.7.4-0ubuntu1.1) ...
yongqian@yongqian-ThinkPad-T450s:~$ sudo apt-get install build-essential
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關系樹       
正在讀取狀態信息... 完成       
build-essential 已經是最新版 (12.1ubuntu2)。
升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 99 個軟件包未被升級。
yongqian@yongqian-ThinkPad-T450s:~$ sudo apt-get install cmake
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關系樹       
正在讀取狀態信息... 完成       
將會同時安裝下列軟件:
  cmake-data libjsoncpp1
建議安裝:
  codeblocks eclipse ninja-build
下列【新】軟件包將被安裝:
  cmake cmake-data libjsoncpp1
升級了 0 個軟件包,新安裝了 3 個軟件包,要卸載 0 個軟件包,有 99 個軟件包未被升級。
需要下載 3,817 kB 的歸檔。
解壓縮后會消耗 20.5 MB 的額外空間。
您希望繼續執行嗎? [Y/n] y
獲取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 cmake-data all 3.5.1-1ubuntu3 [1,121 kB]
獲取:2 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libjsoncpp1 amd64 1.7.2-1 [73.0 kB]
獲取:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 cmake amd64 3.5.1-1ubuntu3 [2,623 kB]
已下載 3,817 kB,耗時 3秒 (1,052 kB/s)
正在選中未選擇的軟件包 cmake-data。
(正在讀取數據庫 ... 系統當前共安裝有 220280 個文件和目錄。)
正准備解包 .../cmake-data_3.5.1-1ubuntu3_all.deb  ...
正在解包 cmake-data (3.5.1-1ubuntu3) ...
正在選中未選擇的軟件包 libjsoncpp1:amd64。
正准備解包 .../libjsoncpp1_1.7.2-1_amd64.deb  ...
正在解包 libjsoncpp1:amd64 (1.7.2-1) ...
正在選中未選擇的軟件包 cmake。
正准備解包 .../cmake_3.5.1-1ubuntu3_amd64.deb  ...
正在解包 cmake (3.5.1-1ubuntu3) ...
正在處理用於 man-db (2.7.5-1) 的觸發器 ...
正在處理用於 libc-bin (2.23-0ubuntu9) 的觸發器 ...
正在設置 cmake-data (3.5.1-1ubuntu3) ...
正在設置 libjsoncpp1:amd64 (1.7.2-1) ...
正在設置 cmake (3.5.1-1ubuntu3) ...
正在處理用於 libc-bin (2.23-0ubuntu9) 的觸發器 ...
順利完成:)))))))))

 

clone 順利

checkout 2。5。5 順利

qt編譯 報錯

Failed to find "GL/gl.h" in "/usr/include/libdrm"

try

{

sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev 順利完成

try again

 

}

順利完成

qt 輸出

{

Running "/usr/bin/cmake /home/yongqian/WizNote/WizQTClient '-GCodeBlocks - Unix Makefiles' -DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++ -DQT_QMAKE_EXECUTABLE:STRING=/home/yongqian/Qt5.7.0/5.7/gcc_64/bin/qmake" in /tmp/qtc-cmake-s5sMQw.

-- The C compiler identification is GNU 5.4.0

-- The CXX compiler identification is GNU 5.4.0

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: /usr/bin/g++

-- Check for working CXX compiler: /usr/bin/g++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Performing Test COMPILER_SUPPORTS_CXX11

-- Performing Test COMPILER_SUPPORTS_CXX11 - Success

-- Performing Test COMPILER_SUPPORTS_CXX0X

-- Performing Test COMPILER_SUPPORTS_CXX0X - Success

-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

-- Looking for sys/types.h

-- Looking for sys/types.h - found

-- Looking for stdint.h

-- Looking for stdint.h - found

-- Looking for stddef.h

-- Looking for stddef.h - found

-- Check size of off64_t

-- Check size of off64_t - done

-- Looking for fseeko

-- Looking for fseeko - found

-- Looking for unistd.h

-- Looking for unistd.h - found

ZLIB not found, using internal: /home/yongqian/WizNote/WizQTClient/lib/zlib

CMake Error at /home/yongqian/Qt5.7.0/5.7/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):

Failed to find "GL/gl.h" in "/usr/include/libdrm".

Call Stack (most recent call first):

/home/yongqian/Qt5.7.0/5.7/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:146 (include)

/home/yongqian/Qt5.7.0/5.7/gcc_64/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:87 (find_package)

/home/yongqian/Qt5.7.0/5.7/gcc_64/lib/cmake/Qt5/Qt5Config.cmake:26 (find_package)

cmake/QtChooser.cmake:1 (find_package)

lib/quazip/CMakeLists.txt:6 (include)

 

 

-- Configuring incomplete, errors occurred!

See also "/tmp/qtc-cmake-s5sMQw/CMakeFiles/CMakeOutput.log".

*** cmake process exited with exit code 1.

Running "/usr/bin/cmake /home/yongqian/WizNote/WizQTClient '-GCodeBlocks - Unix Makefiles' -DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++ -DQT_QMAKE_EXECUTABLE:STRING=/home/yongqian/Qt5.7.0/5.7/gcc_64/bin/qmake" in /tmp/qtc-cmake-c4Vg32.

-- The C compiler identification is GNU 5.4.0

-- The CXX compiler identification is GNU 5.4.0

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: /usr/bin/g++

-- Check for working CXX compiler: /usr/bin/g++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Performing Test COMPILER_SUPPORTS_CXX11

-- Performing Test COMPILER_SUPPORTS_CXX11 - Success

-- Performing Test COMPILER_SUPPORTS_CXX0X

-- Performing Test COMPILER_SUPPORTS_CXX0X - Success

-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

-- Looking for sys/types.h

-- Looking for sys/types.h - found

-- Looking for stdint.h

-- Looking for stdint.h - found

-- Looking for stddef.h

-- Looking for stddef.h - found

-- Check size of off64_t

-- Check size of off64_t - done

-- Looking for fseeko

-- Looking for fseeko - found

-- Looking for unistd.h

-- Looking for unistd.h - found

ZLIB not found, using internal: /home/yongqian/WizNote/WizQTClient/lib/zlib

-- /home/yongqian/WizNote/WizQTClient/resources/wiznote.qrc

WizNote whill compiling as Release, use Qt: 5.7.0

-- Configuring done

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in src/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

CMake Warning (dev) in lib/quazip/CMakeLists.txt:

Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.

Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

 

-- Generating done

CMake Warning:

Manually-specified variables were not used by the project:

 

QT_QMAKE_EXECUTABLE

 

 

-- Build files have been written to: /tmp/qtc-cmake-c4Vg32

}

 

嘗試run一下,經過很長時間的等待,我的機器上大概2分鍾

報錯:

/home/yongqian/WizNote/WizQTClient/lib/quazip/zip.h:56: error: zlib.h: No such file or directory

 

看來是忘記了 這個:::

  1. sudo apt-get install zlib1g-dev

{ sudo apt-get install zlib1g-dev
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關系樹       
正在讀取狀態信息... 完成       
將會同時安裝下列軟件:
  zlib1g
下列【新】軟件包將被安裝:
  zlib1g-dev
下列軟件包將被升級:
  zlib1g
升級了 1 個軟件包,新安裝了 1 個軟件包,要卸載 0 個軟件包,有 98 個軟件包未被升級。
需要下載 219 kB 的歸檔。
解壓縮后會消耗 424 kB 的額外空間。
您希望繼續執行嗎? [Y/n] y
獲取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g amd64 1:1.2.8.dfsg-2ubuntu4.1 [51.2 kB]
獲取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB]
已下載 219 kB,耗時 0秒 (820 kB/s)  
(正在讀取數據庫 ... 系統當前共安裝有 224086 個文件和目錄。)
正准備解包 .../zlib1g_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb  ...
正在將 zlib1g:amd64 (1:1.2.8.dfsg-2ubuntu4.1) 解包到 (1:1.2.8.dfsg-2ubuntu4) 上 ...
正在處理用於 libc-bin (2.23-0ubuntu9) 的觸發器 ...
正在設置 zlib1g:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
正在處理用於 libc-bin (2.23-0ubuntu9) 的觸發器 ...
正在選中未選擇的軟件包 zlib1g-dev:amd64。
(正在讀取數據庫 ... 系統當前共安裝有 224086 個文件和目錄。)
正准備解包 .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb  ...
正在解包 zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
正在處理用於 man-db (2.7.5-1) 的觸發器 ...
正在設置 zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
yongqian@yongqian-ThinkPad-T450s:~/WizNote/WizQTClient$

}

 

and then……

再一次編譯,好激動

成功嘍

彈出了登錄的界面


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM