473,554 Members | 3,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2584
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" <An**********@d iscussions.micr osoft.com> escribió en el
mensaje news:CD******** *************** ***********@mic rosoft.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("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" <An**********@d iscussions.micr osoft.com> escribió en el
mensaje news:CD******** *************** ***********@mic rosoft.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("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" <An**********@d iscussions.micr osoft.com> escribió en el
mensaje news:CD******** *************** ***********@mic rosoft.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("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" <An**********@d iscussions.micr osoft.com> escribió en el
mensaje news:CD******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:97******** *************** ***********@mic rosoft.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("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" <An**********@d iscussions.micr osoft.com> escribió en el mensaje news:CD******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:97******** *************** ***********@mic rosoft.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("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" <An**********@d iscussions.micr osoft.com> escribió en
el
mensaje news:CD******** *************** ***********@mic rosoft.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
7276
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
2595
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 which has no shared system libraries so I want to link it statically against libc et al, but it would be nice to still be able to load modules which...
3
3819
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
2532
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. The solution also contains a project which includes all the above generated static libraries.I have set all the above projects as dependent projects...
2
1734
by: Cliff Cooley | last post by:
Will static libraries generated by VB++ 6 always be usable by VC++ 7 applications ? Many thanks, Cliff
5
1874
by: meendar | last post by:
can anyone tell me what the static and dynamic library? thnkx in advance.
15
2297
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 one very large DLL that has the bulk of the code. I've downloaded the MFCWinFormsSample.EXE and have noticed that the main app could stay as a...
6
10340
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 app and a C++ native static library, they work well together _unless_ I have, it seems, any static variables defined in any function in the native...
1
1509
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 linker is not choosing the right ones by default. The problem is that when I use options like '-static' the linker will try too link all libraries...
0
2183
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 helper functions. I tried to link my object files (e.g name.o & name_wrap.o) with the static libraries (whose functionalities need to be wrapped) to...
0
7570
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7493
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7775
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7526
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7854
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5411
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3537
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1107
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.