运行 meep C++ 基础知识
running meep c++ basics
我正在尝试通过其 C++ 库在 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;
}
您必须 link MEEP 库。我这样编译你的应用程序:
g++ -o test2 test2.cpp -lmeep
MEEP 开发文件可以这样安装在 Ubuntu:
sudo apt-get install libmeep-dev
现在也像这样修改包含语句:
#include <meep.hpp>
我在 Ubuntu 15.10 上对此进行了测试,您的应用运行良好。
我正在尝试通过其 C++ 库在 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;
}
您必须 link MEEP 库。我这样编译你的应用程序:
g++ -o test2 test2.cpp -lmeep
MEEP 开发文件可以这样安装在 Ubuntu:
sudo apt-get install libmeep-dev
现在也像这样修改包含语句:
#include <meep.hpp>
我在 Ubuntu 15.10 上对此进行了测试,您的应用运行良好。