我正在尝试跨编译拉帕克库(fortran)和c api,lapacke,用于裸机嵌入式目标powerpc-eabi目标,使用GCC交叉编译器,用于此目标。编译进行进行,但最终遇到了此错误:
[ 44%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cbbcsd.c.obj
cd /home/rcrozier/build/powerpc-eabi/lapack/LAPACKE && /usr/local/powerpc-eabi/bin/powerpc-eabi-gcc -DADD_ -mcpu=750 -I/home/rcrozier/src/fast-v8-hg/cross-dependancies/lapack-3.6.0/LAPACKE/include -o CMakeFiles/lapacke.dir/src/lapacke_cbbcsd.c.obj -c /home/rcrozier/src/fast-v8-hg/cross-dependancies/lapack-3.6.0/LAPACKE/src/lapacke_cbbcsd.c
In file included from /home/rcrozier/src/fast-v8-hg/cross-dependancies/lapack-3.6.0/LAPACKE/include/lapacke_utils.h:37:0,
from /home/rcrozier/src/fast-v8-hg/cross-dependancies/lapack-3.6.0/LAPACKE/src/lapacke_cbbcsd.c:34:
/home/rcrozier/src/fast-v8-hg/cross-dependancies/lapack-3.6.0/LAPACKE/include/lapacke.h:145:22: error: ‘LAPACK_GLOBAL’ declared as function returning a function
#define LAPACK_lsame LAPACK_GLOBAL(lsame,LSAME)
^
当将C接口构建到Lapack,Lapacke。
时发生此错误。 Lapack论坛上的一篇文章表明,这是Fortran名称杂交的问题,并添加-DADD_
处理器标志。上面我尝试了这个,但没有区别。
预处理器定义用于标题文件,复制下面:
#ifndef LAPACK_HEADER_INCLUDED
#define LAPACK_HEADER_INCLUDED
#ifndef LAPACK_GLOBAL
#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_)
#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER)
#define LAPACK_GLOBAL(lcname,UCNAME) UCNAME
#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE)
#define LAPACK_GLOBAL(lcname,UCNAME) lcname
#else
#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
#endif
#endif
#endif
错误发生在另一个使用LAPACK_GLOBAL
的标头文件中:
#include "lapacke_mangling.h"
#define LAPACK_lsame LAPACK_GLOBAL(lsame,LSAME)
lapack_logical LAPACK_lsame( char* ca, char* cb,
lapack_int lca, lapack_int lcb );
lapacke_mangling.h
文件内容如下:
#ifndef LAPACK_HEADER_INCLUDED
#define LAPACK_HEADER_INCLUDED
#endif
本地建造或为另一个Linux目标构建时,不会发生错误,powerpc-linux-gnu
。
任何人都可以解释这个问题吗?
实际上是问题是,实际上未与Cmake Build System一起使用预处理器标头文件,而是应该由CMAKE生成其他标头。cmake没有生成文件corectly(可能是由于交叉兼容)。下面的补丁修改了lapacke cmakelists以添加一个选项,以强制使用此标头文件。
--- CMakeLists.txt 2017-11-30 12:07:46.007080017 +0000
+++ newCMakeLists.txt 2017-11-30 12:06:54.491078643 +0000
@@ -3,11 +3,18 @@
set(LAPACK_INSTALL_EXPORT_NAME lapacke-targets)
+option(FORCE_LAPACKE_MANGLING_WITH_FLAGS "Force the use of the lapack_mangling_with_flags.h header rather than automatic detection" OFF)
+
# Create a header file netlib.h for the routines called in my C programs
-include(FortranCInterface)
-FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling.h
- MACRO_NAMESPACE "LAPACK_"
- SYMBOL_NAMESPACE "LAPACK_" )
+if (FORCE_LAPACKE_MANGLING_WITH_FLAGS)
+ # copy the lapacke_mangling_with_flags.h to lapacke_mangling.h
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling_with_flags.h ${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling.h)
+else (FORCE_LAPACKE_MANGLING_WITH_FLAGS)
+ include(FortranCInterface)
+ FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling.h
+ MACRO_NAMESPACE "LAPACK_"
+ SYMBOL_NAMESPACE "LAPACK_" )
+endif (FORCE_LAPACKE_MANGLING_WITH_FLAGS)
# Old way to detect mangling
#include(FortranMangling)
这样,我的定义被拾取了,并应用了适当的杂交。