简体   繁体   English

使用Makefile.am/Makefile.in在Ubuntu Linux中构建c ++项目

[英]Building c++ project in Ubuntu Linux with Makefile.am/Makefile.in

I am new in Ubuntu/Linux and I've been working with java using the NetBeans IDE, so I don't have much experience with building c++ projects. 我是Ubuntu / Linux的新手,并且我一直在使用NetBeans IDE处理Java,所以我在构建c ++项目方面没有太多经验。 But now I have to provide a proof of concept and I need to connect a C++ client with my ActiveMQ server. 但是现在我必须提供概念证明,并且需要将C ++客户端与ActiveMQ服务器连接。 I downloaded The ActiveMQ-CPP API from this link , but I can't build/run it. 我从此链接下载了ActiveMQ-CPP API,但无法构建/运行它。

The download came with the files: Maklefile.am and Makefile.in. 下载随附文件:Maklefile.am和Makefile.in。 I searched it and I found that I need automake/autoconf to build it. 我搜索了它,发现我需要automake / autoconf来构建它。 I tried running ./configure but it says that it couldn't find such file or directory. 我尝试运行./configure,但它说找不到这样的文件或目录。 I tried 我试过了

sudo apt-get update
sudo apt-get install automake
sudo apt-get install autoconf

and a lot of other commands that I found on the Internet. 以及我在Internet上找到的许多其他命令。 None of then worked. 没有一个工作。 I know that this question is really basic and it seems to be already answered somewhere else, but every attempt I've made failed. 我知道这个问题确实很基本,似乎已经在其他地方得到了回答,但是我所做的每一次尝试都失败了。 I think I'm missing something. 我想我缺少了一些东西。 I even tried the solution provided in the last message in this topic but it didn't work either. 我什至尝试了本主题中最后一条消息中提供的解决方案,但该解决方案也不起作用。

Can anyone help me install autoconf/automake, or tell me how to use Makefile.am / Makefile.in to build the project I downloaded, or even suggest me some other way of building it? 谁能帮助我安装autoconf / automake,或告诉我如何使用Makefile.am / Makefile.in来构建我下载的项目,甚至建议我以其他方式构建它吗?

Since you're open to other methods of building your project, I'm going to suggest CMake. 由于您对构建项目的其他方法持开放态度,因此我建议使用CMake。 It is a far better build system than autotools (at least from where I stand). 它比自动工具(至少从我所处的位置) 好得多。

#CMakeLists.txt
project(MyProject CXX)
set_minimum_required(VERSION 2.8)
add_executable(foobar foo.cpp bar.cpp)

That example will build an executable called "foobar" by compiling and linking foo.cpp and bar.cpp. 该示例将通过编译和链接foo.cpp和bar.cpp来构建名为“ foobar”的可执行文件。 Put the above code in a file called CMakeLists.txt, then run the following commands: 将上面的代码放入一个名为CMakeLists.txt的文件中,然后运行以下命令:

cmake <path to project> #run in the folder you want to build in
make #this does the actual work

The really cool thing about CMake is that it generates a build system (Makefiles by default) but you can use it to generate project files for Eclipse, a Visual Studio solution, and a bunch of other things. CMake的真正妙处在于它会生成一个构建系统(默认情况下为Makefiles),但是您可以使用它为Eclipse,Visual Studio解决方案以及其他一些东西生成项目文件。 If you want more information, I'd check out their documentation . 如果您需要更多信息,请查看他们的文档

The "configure" script should be in your ActiveMQ-cpp source directory. “配置”脚本应位于您的ActiveMQ-cpp源目录中。 From the Linux command line, you should be able to: 从Linux命令行,您应该能够:

1) "cd" into your ActiveMQ* directory 1)“ cd”到您的ActiveMQ *目录中

2) "ls -l" to see the "configure" script 2)在“ ls -l”中查看“配置”脚本

3) "./configure" to set things up for building the library\\ 3)使用“ ./configure”设置内容以构建库\\

4) "make" to actually build the library 4)“ make”实际建立库

This is mentioned in comments, but this particular point of confusion has been common for well over a decade and I think needs to be clarified as often as possible. 评论中提到了这一点,但是这种特殊的混淆点已经存在了十多年了,我认为需要尽可能多地加以澄清。 You DO NOT need to have autoconf or automake installed to build a project that used those tools. 您不需要安装autoconf或automake即可构建使用这些工具的项目。 The entire point of the autotools is to generate a build system that will build on a system using only the standard tools (make, ac compiler, sh, and few others.) Unfortunately, many developers release tarballs that do not build cleanly. 自动工具的全部目的是生成一个构建系统,该系统将仅使用标准工具(make,ac编译器,sh和其他一些工具)在系统上构建。不幸的是,许多开发人员发布的tarball并非干净构建。 If you unpack the tarball and it does not contain a configure script, or if the configure script is broken, that is a bug in the package. 如果解压缩tarball并没有包含配置脚本,或者配置脚本损坏,则说明软件包中存在bug。 The solution is absolutely not to install autoconf/automake/libtool and try to produce a working configure script. 解决方案是绝对不要安装autoconf / automake / libtool并尝试生成有效的配置脚本。 The solution is to report the build error as a bug to the package maintainer. 解决方案是将生成错误作为错误报告给软件包维护者。

The world would be a better place if Linux distributions stopped installing multiple versions of the autotools by default as less than .002% of the population needs those tools, and anyone who actually needs to have the tools should be capable of installing it themselves. 如果Linux发行版默认情况下停止安装多个版本的自动工具,这将是一个更好的地方,因为只有不到.002%的人口需要这些工具,而实际上需要这些工具的任何人都应该能够自行安装。 Anyone incapable of acquiring and installing the tools has no business using them. 任何无法获得和安装工具的人都不会使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM