DLL errors in vc++ program
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: DLL errors in vc++ program

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    DLL errors in vc++ program

    Hi

    I'm new to visual c++, but OK with several other languages, however I am having build errors using an external dll in vs2010.

    The external dll call is made from a button on a form. The header and lib files are as supplied with the dll, which just controls a digital i/o port. The lib file is referenced in the linker.

    my simple code :-

    #include <libad.h>
    ...
    adh = ad_open("usb-pio")

    Errors on build :-

    1>usbpiowf.obj : error LNK2028: unresolved token (0A00000F) "extern "C" int __clrcall ad_open(char const *)" (?ad_open@@$$J0YMHPBD@Z) referenced in function "private: void __clrcall usbpiowf::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@usbpiowf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>usbpiowf.obj : error LNK2019: unresolved external symbol "extern "C" int __clrcall ad_open(char const *)" (?ad_open@@$$J0YMHPBD@Z) referenced in function "private: void __clrcall usbpiowf::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@usbpiowf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>E:\Microsoft Visual Studio 10.0\My_winform_C_Projects\usbpiowf\Debug\usbpiowf.exe : fatal error LNK1120: 2 unresolved externals

    Any help much appreciated.

    Best Regards

    picclock

  2. #2
    Join Date
    Dec 2004
    Posts
    61

    Re: DLL errors in vc++ program

    Did you specific the "Additional Library Directory" where you lib is?
    When you have set your "Additional Dependencies" at the project properties->input.

  3. #3
    Join Date
    Apr 2012
    Posts
    29

    Re: DLL errors in vc++ program

    Uhm it took me almost 2 hours to figure out what he was trying to do. I don't like this sort of static library links. I guess you do also have the document of the library, you can declare the function pointers for those functions you would want to call then try to get their entries with GetProcAddress. This seems more rigid and portable.

  4. #4
    Join Date
    Sep 2012
    Posts
    3

    Thumbs up Re: DLL errors in vc++ program

    @ vbenduser
    The additional library directory path was correctly set, but it is easy to overlook. It just seems that visual studio doesn't like playing with this dll. Almost certainly a header issue of some sort.

    It was only a small program so having wasted far too long trying to sort it out I thought I would try it using Delphi. It worked like a charm from the getgo - I do find this sort of thing very irritating and this kind of issue often seems to occur when integrating third party stuff that is poorly documented and quite possibly poorly written.

    Thanks for your interest, I can easily live with the alternate solution.

    Best Regards

    picclock

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,980

    Re: DLL errors in vc++ program

    Quote Originally Posted by picclock View Post
    @ vbenduser
    The additional library directory path was correctly set, but it is easy to overlook. It just seems that visual studio doesn't like playing with this dll. Almost certainly a header issue of some sort.

    It was only a small program so having wasted far too long trying to sort it out I thought I would try it using Delphi. It worked like a charm from the getgo - I do find this sort of thing very irritating and this kind of issue often seems to occur when integrating third party stuff that is poorly documented and quite possibly poorly written.

    Thanks for your interest, I can easily live with the alternate solution.

    Best Regards

    picclock
    It's not a header issue, it's a linker issue. Did you specifically add the .lib file to your project? You need to do more than set the directory, you need to add the specific lib file also.

  6. #6
    Join Date
    Apr 1999
    Posts
    27,418

    Re: DLL errors in vc++ program

    Quote Originally Posted by picclock View Post
    Hi

    I'm new to visual c++, but OK with several other languages,
    Well, those linker messages all refer to Managed C++ functions. Managed C++ is off-topic in this forum, as there is a separate forum dedicated to Managed C++.

    Regards,

    Paul McKenzie

  7. #7
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,219

    Re: DLL errors in vc++ program

    Quote Originally Posted by picclock View Post
    usbpiowf.obj : error LNK2028: unresolved token (0A00000F) "extern "C" int __clrcall ad_open(char const *)" (?ad_open@@$$J0YMHPBD@Z) referenced in function "private: void __clrcall usbpiowf::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@usbpiowf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    Quote Originally Posted by picclock View Post
    I thought I would try it using Delphi. It worked like a charm from the getgo
    Do you mean you could link to this DLL from a Delphi-built app?? According to MSDN, functions declared using __clrcall can only be called from managed code. Do Delphi apps support managed code? I didn't think so but maybe they do
    "A problem well stated is a problem half solved. - Charles F. Kettering

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center