3

私はここで迷っています。Mac の LLVM でプログラムを正常にコンパイルしていますが、Linux サーバーに移動して g++ を使用してコンパイルしようとすると、大量のリンカー エラーが発生しました。

ここに抜粋があります:

/tmp/ccGbgd6T.o: In function `Scene::setBackgroundImage(String)':
Project.cpp:(.text+0x166): undefined reference to `Graph_lib::Image::Image(Point, String, Graph_lib::Suffix::Encoding)'
/tmp/ccGbgd6T.o: In function `Graph_lib::Window::~Window()':
Project.cpp:(.text._ZN9Graph_lib6WindowD2Ev[_ZN9Graph_lib6WindowD5Ev]+0xc): undefined reference to `vtable for Graph_lib::Window'
/tmp/ccGbgd6T.o: In function `Graph_lib::Shape::~Shape()':
Project.cpp:(.text._ZN9Graph_lib5ShapeD2Ev[_ZN9Graph_lib5ShapeD5Ev]+0xb): undefined reference to `vtable for Graph_lib::Shape'
/tmp/ccGbgd6T.o: In function `Graph_lib::Text::Text(Point, String const&)':
Project.cpp:(.text._ZN9Graph_lib4TextC2E5PointRK6String[_ZN9Graph_lib4TextC5E5PointRK6String]+0xe): undefined reference to `Graph_lib::Shape::Shape()'
Project.cpp:(.text._ZN9Graph_lib4TextC2E5PointRK6String[_ZN9Graph_lib4TextC5E5PointRK6String]+0x17): undefined reference to `vtable for Graph_lib::Text'
Project.cpp:(.text._ZN9Graph_lib4TextC2E5PointRK6String[_ZN9Graph_lib4TextC5E5PointRK6String]+0x67): undefined reference to `Graph_lib::Shape::add(Point)'
/tmp/ccGbgd6T.o: In function `Graph_lib::Button::Button(Point, int, int, String const&, void (*)(void*, void*))':
Project.cpp:(.text._ZN9Graph_lib6ButtonC2E5PointiiRK6StringPFvPvS5_E[_ZN9Graph_lib6ButtonC5E5PointiiRK6StringPFvPvS5_E]+0x40): undefined reference to `vtable for Graph_lib::Button'

これは私を怖がらせましたが、すべてのエラーが同じクラスから発生していることに気付きました: Graph_lib. Graph.hこれは、次のように見えるものの非常に切り取られたバージョンです: (注、これは私のクラスではありません)

#ifndef GRAPH_GUARD
#define GRAPH_GUARD 1

#include <...system stuff...>

namespace Graph_lib {
// lots of other classes in here
// this is just one
    struct Image : Shape {
        Image(Point xy, string file_name, Suffix::Encoding e = Suffix::none);
    //rest of class
    }
}

ここで何がうまくいかないのでしょうか?

編集:これは私がコンパイルに使用しているコマンドです:

g++-4.6 -std=c++0x *.cpp -lfltk -lfltk_images
4

2 に答える 2

2

プロジェクトを 、またはクラス メソッドGraph.cppの実装を保持するファイルにリンクするのを忘れているようです。Graph_lib

于 2012-11-16T01:14:37.260 に答える
1

グラフ ライブラリが見つからないようです。

を使用してリンクする場合g++, use -l <Graph lib>

于 2012-11-16T01:15:22.600 に答える