-
September 27th, 2012, 10:09 AM
#1
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
-
September 27th, 2012, 12:16 PM
#2
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.
-
September 27th, 2012, 01:47 PM
#3
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.
-
September 28th, 2012, 01:33 AM
#4
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
-
September 28th, 2012, 07:16 AM
#5
Re: DLL errors in vc++ program
Originally Posted by picclock
@ 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.
-
September 28th, 2012, 08:12 AM
#6
Re: DLL errors in vc++ program
Originally Posted by picclock
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
-
September 28th, 2012, 08:14 AM
#7
Re: DLL errors in vc++ program
Originally Posted by picclock
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)
Originally Posted by picclock
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|