ubuntu下编译为知笔记

Posted 元亨利贞

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

在下载的时候安装其他的软件,顺利

[email protected]:~$ 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) ...
[email protected]:~$ sudo apt-get install build-essential
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
build-essential 已经是最新版 (12.1ubuntu2)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 99 个软件包未被升级。
[email protected]:~$ 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) ...
[email protected]:~/WizNote/WizQTClient$

}

 

and then……

再一次编译,好激动

成功喽

弹出了登录的界面













































































































以上是关于ubuntu下编译为知笔记的主要内容,如果未能解决你的问题,请参考以下文章

WizNote编译

WSL下编译OpenWrt/LEDE笔记

Ubuntu12下编译安装PHP5.3开发环境

如何在linux/ubuntu下编写c++网络通信代码

ubuntu环境下编译bitcoin(比特币)全过程

Ubuntu下编译AOSP步骤