473,412 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Static libraries into C#

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
Nov 16 '05 #1
6 2572
Maybe Marshaling can helps you. Look at this:

using System;
using System.Runtime.InteropServices;

class CSClass
{
[DllImport("mycpp.dll")]
public static extern int myfunction(string c);

public static void Main()
{
...
int n = myfunction("One String");
...
}
}

Ernesto Lores
(Barcelona)


"Andrew S. Giles" <An**********@discussions.microsoft.com> escribió en el
mensaje news:CD**********************************@microsof t.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

Nov 16 '05 #2
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:
Maybe Marshaling can helps you. Look at this:

using System;
using System.Runtime.InteropServices;

class CSClass
{
[DllImport("mycpp.dll")]
public static extern int myfunction(string c);

public static void Main()
{
...
int n = myfunction("One String");
...
}
}

Ernesto Lores
(Barcelona)


"Andrew S. Giles" <An**********@discussions.microsoft.com> escribió en el
mensaje news:CD**********************************@microsof t.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


Nov 16 '05 #3
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:
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:
Maybe Marshaling can helps you. Look at this:

using System;
using System.Runtime.InteropServices;

class CSClass
{
[DllImport("mycpp.dll")]
public static extern int myfunction(string c);

public static void Main()
{
...
int n = myfunction("One String");
...
}
}

Ernesto Lores
(Barcelona)


"Andrew S. Giles" <An**********@discussions.microsoft.com> escribió en el
mensaje news:CD**********************************@microsof t.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


Nov 16 '05 #4
Thanks! I didnt think it would be, but I thought I would check before I
ruled it completely out.

Andrew

"JoeWood" wrote:
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:
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:
Maybe Marshaling can helps you. Look at this:

using System;
using System.Runtime.InteropServices;

class CSClass
{
[DllImport("mycpp.dll")]
public static extern int myfunction(string c);

public static void Main()
{
...
int n = myfunction("One String");
...
}
}

Ernesto Lores
(Barcelona)


"Andrew S. Giles" <An**********@discussions.microsoft.com> escribió en el
mensaje news:CD**********************************@microsof t.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

Nov 16 '05 #5
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" <Jo*****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
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:
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:
Maybe Marshaling can helps you. Look at this:

using System;
using System.Runtime.InteropServices;

class CSClass
{
[DllImport("mycpp.dll")]
public static extern int myfunction(string c);

public static void Main()
{
...
int n = myfunction("One String");
...
}
}

Ernesto Lores
(Barcelona)


"Andrew S. Giles" <An**********@discussions.microsoft.com> escribió en el mensaje news:CD**********************************@microsof t.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

Nov 16 '05 #6
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:
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" <Jo*****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
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:

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:
Maybe Marshaling can helps you. Look at this:

using System;
using System.Runtime.InteropServices;

class CSClass
{
[DllImport("mycpp.dll")]
public static extern int myfunction(string c);

public static void Main()
{
...
int n = myfunction("One String");
...
}
}

Ernesto Lores
(Barcelona)


"Andrew S. Giles" <An**********@discussions.microsoft.com> escribió en
el
mensaje news:CD**********************************@microsof t.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


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mudd | last post by:
How do I build Python so that I get static libraries instead of dynamic libraries (e.g. build/lib.solaris-2.8-sun4u-2.3/math.so)? John
3
by: Rickard Lind | last post by:
Is there any way to build the python executable statically and still be able to load modules built as shared libraries? I'm trying to run python scripts on a stripped down FreeBSD (4.9) machine...
3
by: iceColdFire | last post by:
Hi, Can someone highlight the difference between static library and bynamic library...and how do .lib and .dll files come up in the picture... Thanks, a.a.cpp++ :-)
1
by: rajesh_krec | last post by:
Hello Everybody, I'm using Microsoft Visual Studio .NET 2003 (with Vc7 compiler) I have some 15 projects each of which generate a static library when i build the solution in release mode. ...
2
by: Cliff Cooley | last post by:
Will static libraries generated by VB++ 6 always be usable by VC++ 7 applications ? Many thanks, Cliff
5
by: meendar | last post by:
can anyone tell me what the static and dynamic library? thnkx in advance.
15
by: Notre Poubelle | last post by:
Hello, I have a large legacy MFC application. As is typical, there is an executable along with several MFC DLLs. One of these DLLs is created by staticly linking in many libraries resulting in...
6
by: =?Utf-8?B?R29yZG8=?= | last post by:
Hello everyone, I've been trying for some time now to move to C++/CLI, but I have several large legacy C++ static libraries I need to use. When I set up a simple solution with a C++/CLI Winforms...
1
by: barcaroller | last post by:
This is not a language-specific question. I have an executable that is supposed to link to both static and shared libraries at the same time. Most of these libraries come in both flavours and the...
0
by: abarun22 | last post by:
HI I am new to SWIG & Python and right now i am in the process of wrapping some "C" functionalities present in a static library for python. I do have my C file "name.c" which just contains some...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.