using System;
using System.Runtime. InteropServices ;
class CSClass
{
[DllImport("mycp p.dll")]
public static extern int myfunction(stri ng c);
public static void Main()
{
...
int n = myfunction("One String");
...
}
}
Ernesto Lores
(Barcelona)
"Andrew S. Giles" <AndrewSGiles@d iscussions.micr osoft.com> escribió en el
mensaje news:CD3D93F5-CF66-4152-9ECC-650E94A2E8E4@mi crosoft.com...[color=blue]
> Is it possible to bring in a static library (developed in C++) into a C#
> project/solution?
>
> Thanks in advance for any information.
>
> Andrew S. GIles[/color]
Thanks. But it is not a Dynamic Library that I have access to. All I have
is a static
libraby (lib) not a dynamic library (DLL).
Andrew
"e-lores" wrote:
[color=blue]
> Maybe Marshaling can helps you. Look at this:
>
> using System;
> using System.Runtime. InteropServices ;
>
> class CSClass
> {
> [DllImport("mycp p.dll")]
> public static extern int myfunction(stri ng c);
>
> public static void Main()
> {
> ...
> int n = myfunction("One String");
> ...
> }
> }
>
> Ernesto Lores
> (Barcelona)
>
>
>
>
> "Andrew S. Giles" <AndrewSGiles@d iscussions.micr osoft.com> escribió en el
> mensaje news:CD3D93F5-CF66-4152-9ECC-650E94A2E8E4@mi crosoft.com...[color=green]
> > Is it possible to bring in a static library (developed in C++) into a C#
> > project/solution?
> >
> > Thanks in advance for any information.
> >
> > Andrew S. GIles[/color]
>
>
>[/color]
No, this is not possible. The best solution would be to compile your LIB
file into a DLL and export out the functions that you want to use.
JoeW
"Andrew S. Giles" wrote:
[color=blue]
> Thanks. But it is not a Dynamic Library that I have access to. All I have
> is a static
> libraby (lib) not a dynamic library (DLL).
>
> Andrew
>
> "e-lores" wrote:
>[color=green]
> > Maybe Marshaling can helps you. Look at this:
> >
> > using System;
> > using System.Runtime. InteropServices ;
> >
> > class CSClass
> > {
> > [DllImport("mycp p.dll")]
> > public static extern int myfunction(stri ng c);
> >
> > public static void Main()
> > {
> > ...
> > int n = myfunction("One String");
> > ...
> > }
> > }
> >
> > Ernesto Lores
> > (Barcelona)
> >
> >
> >
> >
> > "Andrew S. Giles" <AndrewSGiles@d iscussions.micr osoft.com> escribió en el
> > mensaje news:CD3D93F5-CF66-4152-9ECC-650E94A2E8E4@mi crosoft.com...[color=darkred]
> > > Is it possible to bring in a static library (developed in C++) into a C#
> > > project/solution?
> > >
> > > Thanks in advance for any information.
> > >
> > > Andrew S. GIles[/color]
> >
> >
> >[/color][/color]
Thanks! I didnt think it would be, but I thought I would check before I
ruled it completely out.
Andrew
"JoeWood" wrote:
[color=blue]
> No, this is not possible. The best solution would be to compile your LIB
> file into a DLL and export out the functions that you want to use.
>
> JoeW
>
> "Andrew S. Giles" wrote:
>[color=green]
> > Thanks. But it is not a Dynamic Library that I have access to. All I have
> > is a static
> > libraby (lib) not a dynamic library (DLL).
> >
> > Andrew
> >
> > "e-lores" wrote:
> >[color=darkred]
> > > Maybe Marshaling can helps you. Look at this:
> > >
> > > using System;
> > > using System.Runtime. InteropServices ;
> > >
> > > class CSClass
> > > {
> > > [DllImport("mycp p.dll")]
> > > public static extern int myfunction(stri ng c);
> > >
> > > public static void Main()
> > > {
> > > ...
> > > int n = myfunction("One String");
> > > ...
> > > }
> > > }
> > >
> > > Ernesto Lores
> > > (Barcelona)
> > >
> > >
> > >
> > >
> > > "Andrew S. Giles" <AndrewSGiles@d iscussions.micr osoft.com> escribió en el
> > > mensaje news:CD3D93F5-CF66-4152-9ECC-650E94A2E8E4@mi crosoft.com...
> > > > Is it possible to bring in a static library (developed in C++) into a C#
> > > > project/solution?
> > > >
> > > > Thanks in advance for any information.
> > > >
> > > > Andrew S. GIles
> > >
> > >
> > >[/color][/color][/color]
u build a dll that calls the functions in the static lib and the compiler
will insert the code from the static lib into the dll and then u can use the
dll.
"JoeWood" <JoeWood@discus sions.microsoft .com> wrote in message
news:9749CA14-CC11-4732-BE93-3299963FDC9B@mi crosoft.com...[color=blue]
> No, this is not possible. The best solution would be to compile your LIB
> file into a DLL and export out the functions that you want to use.
>
> JoeW
>
> "Andrew S. Giles" wrote:
>[color=green]
> > Thanks. But it is not a Dynamic Library that I have access to. All I[/color][/color]
have[color=blue][color=green]
> > is a static
> > libraby (lib) not a dynamic library (DLL).
> >
> > Andrew
> >
> > "e-lores" wrote:
> >[color=darkred]
> > > Maybe Marshaling can helps you. Look at this:
> > >
> > > using System;
> > > using System.Runtime. InteropServices ;
> > >
> > > class CSClass
> > > {
> > > [DllImport("mycp p.dll")]
> > > public static extern int myfunction(stri ng c);
> > >
> > > public static void Main()
> > > {
> > > ...
> > > int n = myfunction("One String");
> > > ...
> > > }
> > > }
> > >
> > > Ernesto Lores
> > > (Barcelona)
> > >
> > >
> > >
> > >
> > > "Andrew S. Giles" <AndrewSGiles@d iscussions.micr osoft.com> escribió en[/color][/color][/color]
el[color=blue][color=green][color=darkred]
> > > mensaje news:CD3D93F5-CF66-4152-9ECC-650E94A2E8E4@mi crosoft.com...
> > > > Is it possible to bring in a static library (developed in C++) into[/color][/color][/color]
a C#[color=blue][color=green][color=darkred]
> > > > project/solution?
> > > >
> > > > Thanks in advance for any information.
> > > >
> > > > Andrew S. GIles
> > >
> > >
> > >[/color][/color][/color]
It's not possible because the code in the static lib is not managed ...
thus it cannot be compiled into a managed assembly. Also, the .NET
framework doesn't have those kinds of linking utilities (without third
party tools), and those are only for linking other managed code
--
Joel Martinez http://www.onetug.org - Orlando .NET User Group http://www.codecube.net - blog
Bern wrote:
[color=blue]
> how is that not possible?
>
> u build a dll that calls the functions in the static lib and the compiler
> will insert the code from the static lib into the dll and then u can use the
> dll.
>
> "JoeWood" <JoeWood@discus sions.microsoft .com> wrote in message
> news:9749CA14-CC11-4732-BE93-3299963FDC9B@mi crosoft.com...
>[color=green]
>>No, this is not possible. The best solution would be to compile your LIB
>>file into a DLL and export out the functions that you want to use.
>>
>>JoeW
>>
>>"Andrew S. Giles" wrote:
>>
>>[color=darkred]
>>>Thanks. But it is not a Dynamic Library that I have access to. All I[/color][/color]
>
> have
>[color=green][color=darkred]
>>>is a static
>>>libraby (lib) not a dynamic library (DLL).
>>>
>>>Andrew
>>>
>>>"e-lores" wrote:
>>>
>>>
>>>>Maybe Marshaling can helps you. Look at this:
>>>>
>>>>using System;
>>>>using System.Runtime. InteropServices ;
>>>>
>>>>class CSClass
>>>>{
>>>> [DllImport("mycp p.dll")]
>>>> public static extern int myfunction(stri ng c);
>>>>
>>>> public static void Main()
>>>> {
>>>> ...
>>>> int n = myfunction("One String");
>>>> ...
>>>> }
>>>>}
>>>>
>>>>Ernesto Lores
>>>>(Barcelon a)
>>>>
>>>>
>>>>
>>>>
>>>>"Andrew S. Giles" <AndrewSGiles@d iscussions.micr osoft.com> escribió en[/color][/color]
>
> el
>[color=green][color=darkred]
>>>>mensaje news:CD3D93F5-CF66-4152-9ECC-650E94A2E8E4@mi crosoft.com...
>>>>
>>>>>Is it possible to bring in a static library (developed in C++) into[/color][/color]
>
> a C#
>[color=green][color=darkred]
>>>>>project/solution?
>>>>>
>>>>>Thanks in advance for any information.
>>>>>
>>>>>Andrew S. GIles
>>>>
>>>>
>>>>[/color][/color]
>
>[/color]
Comment