【发布时间】:2016-10-04 03:40:24
【问题描述】:
我想使用libElemental作为库安装后如下:
git clone https://github.com/elemental/Elemental
mkdir build
cd build
cmake ../Elemental
make
make install
安装成功并构建示例。我对makefile 的经验有限,但想避免使用cmake,这样我就可以轻松地融入其他地方。
我有一个文件:test.cpp:
#include <El.hpp>
#include <stdlib.h>
int main(int argc, char* argv[]) {
return 0;
}
这是我不成功的makefile 尝试:
CFLAGS = -O3 -std=gnu++11
LDFLAGS := -lEl
CC = mpicc.mpich2
CXX = mpicxx.mpich2
all: test
test: test.cpp
$(CXX) $(CFLAGS) $(LDFLAGS) test.cpp -o test
这是我收到的链接器错误的 sn-p:
/tmp/ccgDsmEV.o: In function __static_initialization_and_destruction_0':
/usr/local/include/El/number_theory/lattice/LLL.hpp:316: undefined reference to El::Timer::Timer(std::string const&)'
:
:
/tmp/ccgDsmEV.o:/usr/local/include/El/number_theory/lattice/LLL.hpp:318: more undefined references to El::Timer::Timer(std::string const&)' follow
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
非常感谢任何帮助我解决此问题的帮助或指示!
【问题讨论】:
-
试试
$(CXX) test.cpp $(CFLAGS) $(LDFLAGS) -o test。但不能保证。 -
would like to avoid using cmake so I can easily integrate elsewhere但这就是 CMake 的用途。 -
是的,但我无法控制我目前正在集成的内容,也无法使用 cmake。