secondsen 发表于 2012-9-13 12:32:29

LNK2019。。

项目 --> 属性 --> 链接器 -->  输入 --> 附近依赖项。。。这个的,不适用,应该。。。因为,都是我自己写的

struct _2nDs_Vector2D
{
    float x;
    float y;

    inline void Set(float fx, float fy);
    inline void Set(const _2nDs_Vector2D& vector);
........其他.....飘过.......
}

别的2nDs_Math.h
#include "Vector2D.h"
GLubyte isEdgeToEdgeIntersection(const _2nDs_Vector2D& A, const _2nDs_Vector2D& B, const _2nDs_Vector2D& C, const _2nDs_Vector2D& D, _2nDs_Vector2D* IntSecPoint);

2nDs_ Math.cpp

GLubyte isEdgeToEdgeIntersection(const _2nDs_Vector2D& A, const _2nDs_Vector2D& B, const _2nDs_Vector2D& C, const _2nDs_Vector2D& D, _2nDs_Vector2D* IntSecPoint)
{
.........
if (A.IsEqualTo(B)) IntSecPoint->Set(A);
.........
}



error LNK2019: unresolved external symbol "public: void __thiscall _2nDs_Vector2D::Set(struct _2nDs_Vector2D const &)" (?Set@_2nDs_Vector2D@@QAEXABU1@@Z) referenced in function "unsigned char __cdecl isEdgeToEdgeIntersection(struct _2nDs_Vector2D const &,struct _2nDs_Vector2D const &,struct _2nDs_Vector2D const &,struct _2nDs_Vector2D const &,struct _2nDs_Vector2D *)" (?isEdgeToEdgeIntersection@@YAEABU_2nDs_Vector2D@@000PAU1@@Z)    C:\Documents and Settings\secondsen\My Documents\Visual Studio 2010\Projects\2nDs_Engine\2nDs_Engine\2nDs_Maths.obj    2nDs_Engine

都是我自己写的,也包含了,LNK2019是怎么蹦出来的?


补充一下。。Set和IsEqualTo都报了LNK2019

shawind 发表于 2012-9-13 18:51:30

_2nDs_Vector2D这个struct只有定义,没有实现么?

secondsen 发表于 2012-9-13 20:51:00

有实现的,就是赋值 放在相应的cpp中,声明在.h中

secondsen 发表于 2012-9-13 20:53:59

2nDs_Vector2D.h

#ifndef _2nDs_VECTOR2D_H_
#define _2nDs_VECTOR2D_H_

#include "2nDs_System.h"

struct _2nDs_Vector2D
{
    GLfloat x;
    GLfloat y;

    _2nDs_Vector2D(GLvoid):x(0), y(0){}
    _2nDs_Vector2D(GLfloat value):x(value), y(value){}
    _2nDs_Vector2D(GLfloat fx, GLfloat fy):x(fx), y(fy){}
    _2nDs_Vector2D(const float* values):x((*values)), y((*values)+1){}
    _2nDs_Vector2D(_2nDs_Vector2D& vector2D):x(vector2D.x), y(vector2D.y){}
    inline GLvoid Set(GLfloat fx, GLfloat fy);
    inline GLvoid Set(const _2nDs_Vector2D& vector);
    inline GLvoid LoadIdentity(GLvoid);
    inline GLvoid Normalize(GLvoid);
    inline GLvoid RotateDeg(GLfloat angle);
    inline GLvoid RotateRad(GLfloat angle);
    inline GLvoid GetNormalized(_2nDs_Vector2D& vector) const;
    inline GLvoid GetRotatedDeg(GLfloat angle, _2nDs_Vector2D& vector) const;
    inline GLvoid GetRotatedRad(GLfloat angle, _2nDs_Vector2D& vector) const;
    inline GLfloat GetLength() const;
    inline GLfloat GetSquaredLength() const;
    inline GLvoid Lerp(const _2nDs_Vector2D& src, GLfloat factor, _2nDs_Vector2D& dst);
    inline GLvoid IsSumOf(const _2nDs_Vector2D& vector1, const _2nDs_Vector2D& vector2);
    inline GLvoid IsDifferenceOf(const _2nDs_Vector2D& vector1, const _2nDs_Vector2D& vector2);
    inline GLvoid IsProductOf(const _2nDs_Vector2D& vector1, const _2nDs_Vector2D& vector2);
    inline GLvoid IsQuotientOf(const _2nDs_Vector2D& vector1, const _2nDs_Vector2D& vector2);
    inline GLvoid IsSumOf(const _2nDs_Vector2D& vector, const GLfloat value);
    inline GLvoid IsDifferenceOf(const _2nDs_Vector2D& vector, const GLfloat value);
    inline GLvoid IsProductOf(const _2nDs_Vector2D& vector, const GLfloat value);
    inline GLvoid IsQuotientOf(const _2nDs_Vector2D& vector, const GLfloat value);
    inline GLvoid Plus(const _2nDs_Vector2D& vector);
    inline GLvoid Subtract(const _2nDs_Vector2D& vector);
    inline GLvoid Multiply(const _2nDs_Vector2D& vector);
    inline GLvoid Divide(const _2nDs_Vector2D& vector);
    inline GLvoid Plus(const GLfloat value);
    inline GLvoid Subtract(const GLfloat value);
    inline GLvoid Multiply(const GLfloat value);
    inline GLvoid Divide(const GLfloat value);
    inline GLvoid Invert(_2nDs_Vector2D& vector);
    inline GLvoid Inverted(GLvoid);
    inline GLfloat DotMultiply(const _2nDs_Vector2D& vector);
    inline GLvoid CrossMultiply(const _2nDs_Vector2D& vector, _2nDs_Vector2D& Dst);
    inline GLboolean IsEqualTo(const _2nDs_Vector2D& vector) const;
    inline GLboolean IsUnequalTo(const _2nDs_Vector2D& vector) const;
};

#endif


2nDs_Vector2D.cpp

#include "2nDs_Vector2D.h"
#include "2nDs_Maths.h"

inline GLvoid _2nDs_Vector2D::Set(GLfloat fx, GLfloat fy) {x = fx; y = fy;}
inline GLvoid _2nDs_Vector2D::Set(const _2nDs_Vector2D& vector) {x = vector.x; y = vector.y;}
inline GLvoid _2nDs_Vector2D::LoadIdentity(GLvoid) {x = 0.0f; y = 0.0f;}

inline GLvoid _2nDs_Vector2D::Normalize(GLvoid)
{
    GLfloat l = GetLength();
    if(l == 1 || l == 0) return;
    x /= l;
    y /= l;
}

。。。。。。其他。。。。

shawind 发表于 2012-9-14 08:42:58

看不出来有什么明显的问题,如果编译出的目标文件里确实是有2nDs_Vector2D.obj的话,我猜可能是你的项目工程组织结构的问题吧。

同等专业的程序员来解惑。

secondsen 发表于 2012-9-14 09:19:40

引用第4楼shawind于2012-09-14 08:42发表的:
我猜可能是你的项目工程组织结构的问题吧。




组织结构是指??包含来包含去的,弄得一团乱麻??

shawind 发表于 2012-9-14 14:35:08

引用第5楼secondsen于2012-09-14 09:19发表的  :
组织结构是指??包含来包含去的,弄得一团乱麻??
....... images/back.gif


是的,比如说,链接的时候link.exe没找到2nDs_Vector2D.obj。又或者有什么预定义不小心把2nDs_Vector2D.cpp里的实现给忽略过去了。不过,直接用IDE管理的项目,一般是不会出这种问题的。
你以用 dumpbin /SYMBOLS 2nDs_Vector2D.obj > 2nDs_Vector2D.txt
然后打开2nDs_Vector2D.txt看看里面有没有set等方法的符号,
如果有,就是你的link.exe找不到2nDs_Vector2D.obj文件。
如果没有,就是你的具体实现根本没有被编译出来。

secondsen 发表于 2012-9-14 23:27:25

Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file 2nDs_Vector2D.obj

File Type: COFF OBJECT

COFF SYMBOL TABLE
000 00AB766F ABS    notype       Static       | @comp.id
001 00000001 ABS    notype       Static       | @feat.00
002 00000000 SECT1  notype       Static       | .drectve
    Section length   41, #relocs    0, #linenums    0, checksum        0
    Relocation CRC 00000000
005 00000000 SECT2  notype       Static       | .debug$S
    Section length 1370, #relocs    0, #linenums    0, checksum        0
    Relocation CRC 00000000
008 00000000 SECT3  notype       Static       | .debug$T
    Section length   94, #relocs    0, #linenums    0, checksum        0
    Relocation CRC 00000000

String Table Size = 0x0 bytes

  Summary

        1370 .debug$S
          94 .debug$T
          41 .drectve


实现部分没有编译出来的意思??

shawind 发表于 2012-9-15 10:25:21

应该是这样了,从这个结果来看,2nDs_Vector2D.cpp的几乎像是空文件。
你查下,是不是有#define...这类的条件编译开关把具体代码给忽略过去了。

secondsen 发表于 2012-9-16 18:17:35

感觉 略 崩溃
页: [1] 2
查看完整版本: LNK2019。。