使用 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;
}
测试文件旨在演示计算两个输入多边形的交集。
我在“项目->属性->VC++目录->包含目录”中包含了必要头文件的路径,编译器识别出“poly.h”、“poly_io.h”和“nclip.h”的存在。
但是,当我尝试编译时,出现以下链接器错误:
test.obj : 错误 LNK2019:函数标量删除析构函数'(unsigned int)"` (??_GPolyNode@@AAEPAXI@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
我究竟做错了什么?我试图在“项目->属性”下的所有地方添加路径。但现在我不知所措。
我希望这对某人来说是一个相当简单的问题:)