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

B

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.
 
H

Herfried K. Wagner [MVP]

Bmack500 said:
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.
 
G

Guest

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 said:
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.
 
B

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 said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top