运行 MEEP C++ 基础知识
running meep c++ basics
我正在尝试通过其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 上对此进行了测试,您的应用程序运行良好。
相关文章:
- 与C++哈希表的基础知识混淆
- 基础知识指针 c++
- 使用 QVector 创建图形磁贴(QCache 之前的基础知识)
- 异常基础知识:为什么 while 循环会变成无限循环?
- Cortex-M0 ASF基础知识
- C++基础知识(使用其他方法(Unicode?)的相同代码)
- 2 个未解析的外部符号(C++函数基础知识)
- 了解线程构造函数的基础知识
- 了解写入副本的基础知识
- C++OOP基础知识-是否正确返回对象引用
- 计算DX11中的着色器基础知识
- MDI窗口和QSignalMapper基础知识
- P2P最重要的基础知识
- C 多循环 for () 基础知识
- C++指针和数组基础知识
- 堆叠基础知识
- c++编译的基础知识
- 如何开始学习用C++为XBOX 360 KINECT编写用于开发windows应用程序的程序的基础知识
- 链接列表基础知识中的混乱
- 运行 MEEP C++ 基础知识