1

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?

slavoo
  • 5,798
  • 64
  • 37
  • 39
Matt
  • 21
  • 1
  • 4
  • Have you added the source 'osc' and 'ip' folders to your Visual C++ project? Just copying them to where your project lies in your hard disk won't do. – Julio Gorgé May 27 '11 at 14:43
  • @Julio no, how do I do this? I've added them to the project tree structure – Matt May 27 '11 at 14:46
  • Try dragging the source code folders to the project navigation tree in VC++? Been ages since I used VC so I'm not sure if drag & drop works. I guess alternatively you could right-click on the project nav tree and select the 'add existing files…' (or sth similar) menu item for this. – Julio Gorgé May 27 '11 at 15:13
  • @Julio Thanks, I've done this, but it still won't compile. I'm told I need to build my own library. I have no idea what that means! – Matt May 27 '11 at 15:18
  • +1 for the attempt to make a decent problem description. – sharkin May 27 '11 at 15:20

2 Answers2

1

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.

sharkin
  • 12,162
  • 24
  • 86
  • 122
  • There are no lib or dll files in the SDK, but this is a commonly used set of protocols. If it's any help, the documentation refers to all of the files as being collectively a 'library' "Oscpack is not an OSC application framework, it doesn't include infrastructure for constructing or routing OSC namespaces, just classes for easily constructing, sending, receiving and parsing OSC packets" – Matt May 27 '11 at 15:06
  • 1
    Just as 'mah' I had a look at it and you need to build it yourself. Read the README file in the SDK root. This info will probably not be enough for you but it's a rather standard procedure, so you can look for help on how to build an SDK from a makefile. For instance look for such posts here, you'll find quite a few. – sharkin May 27 '11 at 15:18
0

You're either not pulling in the correct library, or your prototype is not defining the library function correctly according to what's actually in it.

mah
  • 39,056
  • 9
  • 76
  • 93
  • How do I go about pulling a library? I have added the include folders to the physical directory structure and dragged these folders into the tree view of the Visual C++ project, but it still does not run – Matt May 27 '11 at 14:53
  • The SDK contains no lib files. Is this what I need? – Matt May 27 '11 at 14:59
  • You need to modify your project linker settings to include the SDK's libraries on the input, and to specify what directory they're in. For VS2010, in properties->Linker->General, you need to set up "Additional Library Directories" and in properties->Linker->Input you need to add them to "Additional Dependencies". – mah May 27 '11 at 15:00
  • I just took a look at the SDK you linked -- you need to build its library yourself, or at least include their source within your project (the ip and osc directories). – mah May 27 '11 at 15:03
  • I've tried including the ip and osc directories in my project, which hasn't worked, but building a library? This is new to me. Could you point me towards some sort of tutorial? I'm searching Google for 'how to build a C++ library' which doesn't seem to provide any useful tips... – Matt May 27 '11 at 15:09
  • mah is right, but I would personally not advise you to try adding the sources directly to your project. The SDK likely needs certain symbols and settings defined which is taken care of in the included build setup. Given your inexperience in this matter you might run into issues you wouldn't know how to interpret. – sharkin May 27 '11 at 15:27