运行 MEEP C++ 基础知识

running meep c++ basics

本文关键字:基础知识 C++ MEEP 运行      更新时间:2023-10-16

我正在尝试通过其C++库在ubuntu上运行MIT MEEP,但我普遍不成功。我已经正确安装了 meep 和 g++。我可以运行方案 ctrl 文件,但不能运行 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;
} 

您必须链接 MEEP 库。我像这样编译了你的应用程序:

g++ -o test2 test2.cpp -lmeep

MEEP 开发文件可以像这样安装在 Ubuntu 上:

sudo apt-get install libmeep-dev

现在还要像这样修改 include 语句:

#include <meep.hpp>

我在 Ubuntu 15.10 上对此进行了测试,您的应用程序运行良好。