4

I have some code in C# which I want to use in other project (coded in C++). From what I researched, I need to create a .lib but MSVS only creates .dll (I think..). I think is possible to use the .dll by using LoadLibrary() over C++ but seems not very friendly.

1 - Can I create the .lib in MSVS? If not, how can I create it.

2 - What is the best way to integrate the code? By the .lib or using .dll + LoadLibrary()?

4 Answers 4

3

The easiest option, honestly, is to use C++/CLI. That lets you use both object systems (.NET, and traditional C++ with its standard template library).

Sign up to request clarification or add additional context in comments.

Comments

1

Is it managed C++ ? If so you can directly add a reference to the C# dll and use it.

1 Comment

I guess it isn't. My classes would have to had "__gc class A" right? I put "using <WordsExtraction.dll>", and the CLR option and the compiler says: please specify the assembly search path using /AI or by setting the LIBPATH environment variable" I have the WordsExtraction.dll on my Debug folder
1

What you need is a com compliant class in c#: http://en.allexperts.com/q/C-3307/2008/2/Using-C-class-C.htm http://blogs.msdn.com/b/deeptanshuv/archive/2005/06/26/432870.aspx

Comments

1

One possibility is to make your C# code Managed COM compliant. Then use the standard COM api's (QueryInterface etc) to call the C# COM code.

The codeproject sample may be useful http://www.codeproject.com/KB/cs/ManagedCOM.aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.