我试图通过它的麻省理工学院MEEP库在ubuntu上运行C++,但是我一直没有成功。我已经安装好了meep和g++。我可以运行文件,但不能运行c++库。
我正在尝试MEEP c++教程中的简单代码。meep.hpp就在我给你的地方。我是c++的新手。
有人能告诉我什么是不对的吗?
以下是我得到的第一行错误:
Building target: test2
Invoking: GCC C++ Linker
g++ -o "test2" ./src/test2.o
./src/test2.o: In function `main':
/home/mad/clipse_workspace/test2/Debug/../src/test2.cpp:20: undefined reference to `meep::initialize::initialize(int&, char**&)'
/home/mad/clipse_workspace/test2/Debug/../src/test2.cpp:22: undefined reference to `meep::vol2d(double, double, double)'下面是我运行的代码:
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include </usr/include/meep/meep.hpp>
using namespace meep;
using namespace std;
double eps(const vec &p);
int main(int argc, char **argv) {
initialize mpi(argc, argv); // do this even for non-MPI Meep
double resolution = 10; // pixels per distance
grid_volume v = vol2d(5,10, resolution); // 5x10 2d cell
structure s(v, eps, pml(1.0));
fields f(&s);
f.output_hdf5(Dielectric, v.surroundings());
double freq = 0.3, fwidth = 0.1;
gaussian_src_time src(freq, fwidth);
f.add_point_source(Ey, src, vec(1.1, 2.3));
while (f.time() < f.last_source_time()) {
f.step();
}
f.output_hdf5(Hz, v.surroundings());
return 0;
}
double eps(const vec &p) {
if (p.x() < 2 && p.y() < 3)
return 12.0;
return 1.0;
} 发布于 2016-01-13 20:57:50
你必须连接MEEP图书馆。我像这样编译了你的应用程序:
g++ -o test2 test2.cpp -lmeepMEEP开发文件可以像这样安装在Ubuntu上:
sudo apt-get install libmeep-dev现在还可以像下面这样修改include语句:
#include <meep.hpp>我在Ubuntu15.10上测试了这个,你的应用程序运行得很好。
https://stackoverflow.com/questions/34776751
复制相似问题