“未解决的外部符号”错误 [英] 'Unresolved external symbol' errors

查看:193
本文介绍了“未解决的外部符号”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用的示例程序应该允许使用OSC协议控制MIDI设备。我所做的是从这里下载SDK: http://mac.softpedia.com/get/Development/Libraries/oscpack.shtml



examples文件夹包含一个名为SimpleSend.cpp的文件。代码如下:

  #includeosc / OscOutboundPacketStream.h
#includeip / UdpSocket.h


#define ADDRESS127.0.0.1
#define PORT 7000

#define OUTPUT_BUFFER_SIZE 1024

int main(int argc,char * argv [])
{
UdpTransmitSocket transmitSocket(IpEndpointName(ADDRESS,PORT));

字符缓冲区[OUTPUT_BUFFER_SIZE];
osc :: OutboundPacketStream p(buffer,OUTPUT_BUFFER_SIZE);

p<< osc :: BeginBundleImmediate
<< osc :: BeginMessage(/ test1)
<< true<< 23<< (float)3.1415 < hello< osc :: EndMessage
<< osc :: BeginMessage(/ test2)
<< true<< 24<< (float)10.8 < world< osc :: EndMessage
<< osc :: EndBundle;

transmitSocket.Send(p.Data(),p.Size());
}



我打开Visual C ++并创建了一个新的(CLR控制台应用程序)称为osctemp。我从'SimpleSend.cpp'文件复制代码,并将其粘贴到为我的项目创建的主cpp文件中,从默认项目文件中保留以下代码行:

  #includestdafx.h

使用命名空间System;

然后导航到stdafx.h头文件,注意它包含底部的行:

  // TODO:引用您的程序需要的其他标题

...所以我顺从地将包含和定义从我的主要cpp文件到这里。



注意我需要添加包含到我的项目,所以在Windows资源管理器中我将文件夹'osc'和'ip'复制到我的项目文件夹。



收到以下错误:



1> ------构建开始:项目:osctemp,配置:调试Win32 ------



1> stdafx.cpp



1> AssemblyInfo.cpp



1> osctemp.cpp



1>生成代码...



1> .NETFramework,Version = v4 .0.AssemblyAttributes.cpp



1> osctemp.obj:error LNK2028:unresolved token(0A00000A)public:char const * __thiscall osc :: OutboundPacketStream :: Data在函数int __cdecl main(int,char * * const)(?main @@ $$ HYAHHQAPAD @ Z)

$ b中引用的voidconst
$ b

1> osctemp.obj:error LNK2028:unresolved token(0A00000B)public:unsigned int __thiscall osc :: OutboundPacketStream :: Size(void)const(?Size @ OutboundPacketStream @ osc @ $$ FQBEIXZ)在函数int __cdecl main(int,char * * const)(?main @@ $$ HYAHHQAPAD @ Z)



1>中引用osctemp。 obj:error LNK2028:unresolved token(0A00000C)public _ void __thiscall UdpSocket :: Send(char const *,int)(?Send @ UdpSocket @@ $$ FQAEXPBDH @ char * * const)(?main @@ $$ HYAHHQAPAD @ Z)



...(还有更多类似的东西)...



1> D:\ Temp \OSCTEMP\osctemp\Debug\osctemp.exe:致命错误LNK1120:40未解决的外部



我错过了什么?

解决方案

从您的问题描述中我找不到任何关于如何链接到SDK库。你是这样做的吗?



要链接到SDK库,你需要一个或多个.lib文件。即使SDK是作为DLL分发的,您需要一个lib文件用于构建时链接。您应该阅读SDK文档并查找有关链接依赖关系的准则。



如果您在SDK发行版中似乎找不到任何lib文件,是你需要首先构建SDK以产生一个库,然后链接到它。或者,如果SDK附带一个现成的VS项目,您可以将它添加到您的解决方案,并设置您自己的项目,以依赖它(即VS做找到输出lib和链接的工作)。



同样,如果SDK是任何下降标准,那么就需要有关于自己构建SDK的文档。



祝你好运。


I am using an example program that is supposed to allow control of MIDI devices using a protocol called OSC.

What I have done is downloaded the SDK from here: http://mac.softpedia.com/get/Development/Libraries/oscpack.shtml

The 'examples' folder contains a file called 'SimpleSend.cpp'. The code for this is as follows:

#include "osc/OscOutboundPacketStream.h"
#include "ip/UdpSocket.h"


#define ADDRESS "127.0.0.1"
#define PORT 7000

#define OUTPUT_BUFFER_SIZE 1024

int main(int argc, char* argv[])
{
    UdpTransmitSocket transmitSocket( IpEndpointName( ADDRESS, PORT ) );

    char buffer[OUTPUT_BUFFER_SIZE];
    osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE );

    p << osc::BeginBundleImmediate
        << osc::BeginMessage( "/test1" ) 
        << true << 23 << (float)3.1415 << "hello" << osc::EndMessage
        << osc::BeginMessage( "/test2" ) 
        << true << 24 << (float)10.8 << "world" << osc::EndMessage
        << osc::EndBundle;

    transmitSocket.Send( p.Data(), p.Size() );
}

I have opened Visual C++ and created a new (CLR console application) project, called 'osctemp'. I copy the code from the 'SimpleSend.cpp' file and paste this into the main cpp file that is created for my project, keeping the following lines of code from the default project file:

#include "stdafx.h"

using namespace System;

I then navigate to the stdafx.h header file and notice that it contains at the bottom the line:

// TODO: reference additional headers your program requires here

...So I obediently move the includes and defines from my main cpp file to here.

I also notice that I need to add the includes to my project so in Windows Explorer I copy the folders 'osc' and 'ip' into my project folder.

Upon running, I receive the following errors:

1>------ Build started: Project: osctemp, Configuration: Debug Win32 ------

1> stdafx.cpp

1> AssemblyInfo.cpp

1> osctemp.cpp

1> Generating Code...

1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp

1>osctemp.obj : error LNK2028: unresolved token (0A00000A) "public: char const * __thiscall osc::OutboundPacketStream::Data(void)const " (?Data@OutboundPacketStream@osc@@$$FQBEPBDXZ) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)

1>osctemp.obj : error LNK2028: unresolved token (0A00000B) "public: unsigned int __thiscall osc::OutboundPacketStream::Size(void)const " (?Size@OutboundPacketStream@osc@@$$FQBEIXZ) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)

1>osctemp.obj : error LNK2028: unresolved token (0A00000C) "public: void __thiscall UdpSocket::Send(char const *,int)" (?Send@UdpSocket@@$$FQAEXPBDH@Z) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)

...(And many more like this)...

1>D:\Temp\OSCTEMP\osctemp\Debug\osctemp.exe : fatal error LNK1120: 40 unresolved externals

What have I missed?

解决方案

From your problem description I can't find anything about how you link towards the SDK libraries. Have you done so?

To link with the SDK libraries you need one or more .lib files. Even if the SDK is distributed as DLL you need a lib file for the build-time linkage. You should read through the SDK documentation and look for guidelines about link dependencies.

If you can't seem to find any lib-files in the SDK distribution it could very well be that you need to first build the SDK to produce a library and then link towards it. Alternatively, if the SDK comes with a ready VS project you can add it to your solution and set your own project to depend on it (i.e. VS does the work of finding the output lib and linking with it).

Again, if the SDK is of any descent standard, there should be docs about building the SDK yourself if that's necessary.

Good luck.

这篇关于“未解决的外部符号”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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