带有多个标题和名称空间的makefile [英] makefile with multiple headers and namespace

查看:70
本文介绍了带有多个标题和名称空间的makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有各种源文件的公共c ++软件包.
我编译了main.cpp,它引用了各种头文件,并使用带有以下代码的用户定义的名称空间:

I am using a public c++ package that has various source files.
I compiled main.cpp which refers to various headers and uses a user-defined namespace with following code:

g++ -g main.cpp nmssmsoftsusy.cpp decays.cpp /path/config.h -o main

其中main.cpp是

where main.cpp is

#include "main.h"
#include "nmssmsoftsusy.h"
#include "decays.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

using namespace softsusy;

int main() {
  /// Sets up exception handling
  signal(SIGFPE, FPE_ExceptionHandler); 

然后我遇到了诸如以下的错误

Then I got errors such as

对"FPE_ExceptionHandler(int)"的未定义引用

undefined reference to `FPE_ExceptionHandler(int)'

即使我将.h更改为.cpp文件或包括softsusy.h,也存在此类错误.

There are several errors of this kind even after I change .h to .cpp files or including softsusy.h.

我可以问您我的编译命令中的错误源或对我下次可以尝试的makefile中的内容的建议吗?

Can I ask you for the source of error in my compile command or for a suggestion of contents in makefile that i can try next time?

请注意,我是第一次使用makefile运行代码,如果您给我或建议我简要介绍如何组织makefile,这将是惊人的.谢谢.

Please notice that I am new to run the code using makefile and it would be amazing if you give or suggest me a brief explanation of how to organize makefile. Thanks.

推荐答案

首先,您必须编译包本身并获取库,以后程序会将其链接到这些库:

First you have to compile the package itself and get the libraries, which your program link against later:

您必须做什么:

aclocal
./configure
make

之后,您将拥有很多这样的库(静态库)

After that you have a lot of libraries like this ( static ones )

./.libs/libsoft.a
./.libs/libtsil.a
./.libs/libsupermodel.a

或此(动态):

./.libs/libsoft.so.0
./.libs/libsupermodel.so.0
./.libs/libsoft.so.0.0.0
./.libs/libtsil.so.0
./.libs/libtsil.so.0.0.0
./.libs/libsupermodel.so.0.0.0
./.libs/libsupermodel.so
./.libs/libtsil.so
./.libs/libsoft.so

如果您现在要编译您的 own main.cpp项目,则只需 根据需要链接到库.我可以使用以下命令编译并链接您的main.cpp:

If you now want to compile your own main.cpp project, you simply have to link against the libraries as needed. I can compile and link your main.cpp with the following command:

g++ main.cpp -I softsusy-4.1.1/src/ -L/home/krud/softsusy/softsusy-4.1.1/.libs -lsoft -ltsil -lsupermodel -o go

所有内容都写在程序包的INSTALL和README文件以及程序包的文档中.

All that is written in the INSTALL and README files of the package and also in the docs of the package.

如果您不知道如何链接到库,则必须提出一个新问题,因为它与Makefile完全无关,而与上述源包无关.

If you have no idea how to link against a library, you have to start a new question because it has really nothing to do with Makefile and nothing todo with the mentioned source package.

信息:我只需在PC上一分钟就能完成操作,只需将4.1.1版本下载为tgz即可.打开包装并执行前面的3个步骤,一切准备就绪.因为我的包装盒具有较新的自动工具版本,所以仅需要添加aclocal.

Info: I did it on my pc a minute ok by simply downloading version 4.1.1 as tgz. Unpacking and the 3 steps ahead I got everything ready to use. Only the aclocal was needed as addition,m because my box has a newer autotools version.

这篇关于带有多个标题和名称空间的makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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