How to access a c++ library from a vb.net project?

B

brett.mack

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?


Or, do I need to declare if as a .dll? When I do that it won't compile,
giving lnk_2019 errors. I'm using the MFC classes in my c++ app.


Any help would be greatly appreciated!!!!


Thank you in advance.
 
B

Bruno van Dooren [MVP VC++]

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.

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

You can't.
Or, do I need to declare if as a .dll? When I do that it won't compile,
giving lnk_2019 errors. I'm using the MFC classes in my c++ app.

You can either:
a) create a managed class library of your C++ functions.
b) create an unmanaged dll with exported functions. they can only be C style
functions though.
c) create a COM object and consume that in your VB app.

using a static C++ lib in a vb app is not possible afaik.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
B

Bruno van Dooren [MVP VC++]

How can I accomplish "a"?

Start a new C++ CLR class library project.
make sure that /clr is used in your project settings so that you can compile
mixed mode code.

Then you create a managed class, in which you call your unmanaged functions.

For examples and tutorials on mixed mode code, you can go to
www.codeproject.com
and search for interop and C++/CLI. google will also turn up lots of links.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 

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