qt开发在linux上使用eclipse? [英] qt development on linux using eclipse?

查看:106
本文介绍了qt开发在linux上使用eclipse?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,如何在Eclipse中创建QT应用程序?我已经在eclipse.org中看到了一些集成插件,但是似乎它们已经被停止了,不再受支持。



由于我将开发一个可能是开发了几年后,我想为此找到一个合适的解决方案。

解决方案

我如何做Linux + eclipse + Qt + CMake。



这个好东西,源码只是使用CMake,它们的构建就像是一个简单的CMake项目。你不会用eclipse的东西污染他们:eclipse工作区和项目文件在外面。



Qt




  • 获取最新的eclipse,然后通过帮助 - >安装新软件安装Qt包。


  • 在CMake项目源目录外创建一个空的工作区目录。


  • 启动eclipse并切换到该工作区目录。 li>

  • 创建C ++ - > Makefile项目 - > Qt Makefile项目。


  • 删除* .pro文件,makefile来自




来源




  • 转到项目属性 - >路径和符号 - >源位置 - >链接文件夹。


  • 检查高级并链接到CMake项目的源文件夹: ../../ myproject / 。它的工作原理是工作区位于CMake项目目录之外。




CMake generator




  • 在项目中创建发布文件夹。


  • 转到使目标视图(Ctrl + 3,然后键入设定目标,如果很难找到)。 目标视图看起来就像项目视图。


  • 右键单击发布文件夹和新建...。


  • 取消选中与目标名称相同,取消选中使用构建器设置。


  • 释放到目标名称字段中,将使目标留空,构建命令就像cmake ../../../myproject/一样。点击确定。


  • 双击刚刚在Release文件夹中创建的Releasemake目标。它应该运行cmake。




构建




  • 转到项目属性,创建发布配置。


  • 使发布配置处于活动状态。

    li>
  • 对于发布配置,请取消选中自动生成Makefile。


  • 将Build目录设置为Release。


  • 启用并行构建。




应该现在在Release目录中构建。如果没有,请从Release目录中删除所有内容,然后通过双击Make Target视图中的Release目标重新运行cmake。



我使用的 CMakeLists.txt 的模板: https:// stackoverflow .com / a / 36181462/4742108



CMakeLists编辑是手动完成的。所以您可以与任何人协作,因为构建软件,他们只需要源文件和 CMakeLists.txt 。 (CMake是最广泛的C ++构建系统之一)


In Linux, How can I create QT applications in Eclipse? I've seen some integration plugins in eclipse.org however it seems they are discontinued and not supported anymore.

Since I'm going to develop a project which it may be developed for some years from now, I want to find a suitable solution for this.

解决方案

How I do Linux + eclipse + Qt + CMake.

The good thing about it that the sources just use CMake, they are built like if it was just a plain CMake project. And you don't pollute them with the eclipse stuff: the eclipse workspace and project files are outside.

Qt

  • Get latest eclipse and then install the Qt package in it through "Help -> Install New Software".

  • Create an empty "workspace" directory outside the CMake project source directory.

  • Launch eclipse and switch to that "workspace" directory.

  • Create a C++ -> Makefile Project -> Qt Makefile Project.

  • Delete *.pro file, makefile and main.cpp from it.

Sources

  • Go to Project Properties -> Paths and Symbols -> Source Location -> Link Folder.

  • Check "Advanced" and link the source folder of CMake project like that: ../../myproject/. It works because the workspace is just outside the CMake project directory.

CMake generator

  • Create Release folder in the project.

  • Go to "Make Target" view (Ctrl+3 and then type "Make Target" if it's hard to find). "Make Target" view looks just like the project view.

  • Right click on the "Release" folder and "New...".

  • Uncheck "Same as target name", uncheck "Use builder settings".

  • Type in "Release" into "Target name" field, leave "Make target" empty, "Build command" is something like "cmake ../../../myproject/". Click ok.

  • Double click on this "Release" make target that was just created in the Release folder. It should run cmake.

Build

  • Go to Project Properties, create "Release" configuration.

  • Make "Release" configuration active.

  • For "Release" configuration uncheck "Generate Makefiles automatically".

  • Set Build directory to "Release".

  • Enable parallel build.

It should build now in "Release" directory. If it doesn't, remove all from the "Release" directory and rerun cmake by double-clicking on "Release" target in the "Make Target" view as before.

The template for a CMakeLists.txt that I use: https://stackoverflow.com/a/36181462/4742108

CMakeLists editing is done by hand. So you can collaborate with anyone, because to build the software they only need the source files and CMakeLists.txt. (CMake is one of the most wide-spread C++ build systems)

这篇关于qt开发在linux上使用eclipse?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆