C ++构建过程 [英] C++ Build Process

查看:52
本文介绍了C ++构建过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从事开源C ++项目。我没有太多的C ++经验,因为我的日常工作主要涉及Java。我现在计划发布我的C ++项目,我想知道我应该如何安排我的项目的包装。例如,在Java中,所有类文件都打包到jar文件中。那么C ++中的等效方法是什么?是否有组织源代码/二进制文件的良好实践?顺便说一下,我的目标平台是Linux。

I am currently working on an opensource C++ project. I don't have much experience in C++ as my daily job mainly involves with Java. I am now planning to release my C++ project and I would like to know how should I should I arrange the packaging of my project. E.g, in Java, all the class files are packaged into jar file. So what is the equivalent approach in C++? Is there any good practise for organizing the source code/binary? My target platform is Linux by the way.

另一个问题是我目前正在使用Eclipse CDT插件进行开发和构建。因此,无论如何,我可以从Eclipse项目中提取构建脚本并将其用作通用构建脚本吗?关于C ++构建/打包有什么好的参考吗?提前致谢。

Another question is I am currently using Eclipse CDT plugin for development and building. So is there anyway that I can extract build script from Eclipse project and use it as generic build script? Is there any good reference regarding C++ build/packaging? Thanks in advance.

编辑

我想澄清一点我发布的项目可以视为应用程序。这是用于软件配置管理的命令行工具。

To clarify a bit more, I think the release of my project can be considered as an application. It's a command line tool for software configuration management.

推荐答案


我目前正在使用开源C ++项目。

I am currently working on an opensource C++ project.

这简化了很多事情。您应该为您的项目提供构建脚本,并为不同的用例提供支持(了解Makefile,了解类似 target的概念)。

That simplifies many things. You should supply the build scripts for you project and support them for different use cases (learn about Makefiles, there are similar concepts like "target").


我在C ++方面经验不足,因为我的日常工作主要涉及Java。

I don't have much experience in C++ as my daily job mainly involves with Java.

大多数事情因为C / C ++缺乏Java,所以曾经发明过Java(现在要求)。至少了解有关动态(共享)/静态库(简单的.so和.a文件)的知识。

Most of the things you're used to have (and ask for right now) in Java are invented because they lack in C/C++. Learn at least something about dynamic(shared)/static libraries (.so and .a files to be simple).


我现在正在计划释放我的C ++项目,我想知道应该如何安排我的项目的打包。

I am now planning to release my C++ project and I would like to know how should I should I arrange the packaging of my project.

一个C ++项目是非正式的。您可以为著名的IDE提供源代码,构建脚本和一些项目文件。

The "packaging of a C++ project" is something informal. You may supply the sources, build scripts and some project-files for the well-known IDEs.

编辑:您已指定要构建命令行。应用。我相信您所需要的只是从针对该应用程序的简单Makfile开始。 Eclipse可以自动生成参考Makefile。如果您打算将应用程序部署为独立软件,则必须赚取打包费用(rpm,deb,tgz)。

you've specified that you're building the command-line application. I believe all you need is to start from a simple Makfile for that application. The reference Makefile can be automatically generated by Eclipse. If you are planning to deploy your application as a stand-alone software, then you have to earn about packaging (rpm, deb, tgz).


例如,在Java中,所有类文件都打包到jar文件中。

E.g, in Java, all the class files are packaged into jar file.

没有C ++包这样的东西兼容的跨编译器(甚至模块在最新的C ++ 11标准中也被拒绝)
,因为没有二进制标准可以编码C ++类(ABI)。在Linux上,您最有可能会使用GCC(或Intel的编译器或LLVM的CLang或OpenWatcom的自定义版本或...),
,但要链接的标准库的版本使二进制文件得以发布建立几乎没有用。
这就是重新分配源代码的原因。

There are no such thing as a C++ "package" compatible accross compilers (even the "modules" were rejected in the latest C++11 standard) because there is no binary standard to encode C++ classes (ABI). On linux you're most likely going to use GCC (or Intel's compiler, or LLVM's CLang, or custom build of OpenWatcom or...), but the version of standard library you are linking to makes the release of binary builds close to useless. That is the reason for redistibuting source code.


那么C ++中的等效方法是什么?

So what is the equivalent approach in C++?

此处无明确答案。


有没有好的做法是否组织源代码/二进制文件?

Is there any good practise for organizing the source code/binary?

看看大型项目,看看他们组织构建的方式。 建筑工程师这一职业强调了大型项目的编译/链接的困难。

Look at the large-scale projects, see the way they organize their builds. The term "build engineer" as an occupation emphasizes the difficulties of large-scale projects compilation/linking.


我的目标平台是Linux方式。

My target platform is Linux by the way.

这也是一个不完整的描述。 Linux是一个模糊的术语。您应该谈论Linux发行版,编译器工具链和包管理器。例如,Ubuntu 12,amd64,GCC 4.6工具链,APT软件包管理器。

This is also something of an incomplete description. "Linux" is a blurry term. You should speak about the Linux distribution, compiler toolchain and package manager. E.g., Ubuntu 12, amd64, GCC 4.6 toolchain, APT package manager.

围绕相同的内核源构建了不同的 Linux。有不同的编译器。至少要考虑三个主要的软件包管理器:Debian / Ubuntu(deb,apt),Red Hat(rpm),Slackware(tgz)。

There are different "linuxes" built around the same kernel source. There are different compilers. There are at least three major package managers to consider: Debian/Ubuntu(deb,apt), Red Hat(rpm), Slackware(tgz).


另一个问题是我目前正在使用Eclipse CDT插件进行开发和构建。所以无论如何,我可以从Eclipse项目中提取构建脚本

Another question is I am currently using Eclipse CDT plugin for development and building. So is there anyway that I can extract build script from Eclipse project

有一种元技术:您写了一个项目,然后工具会为您的源生成项目文件并生成脚本。看看 CMake 。由于您使用的是 Linux,请尝试查看自动工具(autoconf)的一些标准方法。

There's a sort of "meta-technique": you write a "description" of your project and then a tool generates the project-file and build scripts for your sources. Have a look at CMake. Since you're on "linux", try looking at the somewhat standard way of autotools (autoconf).


关于此工具,有什么好的参考资料吗? C ++构建/打包?

Is there any good reference regarding C++ build/packaging?

您应该首先构建应用程序,然后再处理部署问题。 C / C ++是难以学习的遗产,具有许多精妙之处,而Java则避免了这些细节。

You should start by building your application and then move on to the deployment issues. C/C++ is a hard-to-learn legacy with a lot of subtleties which are avoided in Java.

这篇关于C ++构建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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