2

我正在尝试通过其 C++ lib 在 ubuntu 上运行MIT MEEP,但我一直没有成功。我已经正确安装了 meep 和 g++。我可以运行 Scheme 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;
} 
4

1 回答 1

3

You have to link the MEEP library. I compiled your app like this:

g++ -o test2 test2.cpp -lmeep

MEEP development files can be installed like this on Ubuntu:

sudo apt-get install libmeep-dev

Also modify the include statement like this now:

#include <meep.hpp>

I tested this on Ubuntu 15.10 and your app worked fine.

于 2016-01-13T20:57:50.900 回答