Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / January 2007

Tip: Looking for answers? Try searching our database.

How can I use C++ Lib file into dot net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Umeshnath - 08 Jan 2007 09:16 GMT
I have a library file (.lib) which was developed in c++, I need to use this
lib file into .net
Can I convert the lib file into dll or is there any way to use this lib in
.net?
Mattias Sjögren - 08 Jan 2007 20:45 GMT
>Can I convert the lib file into dll or is there any way to use this lib in
>.net?

You can link it into a DLL and expose the functionality you need.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

William DePalo [MVP VC++] - 09 Jan 2007 06:33 GMT
>I have a library file (.lib) which was developed in c++, I need to use this
> lib file into .net
> Can I convert the lib file into dll or is there any way to use this lib in
> .net?

I see Mattias has already offered one approach.

A variation on that them is to take advantage of the fact that the C++
compilers of MS (MC++ in VS2002/3 - C++/CLI in VS2005) can generate both
native and managed code and will allow you to call across the native/managed
boundary and link it all together into one so-called mixed mode assembly.
Once you have an assembly written in MC++ or C++/CLI which links your static
library, you can have clients make use of that assembly in any other CLS
compliant language - C#, VB.Net etc

Regards.
Will
Umeshnath - 09 Jan 2007 07:14 GMT
Hi,
I don't have source code with me ,then how can I generate native code using
compilers of MS (MC++ in VS2002/3 - C++/CLI in VS2005).I have the lib file
and header files ( declared the methods).Let me know using this how can I
call those functions defined in lib.

Exepceting the proceudre in detail or step by step.

> >I have a library file (.lib) which was developed in c++, I need to use this
> > lib file into .net
[quoted text clipped - 13 lines]
> Regards.
> Will
Ashot Geodakov - 09 Jan 2007 21:56 GMT
1. In Visual Studio:

File -> New -> Project

2. In New Project dialog:

Select Visual C++ (CLR) project type, Class Library template -> OK

3. In VS Solution Explorer:

Right-click on project name -> Add -> Existing item(s) -> Select your header
file and include in in the project.

4. Right-click on project name -> Properties.

5. In Project Properties dialog:

Add your .lib to the list of inputs for the linker.

6. In the Solution Explorer you'll notice a header and a source file for a
template ref class created for you by VS.

Add public methods to this class that call into your lib. Compile the
assembly.

7. Add a reference to this assembly to any .Net project and call into the
new class' methods, which will call into your lib.

> Hi,
> I don't have source code with me ,then how can I generate native code
[quoted text clipped - 4 lines]
>
> Exepceting the proceudre in detail or step by step.
William DePalo [MVP VC++] - 09 Jan 2007 23:32 GMT
> I don't have source code with me ,then how can I generate native code
> using
> compilers of MS (MC++ in VS2002/3 - C++/CLI in VS2005).

Well, there is no magic. You can write code to call the functions in the
library. You compile your code and link it with the library.

Regards,
Will

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.