2017-06-22 5 views
0

これは私がStackoverflowを使用して質問するのは初めてのことです。私はubuntuでg ++を使ってC++コードをコンパイルするソリューションを探していましたが、多くの関連コンテンツを見つけましたが、私の質問に直接答えません...私の目標は、私はmeep.hppファイルを見つけることができないubuntu端末でコンパイルします。g ++を使用してmeepのC++コードをコンパイル

#include <meep.hpp> 

using namespace std; 
using namespace meep; 

double eps(const vec &p) { 
    if (p.x() < 2 && p.y() < 3) 
    return 12.0; 
    return 1.0; 
} 

int main(int argc, char **argv) { 
    initialize mpi(argc, argv); // do this even for non-MPI Meep 
    double resolution = 20; // 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; 
} 

コマンドI:これまでのところ私は、apt-getと...私はすべての必要なライブラリを持っている任意のここでの方法私はテストとして使用していたコードであり、私が試したコマンドを信じて使ってMEEPをインストールしています用途は以下のとおりです。

g++ FirstTest.cpp 

または他のスレッドに言ったように:

g++ -o FirstTest FirstTest.cpp -lmeep 

誰もが、私はそれを大幅に感謝し、正しい方向に私を指すことができれば!私はまだ私は最近libmeep-devをインストールした以下のコメントで述べたように

をLinuxと現在、Theディレクトリを含めるfollowningに

/tmp/ccBM5Uuc.o: In function `main': 
FirstTest.cpp:(.text+0xa6): undefined reference to `meep::initialize::initialize(int&, char**&)' 
FirstTest.cpp:(.text+0x10e): undefined reference to `meep::vol2d(double, double, double)' 
FirstTest.cpp:(.text+0x11d): undefined reference to `meep::identity()' 
FirstTest.cpp:(.text+0x134): undefined reference to `meep::pml(double)' 
FirstTest.cpp:(.text+0x1a1): undefined reference to `meep::structure::structure(meep::grid_volume const&, double (*)(meep::vec const&), meep::boundary_region const&, meep::symmetry const&, int, double, bool, double, int)' 
FirstTest.cpp:(.text+0x1bf): undefined reference to `meep::symmetry::~symmetry()' 
FirstTest.cpp:(.text+0x1e7): undefined reference to `meep::fields::fields(meep::structure*, double, bool, double, bool)' 
FirstTest.cpp:(.text+0x200): undefined reference to `meep::grid_volume::surroundings() const' 
FirstTest.cpp:(.text+0x234): undefined reference to `meep::fields::output_hdf5(meep::component, meep::volume const&, meep::h5file*, bool, bool, char const*)' 
FirstTest.cpp:(.text+0x2b9): undefined reference to `meep::gaussian_src_time::gaussian_src_time(double, double, double)' 
FirstTest.cpp:(.text+0x363): undefined reference to `meep::fields::add_point_source(meep::component, meep::src_time const&, meep::vec const&, std::complex<double>)' 
FirstTest.cpp:(.text+0x383): undefined reference to `meep::fields::step()' 
FirstTest.cpp:(.text+0x3a9): undefined reference to `meep::fields::last_source_time()' 
FirstTest.cpp:(.text+0x3d1): undefined reference to `meep::grid_volume::surroundings() const' 
FirstTest.cpp:(.text+0x405): undefined reference to `meep::fields::output_hdf5(meep::component, meep::volume const&, meep::h5file*, bool, bool, char const*)' 
FirstTest.cpp:(.text+0x437): undefined reference to `meep::fields::~fields()' 
FirstTest.cpp:(.text+0x446): undefined reference to `meep::structure::~structure()' 
FirstTest.cpp:(.text+0x464): undefined reference to `meep::initialize::~initialize()' 
FirstTest.cpp:(.text+0x491): undefined reference to `meep::structure::~structure()' 
FirstTest.cpp:(.text+0x4a5): undefined reference to `meep::symmetry::~symmetry()' 
FirstTest.cpp:(.text+0x4bc): undefined reference to `meep::structure::~structure()' 
FirstTest.cpp:(.text+0x520): undefined reference to `meep::fields::~fields()' 
FirstTest.cpp:(.text+0x534): undefined reference to `meep::structure::~structure()' 
FirstTest.cpp:(.text+0x55c): undefined reference to `meep::initialize::~initialize()' 
/tmp/ccBM5Uuc.o: In function `meep::gaussian_src_time::~gaussian_src_time()': 
FirstTest.cpp:(.text._ZN4meep17gaussian_src_timeD2Ev[_ZN4meep17gaussian_src_timeD5Ev]+0x13): undefined reference to `vtable for meep::gaussian_src_time' 
collect2: error: ld returned 1 exit status 
+1

を探しているものです-I/usr/include -L/usr/lib

のですか?実行時に発生するエラー(もしあれば)その情報を含めるように質問を編集してください(ビルドコマンドの完全な出力をコピーして貼り付けてください)。 –

+0

libmeep-devをインストールするこれはAmadeusに – Amadeus

+0

を助けるはずです...私はlibmeep-devをインストールしました。私の以前のエラーを乗り越えてしまったようです...しかし、違うエラーが発生しています.haha –

答えて

0

試しポイントを取得するのは非常に新しいです。 この

g++ -o FirstTest FirstTest.cpp -lmeep -I/example/include/path -L/example/lib/path 

ように見える多分それはこれは、あなたが表示されたコマンドでなければならないのは何の問題https://github.com/stevengj/meep/blob/master/doc/docs/C%2B%2B_Tutorial.md

+0

'-I/usr/include -L/usr/lib'はほとんどの場合デフォルトと冗長です。 – aschepler

+0

meep/folderが/ usr/includeの中にあるかもしれません。私がmeepをインストールしたときには、 –

+0

が含まれています。私はapt-getコマンドを使用しました...そうですが、meep.hppファイルの場所はわかりません。私のubuntu仮想マシンに移動したmeep.hppファイルを持つgithubからダウンロードして、私のFirstTest.cppがどこにあるのと同じフォルダに配置しましたか? –

関連する問題