-1

I am trying to create message Queue in window but i am getting following linker error.

Sample Code:

#include "stdafx.h"
#include "windows.h"
#include "mq.h"
#include "tchar.h"


    int _tmain(int argc, _TCHAR* argv[])
    {

        wchar_t name[]=L".\\PRIVATE$\\VinayQueue21";

        DWORD bufferLength = 256;

        wchar_t formattedQueueName[256]; 

        HRESULT returnValue = MQCreateQueue(name, NULL,formattedQueueName,&bufferLength);  
        if(returnValue != MQ_OK) 
        {
            wprintf(L"Creating a Queue failed\n"); 
        }
        else 
        { 
            wprintf(L"Queue was successfully created..Formatted QueueName =%s\n",formattedQueueName);
            wprintf(L"LEn returned is %d\n", bufferLength); 
        }
        getchar();

        return 0;
    }

Error:

error1 LNK2019: unresolved external symbol _MQCreateQueue@16 referenced
error2 LNK1120: 1 unresolved externals

How to resolve this?

vinay patel
  • 177
  • 3
  • 5
  • 10
  • 1
    This is a duplicate for **all** other questions containing LNK2019 in their title. Does Visual Studio Rot the Mind? [Apparently](http://www.charlespetzold.com/etc/doesvisualstudiorotthemind.html)... – IInspectable Dec 12 '13 at 13:45
  • Duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?: Failure to link against appropriate libraries/object files or compile implementation files](http://stackoverflow.com/a/12574400/902497) – Raymond Chen Dec 12 '13 at 14:53

1 Answers1

1

You need to link with Mqrt.lib

Project properties -> Linker -> Input -> Additional Dependencies

Always check the "Requirements" section on MSDN for WinAPI functions (MQCreateQueue). You may need to link against some libraries that aren't linked by default.

parrowdice
  • 1,902
  • 15
  • 24
  • Thanks parrowdice.... I have included following two lines and its linking fine #import "mqoa.dll" named_guids // no_namespace #pragma comment (lib, "Mqrt.lib") – vinay patel Dec 12 '13 at 13:45