【发布时间】:2021-11-23 19:34:15
【问题描述】:
问题总结
我正在尝试安装名为 TACS 的开源并行有限元代码,可在 this github repository 获得。为了满足指定的先决条件,我按照this github repository 的说明进行操作,这使我可以在 Windows 上安装 SuiteSparse 和 METIS 并使用预编译的 BLAS/LAPACK DLL。对于 MPI,我通过 Cygwin 安装了 Intel MPI Library 和 Open MPI。最后一步应该是编译运行make,但是此命令在 Windows 10 中不直接可用。因此,我探索了this question 中建议的选项,不幸的是没有成功。我觉得死路一条,任何帮助将不胜感激。
我尝试过的
请看下面我的尝试。我主要是 Windows 用户,我不太了解使用 Makefile 编译程序。我目前的理解是,我试图编译的Makefile 是为 Linux 编写的,而我使用的任何 Windows GNU 编译器都无法工作,因为需要不同的语法。如果我错了,请纠正我。我无法理解的是为什么当我尝试使用适用于 Windows 10 的 Ubuntu Bash 进行编译时也会出现错误(下面列表的最后一次尝试)。
Visual Studio nmake
以管理员身份运行 VS 2019 的开发人员命令提示符,我在 TACS 基本目录中输入了nmake -f Makefile,得到了Makefile.in(28) : fatal error U1001: syntax error : illegal character '{' in macro Stop.
巧克力make
以管理员身份运行 Windows 命令提示符,C:\ProgramData\chocolatey\bin 在 PATH 环境变量的顶部,我在 TACS 基本目录中输入了 make,我得到了
"" was unexpected at this time.
make: *** [Makefile:23: default] Error 255
赛格温make
以管理员身份运行 Windows 命令提示符,C:\cygwin64\bin 在 PATH 环境变量的顶部,我在 TACS 基本目录中输入了make,我得到了三种类型的错误:
error: expected ',' or '...' before numeric constant
error: cannot convert 'int*' to 'idx_t*' {aka 'long int*'}
error: no matching function for call to 'TACSSchurMat::getBCSRMat(BCSRMat**, NULL, NULL, NULL)'
我尝试更改受影响脚本中的一些变量名称(例如 N_ 代替 _N),我摆脱了第一种和第三种类型的错误,但没有消除第二种错误。
GnuWin make
以管理员身份运行 Windows 命令提示符,C:\Program Files (x86)\GnuWin32\bin 在 PATH 环境变量的顶部,我在 TACS 基本目录中输入了 make,我得到了
"" was unexpected at this time.
make: *** [Makefile:23: default] Error 255
MinGWmingw32-make
以管理员身份运行 Windows 命令提示符,C:\MinGW\bin 在 PATH 环境变量的顶部,我在 TACS 基本目录中输入了 mingw32-make,然后我得到了
"" was unexpected at this time.
Makefile:23: recipe for target 'default' failed
mingw32-make: *** [default] Error 255
MSYS MinGW 64 位 make
以管理员身份运行 Windows 命令提示符,C:\msys64\usr\bin 在 PATH 环境变量的顶部,我在 TACS 基本目录中输入了 make,我得到了
make[1]: mpicxx: No such file or directory
make[1]: *** [../TACS_Common.mk:28: C:/Users/qa21944/git/tacs/src/TACSAssembler.o] Error 127
make[1]: *** Waiting for unfinished jobs....
make[1]: mpicxx: No such file or directory
make[1]: *** [../TACS_Common.mk:28: C:/Users/qa21944/git/tacs/src/TACSCreator.o] Error 127
make[1]: Leaving directory '/c/Users/qa21944/git/tacs/src'
make: *** [Makefile:23: default] Error 1
这对我来说很难理解,因为mpicxx 文件是C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin,而它又位于PATH 环境变量中。当我尝试将C:\cygwin64\bin 添加到PATH(低于C:\msys64\usr\bin)并重新运行make 时,我得到了
0 [main] opal_wrapper (14432) C:\cygwin64\bin\opal_wrapper.exe: *** fatal error - cygheap base mismatch detected - 0x180352408/0x180357408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.
我尝试按照这些说明进行操作,然后重新启动计算机,但没有任何改变。
适用于 Windows 10 的 Ubuntu Bash make
这次尝试的灵感来自this answer。我从 Microsoft Store 下载了 Ubuntu 并安装了 make。在 Ubuntu Bash 中,我在 TACS 基本目录中输入了make,然后我得到了
make[1]: Entering directory '/mnt/c/Users/qa21944/git/tacs/src'
Makefile:26: *** target pattern contains no '%'. Stop.
make[1]: Leaving directory '/mnt/c/Users/qa21944/git/tacs/src'
make: *** [Makefile:23: default] Error 1
我不明白为什么会出现此错误。我还确保所有行都以制表符而不是空格开头,但没有任何改变。
代码
您可以在下面找到我正在使用的Makefile.in 和Makefile。
Makefile.in
# Do not modify this file. Copy this file to Makefile.in and then modify it.
# In order to get TACS to compile, you'll need to fill in the
# following path information. Some of the items below are required
# only if you're going to use the python interface.
# the full path to the root TACS directory
TACS_DIR = C:/Users/qa21944/git/tacs
CXX = mpicxx
RM = rm -f
PYTHON = python
PYTHON_CONFIG = python-config
# Set up for parallel make
MAKE = make -j 8
# Set the ar flags
AR_FLAGS = rcs
# Flags for debugging and regular compilation versions
EXTRA_DEBUG_CC_FLAGS = -fPIC -g
EXTRA_CC_FLAGS = -fPIC -O3
# Use this if you have problems with mpich
# TACS_DEF = -DMPICH_IGNORE_CXX_SEEK
# Defines whether to use static or dynamic linking
# TACS_LD_CMD=${TACS_DIR}/lib/libtacs.a
TACS_LD_CMD=-L${TACS_DIR}/lib/ -Wl,-rpath,${TACS_DIR}/lib -ltacs
# For linux systems, use the following settings:
SO_EXT=so
SO_LINK_FLAGS=-fPIC -shared
# For MAC OS X, use the following settings:
# SO_EXT=so
# SO_LINK_FLAGS=-fPIC -dynamiclib
# This uses the default installation of LAPACK.
# Use an optimized version of LAPACK if available.
# You may also have to include -lblas as well.
LAPACK_LIBS = -LC:/SP_ROOT/lapack_windows/x64 -llapack -lpthread -lblas
# For MAC OSX use the accelerate framework
# LAPACK_LIBS=-framework accelerate
# METIS is handy for partitioning graphs, but can be problematic for
# compilation. If you compile METIS using a C++ compiler you must add
# -DTACS_CPLUSPLUS_METIS to the TACS_DEF arguments below. If you
# compile METIS using a C compiler, there should be no issues.
METIS_INCLUDE = -IC:/SP_ROOT/build/install/include
METIS_LIB = -LC:/SP_ROOT/build/install/lib -lmetis
# AMD is a set of routines for ordering matrices. It is not required by default.
AMD_INCLUDE = -IC:/SP_ROOT/build/install/include/suitesparse
AMD_LIBS = -LC:/SP_ROOT/build/install/lib -llibamd
生成文件
# ============================================
#
# Make file for TACS_DIR/
#
# ============================================
include Makefile.in
include TACS_Common.mk
TACS_SUBDIRS = src \
src/bpmat \
src/elements \
src/elements/dynamics \
src/elements/basis \
src/elements/shell \
src/constitutive \
src/functions \
src/io
TACS_OBJS := $(addsuffix /*.o, ${TACS_SUBDIRS})
default:
@if [ "${TACS_IS_COMPLEX}" = "true" ]; then \
echo "Building Complex TACS"; \
for subdir in $(TACS_SUBDIRS) ; do \
echo "making $@ in $$subdir"; \
echo; (cd $$subdir && $(MAKE) TACS_DIR=${TACS_DIR} TACS_DEF="${TACS_DEF} -DTACS_USE_COMPLEX") || exit 1; \
done \
else \
echo "Building Real TACS"; \
for subdir in $(TACS_SUBDIRS) ; do \
echo "making $@ in $$subdir"; \
echo; (cd $$subdir && $(MAKE) TACS_DIR=${TACS_DIR}) || exit 1; \
done \
fi
${CXX} ${SO_LINK_FLAGS} ${TACS_OBJS} ${TACS_EXTERN_LIBS} -o ${TACS_DIR}/lib/libtacs.${SO_EXT}
@if [ "${TACS_IS_COMPLEX}" = "true" ]; then \
echo "ctypedef complex TacsScalar" > tacs/TacsTypedefs.pxi; \
echo "TACS_NPY_SCALAR = np.NPY_CDOUBLE" > tacs/TacsDefs.pxi; \
echo "dtype = complex" >> tacs/TacsDefs.pxi; \
else \
echo "ctypedef double TacsScalar" > tacs/TacsTypedefs.pxi; \
echo "TACS_NPY_SCALAR = np.NPY_DOUBLE" > tacs/TacsDefs.pxi; \
echo "dtype = np.double" >> tacs/TacsDefs.pxi; \
fi
debug:
@if [ "${TACS_IS_COMPLEX}" = "true" ]; then \
echo "Building Complex TACS"; \
for subdir in $(TACS_SUBDIRS) ; do \
echo "making $@ in $$subdir"; \
echo; (cd $$subdir && $(MAKE) debug TACS_DIR=${TACS_DIR} TACS_DEF="${TACS_DEF} -DTACS_USE_COMPLEX") || exit 1; \
done \
else \
echo "Building Real TACS"; \
for subdir in $(TACS_SUBDIRS) ; do \
echo "making $@ in $$subdir"; \
echo; (cd $$subdir && $(MAKE) debug TACS_DIR=${TACS_DIR}) || exit 1; \
done \
fi
${CXX} ${SO_LINK_FLAGS} ${TACS_OBJS} ${TACS_EXTERN_LIBS} -o ${TACS_DIR}/lib/libtacs.${SO_EXT}
@if [ "${TACS_IS_COMPLEX}" = "true" ]; then \
echo "ctypedef complex TacsScalar" > tacs/TacsTypedefs.pxi; \
echo "TACS_NPY_SCALAR = np.NPY_CDOUBLE" > tacs/TacsDefs.pxi; \
echo "dtype = complex" >> tacs/TacsDefs.pxi; \
else \
echo "ctypedef double TacsScalar" > tacs/TacsTypedefs.pxi; \
echo "TACS_NPY_SCALAR = np.NPY_DOUBLE" > tacs/TacsDefs.pxi; \
echo "dtype = np.double" >> tacs/TacsDefs.pxi; \
fi
interface:
${PYTHON} setup.py build_ext --inplace
complex_interface:
${PYTHON} setup.py build_ext --inplace --define TACS_USE_COMPLEX
complex: TACS_IS_COMPLEX=true
complex: default
complex_debug: TACS_IS_COMPLEX=true
complex_debug: debug
clean:
${RM} lib/libtacs.a lib/libtacs.so
${RM} tacs/*.so tacs/*.cpp
@for subdir in $(TACS_SUBDIRS) ; do \
echo "making $@ in $$subdir"; \
echo; \
(cd $$subdir && $(MAKE) $@ TACS_DIR=${TACS_DIR}) || exit 1; \
done
编辑:我正在根据 cmets 的要求添加一个TACS_Common.mk 的 sn-p。
TACS_Common.mk
TACS_LIB = ${TACS_DIR}/lib/libtacs.a
TACS_INCLUDE = -I${TACS_DIR}/src \
-I${TACS_DIR}/src/bpmat \
-I${TACS_DIR}/src/elements \
-I${TACS_DIR}/src/elements/dynamics \
-I${TACS_DIR}/src/elements/basis \
-I${TACS_DIR}/src/elements/shell \
-I${TACS_DIR}/src/constitutive \
-I${TACS_DIR}/src/functions \
-I${TACS_DIR}/src/io
# Set the command line flags to use for compilation
TACS_OPT_CC_FLAGS = ${TACS_DEF} ${EXTRA_CC_FLAGS} ${METIS_INCLUDE} ${AMD_INCLUDE} ${TACS_INCLUDE}
TACS_DEBUG_CC_FLAGS = ${TACS_DEF} ${EXTRA_DEBUG_CC_FLAGS} ${METIS_INCLUDE} ${AMD_INCLUDE} ${TACS_INCLUDE}
# By default, use the optimized flags
TACS_CC_FLAGS = ${TACS_OPT_CC_FLAGS}
# Set the linking flags to use
TACS_EXTERN_LIBS = ${AMD_LIBS} ${METIS_LIB} ${LAPACK_LIBS}
TACS_LD_FLAGS = ${EXTRA_LD_FLAGS} ${TACS_LD_CMD} ${TACS_EXTERN_LIBS}
# This is the one rule that is used to compile all the
# source code in TACS
%.o: %.cpp
${CXX} ${TACS_CC_FLAGS} -c $< -o $*.o
@echo
@echo " --- Compiled $*.cpp successfully ---"
@echo
【问题讨论】:
-
您的描述中缺少一个文件:
TACS_common.mk未显示,它包含在您的Makefile中。请将其添加到问题中,否则将很难(因为Makefile非常复杂)为您提供有关如何解决它的提示。 -
@LuisColorado 感谢您的评论,我已添加文件。
-
错误 target pattern contains no '%' 几乎可以肯定是使用驱动器号的问题,如下所述。因为它们,规则被解释为静态模式规则,而静态模式规则需要
%模式匹配字符。但是,该错误位于第 26 行的src/Makefile中,因此您必须查看那里以了解问题路径名来自何处的详细信息。 -
@MadScientist 你是对的,使用适当的语法更正路径,错误消失了。我接下来要做的是通过 Ubuntu for Windows 10(这确实是一个 WSL)安装所有先决条件,然后再次尝试使用
make进行编译。现在我收到了类似于/usr/bin/ld: src/TACSBuckling.o:TACSBuckling.c:(.text+0x344): undefined reference to `__getreent'、/usr/bin/ld: src/TACSAuxElements.o:TACSAuxElements.cpp:(.xdata+0x10): undefined reference to `__gxx_personality_seh0'等的错误。但这看起来有点超出我原来问题的范围,不是吗?
标签: c++ linux windows makefile compilation