在Windows上C ++/LapackE代码编译良好,但在Linux上相同的代码编译失败 [英] C++/LapackE code compiling fine on Windows, but the identical code fails compilation on Linux

查看:100
本文介绍了在Windows上C ++/LapackE代码编译良好,但在Linux上相同的代码编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用LapackE和MPI库用C ++编写的代码可以在我使用GNU C ++ 4.9.2的Windows上编译并很好地运行.

The code written in C++ with LapackE and MPI libraries compiles and runs great on Windows where I use GNU C++ 4.9.2.

将该代码迁移到Linux(CentOS)服务器无法编译!Linux机器上的GNU C ++是4.4.7.在两种情况下,我都使用相同的LapackE头文件.MPI在Linux机器上运行良好.

Migrating that code to Linux (CentOS) server fails to compile! The GNU C++ on Linux machine is 4.4.7. I used identical LapackE header files in both cases. MPI works well on the Linux machine.

在检查两台机器上的预处理器输出文件后,我可以将错误消息与以下情况相关:在原始文件中将 complex 声明替换为 _Complex 的情况.这是一个复杂的动态数组HAMILTONIAN的声明示例,该声明在Linux上编译时有问题:

Upon inspection of preprocessor output files on both machines, I can relate the error messages to following situations where complex declarations in the original code were replaced by _Complex. Here is an example of a declaration of a complex dynamic array HAMILTONIAN that has problem when compiled on Linux:

在原始来源中:lapack_complex_double *哈密尔顿;

IN THE ORIGNIAL SOURCE: lapack_complex_double* HAMILTONIAN;

在WINDOWS PREPROC中.FILE(效果很好):_lapack_complex_double *哈密尔顿;

IN THE WINDOWS PREPROC. FILE (works well): _lapack_complex_double* HAMILTONIAN;

在LINUX PREPROC中.FILE(无法编译):双_Complex * HAMILTONIAN;

IN THE LINUX PREPROC. FILE (fails to compile): double _Complex* HAMILTONIAN;

这可能是与GCC的不同版本相关的问题吗?

Could this be problem related to different versions of GCC?

我尝试了 #define _Complex复合体,但最终没有帮助.

I've tried #define _Complex complex but it's didn't help in the end.

一些报告的C99 _Complex和C ++复合体的互操作性问题:可能类似的问题.

Some reported problem with interoperability of C99 _Complex and C++ complex: possible similar problem.

请帮助.谢谢!

推荐答案

首先,将GCC编译器设置为4.8或更高版本:就我而言,我们必须保留旧版GCC 4.4.7并同时安装GCC 4.9.2.为了能够在MPI编译中使用较新的版本,必须将其添加到PATH的前面.为此,请参见

First, set GCC compiler to 4.8 or above: In my case, we had to keep the old GCC 4.4.7 and concurrently install GCC 4.9.2. To be able to use the newer version in MPI compilation, one has to add it to the front of the PATH. For that see the answer at How to change default GCC compiler to be used with MPI on Linux CentOS

第二,在使用LapackE(Lapack的C语言包装器)进行编译时,必须使用以下预处理程序选项(-D):

Second, when compiling with LapackE (Lapack's wrapper for C) one has to use following preprocessor options (-D):

-D LAPACK_COMPLEX_STRUCTURE -D HAVE_LAPACK_CONFIG_H -D ADD _

-D LAPACK_COMPLEX_STRUCTURE -D HAVE_LAPACK_CONFIG_H -D ADD_

示例:

bash-4.1 $ mpiCC main.cpp -L/home/USER1/lapack-3.6.1 -llapacke -llapack -lblas -lm -Wall -D LAPACK_COMPLEX_STRUCTURE -D HAVE_LAPACK_CONFIG_H -D ADD _

bash-4.1$ mpiCC main.cpp -L/home/USER1/lapack-3.6.1 -llapacke -llapack -lblas -lm -Wall -D LAPACK_COMPLEX_STRUCTURE -D HAVE_LAPACK_CONFIG_H -D ADD_

请确保:

bash-4.1 $ gcc --version

bash-4.1$ gcc --version

给出4.8或更高.在我的情况下是:gcc(GCC)4.9.3

gives 4.8 or higher. In my case it was: gcc (GCC) 4.9.3

这篇关于在Windows上C ++/LapackE代码编译良好,但在Linux上相同的代码编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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