3

Microsoft Visual C ++を使用して、無料でダウンロードできる小さなパッケージの一部であるファイル「test.cc」をコンパイルしようとしています。

http://sourceforge.net/projects/clippoly/files/

test.ccファイルは次のように表示されます。

//    nclip: a polygon clip library

//    Copyright (C) 1993  University of Twente

//    klamer@mi.el.utwente.nl

//    This library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Library General Public
//    License as published by the Free Software Foundation; either
//    version 2 of the License, or (at your option) any later version.

//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Library General Public License for more details.

//    You should have received a copy of the GNU Library General Public
//    License along with this library; if not, write to the Free
//    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include <cstring>
#include <iostream>

#include "poly.h"
#include "poly_io.h"
#include "nclip.h"

using namespace ::std;

void
clear(PolyPList &l)
{
    PolyPListIter i(l);
    while(i())
        delete i.val();
}

int
main(int, char *[])
{
    Poly *a = read_poly(cin), *b = read_poly(cin);
    PolyPList a_min_b, b_min_a, a_and_b;

    clip_poly( *a, *b, a_min_b, b_min_a, a_and_b );

    cout << "a_min_b:\n" << a_min_b;
    cout << "b_min_a:\n" << b_min_a;
    cout << "a_and_b:\n" << a_and_b;

    delete  a;
    delete  b;

    clear(a_min_b);
    clear(b_min_a);
    clear(a_and_b);

    return 0;
}

テストファイルは、2つの入力ポリゴンの交差の計算を示すように設計されています。

「プロジェクト」->「プロパティ」->「VC++ディレクトリ」->「ディレクトリを含める」に必要なヘッダーファイルへのパスをインクルードしましたが、コンパイラは「poly.h」、「poly_io.h」、「nclip.h」の存在を認識しています。

ただし、コンパイルしようとすると、次のリンカーエラーが発生します。

test.obj:エラーLNK2019:関数スカラー削除デストラクタ'(unsigned int) "`(?? _ GPolyNode @@ AAAEPAX @ Z)"private: __thiscall PolyNode::~PolyNode(void)"で参照される未解決の外部シンボル(?? 1PolyNode @@ AAE @ XZ )"private: void * __thiscall PolyNode::

test.obj:エラーLNK2019:未解決の外部シンボル"class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class Set<class Poly *> const &)"(?? 6 @ YAAAV?$ basic_ostream @ DU?$ char_traits @ D @ std @@@ std @@ AAV01 @ ABV?$ Set @ PAVPoly @@@@@ Z)参照機能的に_main

test.obj:エラーLNK2019:"void __cdecl clip_poly(class Poly const &,class Poly const &,class Set<class Poly *> &,class Set<class Poly *> &,class Set<class Poly *> &)"関数で参照されている未解決の外部シンボル(?clip_poly @@ YAXABVPoly @@ 0AAV?$ Set @ PAVPoly @@@@ 11 @ Z)_main

test.obj:エラーLNK2019:"class Poly * __cdecl read_poly(class std::basic_istream<char,struct std::char_traits<char> > &)"関数で参照される未解決の外部シンボル(?read_poly @@ YAPAVPoly @@ AAV?$ basic_istream @ DU?$ char_traits @ D @ std @@@ std @@@ Z)_main

私は何が間違っているのですか?「プロジェクト->プロパティ」の下のいたるところにパスを追加しようとしました。しかし今、私は途方に暮れています。

これが誰かにとってかなり簡単な質問であることを願っています:)

4

1 に答える 1

3

ヘッダーファイルがどこにあるかをコンパイラーに伝えたように見えますが、Polyクラスを含むライブラリーを見つけることができる場所をリンカーに伝えていません。

Visual Studioが目の前にないため、インターフェイスを介した次のルートが特定されない可能性がありますが、メモリから[プロジェクト]->[プロパティ]->[リンカー]->[入力]->を使用してライブラリ(.lib)を追加する必要があります。追加の依存関係。

于 2011-10-19T21:49:11.767 に答える