【问题标题】:Openmpi compiling error: mpicxx.h "expected identifier before numeric constant"Openmpi 编译错误:mpicxx.h“数字常量之前的预期标识符”
【发布时间】:2012-10-03 23:30:10
【问题描述】:

我正在尝试使用 openmpi 编译一个程序,我的代码没有给出任何错误,但其中一个 mpi 标头却出现了错误:

/usr/include/openmpi-x86_64/openmpi/ompi/mpi/cxx/mpicxx.h:168: error: expected identifier before numeric constant
/usr/include/openmpi-x86_64/openmpi/ompi/mpi/cxx/mpicxx.h:168: error: expected unqualified id before numeric constant

标题中的相关代码行简单地写着:

namespace MPI {

我正在使用 mpiCC 编译器。难道我做错了什么?或者这是 openmpi 中的错误?

提前致谢。

【问题讨论】:

  • 您是否尝试使用 C 编译器包装器编译 C++ 代码?
  • 你是如何安装 Open MPI 的?
  • 能否也请您发布mpiCC -showme的输出。
  • 我通过 Scientific Linux 中的添加/删除软件管理器安装了 OpenMPI。 @Hristo mpiCC -showme 的输出:g++ -I/usr/include/openmpi-x86_64 -pthread -m64 -L/usr/lib64/openmpi/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -Wl, --export-dynamic -lnsl -lutil -lm -ldl
  • 那么看起来您的 C++ 编译器将您的代码视为 C 代码,而不是 C++。文件的扩展名是什么?是.cpp.C.cc.cxx.c++ 还是只是.c

标签: openmpi


【解决方案1】:

虽然我无法重现您遇到的问题,但可以在mpi.h 中找到以下cmets,其中包含mpicxx.h

/*                                                                             
 * Conditional MPI 2 C++ bindings support.  Include if:
 *   - The user does not explicitly request us to skip it (when a C++ compiler
 *       is used to compile C code).
 *   - We want C++ bindings support
 *   - We are not building OMPI itself
 *   - We are using a C++ compiler
 */
#if !defined(OMPI_SKIP_MPICXX) && OMPI_WANT_CXX_BINDINGS && !OMPI_BUILDING
#if defined(__cplusplus) || defined(c_plusplus) 
#include "openmpi/ompi/mpi/cxx/mpicxx.h"
#endif
#endif

如果您没有使用已弃用的 C++ 绑定,则可能的解决方法是添加

-DOMPI_SKIP_MPICXX

到您的CXXFLAGS。希望这可能会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多