我正在为具有一些依赖关系的库编写configure.ac
脚本。其中一个依赖项是需要MPI的库。
我使用macro来检测MPI的可用性,并使用它的变量定义将C ++编译器更改为关联的MPI包装器。不幸的是,当我执行AC_CHECK_HEADER
时,这并没有完全反映出来。编译器测试工作正常,但预处理器测试失败。
config.log
失败(请注意预处理器测试使用g++
代替mpic++
):
configure:17591: checking for mpic++
configure:17607: found /opt/apps/gcc4_7/mvapich2-x/2.0.0/bin/mpic++
configure:17618: result: mpic++
configure:17636: checking for MPI_Init
configure:17636: mpic++ -o conftest -g -O2 -std=c++11 conftest.cpp >&5
configure:17636: $? = 0
configure:17636: result: yes
configure:17729: checking for mpi.h
configure:17742: mpic++ -c -g -O2 conftest.cpp >&5
configure:17742: $? = 0
configure:17743: result: yes
configure:17781: checking mylibrary.h usability
configure:17781: mpic++ -c -g -O2 -I./mylibrary/include -std=c++11 conftest.cpp >&5
configure:17781: $? = 0
configure:17781: result: yes
configure:17781: checking mylibrary.h presence
configure:17781: g++ -E -I./mylibrary/include -std=c++11 conftest.cpp
In file included from ./mylibrary/include/mylibrary.h:4,
from conftest.cpp:26:
./mylibrary/include/mylibrary.h:4:17: fatal error: mpi.h: No such file or directory
configure.ac
相关部分:
...
ACX_MPI([], [AC_MSG_ERROR([Cannot find an MPI C++ compiler wrapper.])])
CXX="$MPICXX"
LIBS="$MPILIBS $LIBS"
CPPFLAGS="-I$with_mylibrary_path/include $CPPFLAGS"
AC_CHECK_HEADER([mylibrary.h], [], [works=no]
...
现在配置只会抛出一个警告,并继续编译器的结果,但我很迂腐,想要解决这个问题,这样我的用户就不会想到它了。他们的系统,构建设置等问题。
我环顾四周,并且找不到重置预处理器命令的方法。我错过了什么吗?
答案 0 :(得分:2)
您可以尝试接受ACX_MPI
的作者的建议并使用AC_TRY_COMPILE
代替......
dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
dnl latter uses $CPP, not $CC (which may be mpicc).
BTW AX_MPI
宏似乎是ACX_MPI
更新(但不是那么不同)的版本。
答案 1 :(得分:0)
显然CXXCPP
用作运行C ++预处理器编译器(source)的命令,因此我修改了配置脚本:
...
ACX_MPI([], [AC_MSG_ERROR([Cannot find an MPI C++ compiler wrapper.])])
CXX="$MPICXX"
CXXCPP="$CXX -E"
LIBS="$MPILIBS $LIBS"
CPPFLAGS="-I$with_mylibrary_path/include $CPPFLAGS"
AC_CHECK_HEADER([mylibrary.h], [], [works=no]
...
并且警告消失了。