Linking to DLL

Discussion in 'C++' started by SirCodesALot, Jun 12, 2008.

  1. SirCodesALot

    SirCodesALot Guest

    Dear great minds,

    I am having trouble linking to an external dll and was wondering if
    anyone out there could help. Here is my class

    Istat.h
    #include "afxdisp.h"

    using namespace System;
    using namespace System::Runtime::InteropServices;

    class IStatus : public COleDispatchDriver
    {

    public:
    IStatus() {} // Calls COleDispatchDriver default constructor


    public:
    //CString GetBstrVersion();
    long GetNPort();

    [DllImport("ComACRsrvr.dll")]

    extern "C" {
    void __stdcall Connect(long nTransport, long nIndex);
    }
    };

    Istat.cpp: (relevate lines)
    IStatus ParkerStage;
    ParkerStage.Connect(3,0);

    --------
    The problem is when I compile. I have the ComACRsrvr.dll in the same
    directory as the project, but when I compile i get the folling error
    messages:
    1>c:\\temp\Istat.h(32) : error C2059: syntax error : 'string'
    1>c:\temp\Istat.h(32) : error C2334: unexpected token(s) preceding
    '{'; skipping apparent function body

    Could I be importing the library incorrectly or is there something I
    am missing? Thanks in advance for your help!!!

    -SJ
     
    SirCodesALot, Jun 12, 2008
    #1
    1. Advertising

  2. On 2008-06-12 20:56, SirCodesALot wrote:
    > Dear great minds,
    >
    > I am having trouble linking to an external dll and was wondering if
    > anyone out there could help. Here is my class
    >
    > Istat.h
    > #include "afxdisp.h"
    >
    > using namespace System;
    > using namespace System::Runtime::InteropServices;
    >
    > class IStatus : public COleDispatchDriver
    > {
    >
    > public:
    > IStatus() {} // Calls COleDispatchDriver default constructor
    >
    >
    > public:
    > //CString GetBstrVersion();
    > long GetNPort();
    >
    > [DllImport("ComACRsrvr.dll")]
    >
    > extern "C" {
    > void __stdcall Connect(long nTransport, long nIndex);
    > }
    > };
    >
    > Istat.cpp: (relevate lines)
    > IStatus ParkerStage;
    > ParkerStage.Connect(3,0);
    >
    > --------
    > The problem is when I compile. I have the ComACRsrvr.dll in the same
    > directory as the project, but when I compile i get the folling error
    > messages:
    > 1>c:\\temp\Istat.h(32) : error C2059: syntax error : 'string'
    > 1>c:\temp\Istat.h(32) : error C2334: unexpected token(s) preceding
    > '{'; skipping apparent function body
    >
    > Could I be importing the library incorrectly or is there something I
    > am missing? Thanks in advance for your help!!!


    You are writing C++/CLI and not C++ which makes it off topic in this
    group, questions about DLLs are also off topic. You should try a MS
    newsgroup (one in the microsoft.public.* hierarchy) or try asking in one
    of the forums at http://forums.msdn.microsoft.com

    --
    Erik Wikström
     
    Erik Wikström, Jun 12, 2008
    #2
    1. Advertising

  3. SirCodesALot

    SirCodesALot Guest

    On Jun 12, 2:00 pm, Erik Wikström <> wrote:
    > On 2008-06-12 20:56, SirCodesALot wrote:
    >
    >
    >
    >
    >
    > > Dear great minds,

    >
    > > I am having trouble linking to an external dll and was wondering if
    > > anyone out there could help. Here is my class

    >
    > > Istat.h
    > > #include "afxdisp.h"

    >
    > > using namespace System;
    > > using namespace System::Runtime::InteropServices;

    >
    > > class IStatus : public COleDispatchDriver
    > > {

    >
    > > public:
    > >    IStatus() {}            // Calls COleDispatchDriver default constructor

    >
    > > public:
    > >    //CString GetBstrVersion();
    > >    long GetNPort();

    >
    > >                 [DllImport("ComACRsrvr.dll")]

    >
    > >                 extern "C" {
    > >                  void __stdcall Connect(long nTransport, long nIndex);
    > >                  }
    > > };

    >
    > > Istat.cpp: (relevate lines)
    > > IStatus ParkerStage;
    > > ParkerStage.Connect(3,0);

    >
    > > --------
    > > The problem is when I compile. I have the ComACRsrvr.dll in the same
    > > directory as the project, but when I compile i get the folling error
    > > messages:
    > > 1>c:\\temp\Istat.h(32) : error C2059: syntax error : 'string'
    > > 1>c:\temp\Istat.h(32) : error C2334: unexpected token(s) preceding
    > > '{'; skipping apparent function body

    >
    > > Could I be importing the library incorrectly or is there something I
    > > am missing? Thanks in advance for your help!!!

    >
    > You are writing C++/CLI and not C++ which makes it off topic in this
    > group, questions about DLLs are also off topic. You should try a MS
    > newsgroup (one in the microsoft.public.* hierarchy) or try asking in one
    > of the forums athttp://forums.msdn.microsoft.com
    >
    > --
    > Erik Wikström- Hide quoted text -
    >
    > - Show quoted text -


    wow. thanks. I apologize for such an off topic post.
     
    SirCodesALot, Jun 12, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    not linking msvcr70.dll

    Guest, Aug 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    961
    Guest
    Aug 11, 2004
  2. Anushi
    Replies:
    5
    Views:
    8,783
  3. Brian Su

    problem linking dll in C++

    Brian Su, Aug 18, 2003, in forum: C++
    Replies:
    2
    Views:
    2,755
    John Harrison
    Aug 18, 2003
  4. Sam Tiny
    Replies:
    2
    Views:
    1,210
    Sam Tiny
    Mar 16, 2005
  5. H. Simpson
    Replies:
    4
    Views:
    287
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page