Click here to Skip to main content
15,887,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So here is the thing.

I have a c library. I need to use several functions from there in a C# project

So I was thinking I need to create a C++ library to be used as wrapper to export these functions. Then add this library as a reference in my C# project.

The problem is that when I try to use the library from another pc the path for lib files are not valid any more so it is giving me an error.

So how I can move C++ library and at the same time the lib files referenced there could always work

Is it something like dynamic referencing lib file in C++ ?
Posted

You don't need to create a C++ wrapper for C functions: you can reference they directly in the same way you would C++ functions via DllImport from a DLL file. Since Platform Invoke requires only that the functions are declared C-style in the DLL file, it's even one less thing to think about! :laugh:

See here: http://msdn.microsoft.com/en-us/library/ms235282.aspx[^]
 
Share this answer
 
Comments
Vladimir Saleh 13-Jan-15 7:18am    
but still this dont answer my question. I want to add c library into the c# dinamicly
OriginalGriff 13-Jan-15 7:25am    
The link explains how to do that: or are you having problems describing it? Perhaps if you explain in more detail exactly what you are trying to achieve?
The first step is to produce a C library. It must export the names in "naked format". The resulting dll should get included in the C# output directory. Be shure to include all needed dlls.

I have written the article Calling All Stations which handles a lot of this stuff. (in knowning these problems)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900