Home All Groups Group Topic Archive Search About

How do I add a c++ library to my vb.net project?

Author
28 Aug 2006 4:44 PM
Bmack500
Okay, this is a pretty basic question. I've created a static library
using c++. Now, I've started a vb.net project. How do I reference the
functions in the static library? I'm using Visual Studio 2005.

I.E., how do I add the library to the project, and call it's functions?



Any help would be greatly appreciated!!!!


Thank you in advance.

Author
28 Aug 2006 10:48 PM
Herfried K. Wagner [MVP]
"Bmack500" <brett.m***@gmail.com> schrieb:
> Okay, this is a pretty basic question. I've created a static library
> using c++. Now, I've started a vb.net project. How do I reference the
> functions in the static library? I'm using Visual Studio 2005.
>
> I.E., how do I add the library to the project, and call it's functions?

You do not need to add a reference to your VB project if you are talking
about a standard C++ DLL which exports functions.  Check out the 'Declare'
statement and the 'DllImportAttribute' class, both can be used to access
functions exported by a native DLL.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
30 Aug 2006 3:25 PM
Bmack500
It's a library file (*.lib). When I try to compile it as a .dll, it
gives me all kinds of linker errors. Not sure how to compile it as a
dll!

Here are the errors:

Error    4    error LNK2019: unresolved external symbol __imp__ldap_unbind
referenced in function "int __cdecl GetChangeNotifications(wchar_t *)"
(?GetChangeNotifications@@YAHPA_W@Z)    adMonlib.obj

I've added the path to the dll's (mfc) where these are located to no
avail.



Herfried K. Wagner [MVP] wrote:
Show quoteHide quote
> "Bmack500" <brett.m***@gmail.com> schrieb:
> > Okay, this is a pretty basic question. I've created a static library
> > using c++. Now, I've started a vb.net project. How do I reference the
> > functions in the static library? I'm using Visual Studio 2005.
> >
> > I.E., how do I add the library to the project, and call it's functions?
>
> You do not need to add a reference to your VB project if you are talking
> about a standard C++ DLL which exports functions.  Check out the 'Declare'
> statement and the 'DllImportAttribute' class, both can be used to access
> functions exported by a native DLL.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
10 Oct 2006 8:59 PM
RickW_inHouston
Did you ever get an answer to this?  I need to do exactly the same thing and
have not figured out how to do it yet.  I have a static library (.lib) and
need to use functions within it, either by some syntax for including and
addressing the .lib or by figuring out how to compile the .lib to a .dll and
add a reference.

Any assistance hugely appreciated.  This is a hot topic for me.


--
....many a beautiful theory was killed by an ugly fact. --Thomas Huxley


Show quoteHide quote
"Bmack500" wrote:

> It's a library file (*.lib). When I try to compile it as a .dll, it
> gives me all kinds of linker errors. Not sure how to compile it as a
> dll!
>
> Here are the errors:
>
> Error    4    error LNK2019: unresolved external symbol __imp__ldap_unbind
> referenced in function "int __cdecl GetChangeNotifications(wchar_t *)"
> (?GetChangeNotifications@@YAHPA_W@Z)    adMonlib.obj
>
> I've added the path to the dll's (mfc) where these are located to no
> avail.
>
>
>
> Herfried K. Wagner [MVP] wrote:
> > "Bmack500" <brett.m***@gmail.com> schrieb:
> > > Okay, this is a pretty basic question. I've created a static library
> > > using c++. Now, I've started a vb.net project. How do I reference the
> > > functions in the static library? I'm using Visual Studio 2005.
> > >
> > > I.E., how do I add the library to the project, and call it's functions?
> >
> > You do not need to add a reference to your VB project if you are talking
> > about a standard C++ DLL which exports functions.  Check out the 'Declare'
> > statement and the 'DllImportAttribute' class, both can be used to access
> > functions exported by a native DLL.
> >
> > --
> >  M S   Herfried K. Wagner
> > M V P  <URL:http://dotnet.mvps.org/>
> >  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
>
Author
13 Nov 2006 7:34 PM
Bmack500
Nope, I just found a way around it. I was also told that it couldn't be
done, but the documentation seems it indicate that not only can it be
done, but that it's routine. So I haven't investigated a solution since
then.

RickW_inHouston wrote:
Show quoteHide quote
> Did you ever get an answer to this?  I need to do exactly the same thing and
> have not figured out how to do it yet.  I have a static library (.lib) and
> need to use functions within it, either by some syntax for including and
> addressing the .lib or by figuring out how to compile the .lib to a .dll and
> add a reference.
>
> Any assistance hugely appreciated.  This is a hot topic for me.
>
>
> --
> ...many a beautiful theory was killed by an ugly fact. --Thomas Huxley
>
>
> "Bmack500" wrote:
>
> > It's a library file (*.lib). When I try to compile it as a .dll, it
> > gives me all kinds of linker errors. Not sure how to compile it as a
> > dll!
> >
> > Here are the errors:
> >
> > Error    4    error LNK2019: unresolved external symbol __imp__ldap_unbind
> > referenced in function "int __cdecl GetChangeNotifications(wchar_t *)"
> > (?GetChangeNotifications@@YAHPA_W@Z)    adMonlib.obj
> >
> > I've added the path to the dll's (mfc) where these are located to no
> > avail.
> >
> >
> >
> > Herfried K. Wagner [MVP] wrote:
> > > "Bmack500" <brett.m***@gmail.com> schrieb:
> > > > Okay, this is a pretty basic question. I've created a static library
> > > > using c++. Now, I've started a vb.net project. How do I reference the
> > > > functions in the static library? I'm using Visual Studio 2005.
> > > >
> > > > I.E., how do I add the library to the project, and call it's functions?
> > >
> > > You do not need to add a reference to your VB project if you are talking
> > > about a standard C++ DLL which exports functions.  Check out the 'Declare'
> > > statement and the 'DllImportAttribute' class, both can be used to access
> > > functions exported by a native DLL.
> > >
> > > --
> > >  M S   Herfried K. Wagner
> > > M V P  <URL:http://dotnet.mvps.org/>
> > >  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
> >
> >