Visual C ++ LNK2019错误 [英] Visual C++ LNK2019 error

查看:288
本文介绍了Visual C ++ LNK2019错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Microsoft Visual C ++我试图编译文件test.cc,这是一个小包可以在

Using Microsoft Visual C++ I am trying to compile the file "test.cc" which is part of a small package available for free download at

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

文件test.cc如下所示:

The file test.cc appears as follows:

//    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;
}

测试文件旨在演示两个输入多边形的交集的计算。

The test file is designed to demonstrate calculation of the intersection of two input polygons.

我在Project-> Properties-> VC ++ Directories-> Include Directories中包含了必要头文件的路径,编译器正在识别poly的存在。 h,poly_io.h和nclip.h。

I have included paths to the necessary header files in 'Project->Properties->VC++ Directories->Include Directories' and the compiler is recognizing the existence of "poly.h", "poly_io.h" and "nclip.h".

然而,当我尝试编译时,我得到以下链接器错误:

however when I try compile I get the following linker errors:


test.obj:error LNK2019:未解析的外部符号private:__thiscall PolyNode ::〜PolyNode(void) (<_ code>private:void * __thiscall PolyNode :: 标量删除析构函数'(unsigned int)(?? _ GPolyNode @ @ AAEPAXI @ Z)

test.obj : error LNK2019: unresolved external symbol "private: __thiscall PolyNode::~PolyNode(void)" (??1PolyNode@@AAE@XZ) referenced in function "private: void * __thiscall PolyNode::scalar deleting destructor'(unsigned int)"` (??_GPolyNode@@AAEPAXI@Z)

test.obj:error 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 : error LNK2019: unresolved external symbol "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) referenced in function _main

test.obj:error LNK2019:未解析的外部符号 void __cdecl clip_poly(class Poly const&,class Poly const&,class Set< class Poly *>&,class Set< class Poly *>&,class Set< class Poly *& _main

test.obj : error LNK2019: unresolved external symbol "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) referenced in function _main

test.obj:error LNK2019:未解析的外部符号类Poly * __cdecl read_poly(class std :: basic_istream< char,struct std :: char_traits& >&)(?read_poly @@ YAPAVPoly @@ AAV?$ basic_istream @ DU?$ char_traits @ D @ std @@@ std @@@ Z) c> _main

test.obj : error LNK2019: unresolved external symbol "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) referenced in function _main

我做错了什么?

我希望对某人来说这是一个相当简单的问题:)

I hope this is a fairly simple question for someone :)

推荐答案

看起来你已经告诉编译器头文件在哪里,但是不告诉链接器它可以找到包含 Poly 类。

It looks as though you have told the compiler where the header files are, but not told the linker where it can find the library that contains the Poly class.

我没有在我面前的Visual Studio,所以下面的路由通过接口可能不会突出,但从内存您需要添加库。 lib)通过Project-> Properties-> Linker-> Input-> Additional Dependencies。

I don't have Visual Studio in front of me so the following route through the interface might not be spot on, but from memory you need to add the library (.lib) through Project->Properties->Linker->Input->Additional Dependencies.

这篇关于Visual C ++ LNK2019错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆