473,910 Members | 6,229 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 2603
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
7315
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
2616
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 were built as shared libraries. In particular I have a library for which I've generated a wrapper...
3
3837
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
2548
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 in the 'Project Dependencies' option.
2
1748
by: Cliff Cooley | last post by:
Will static libraries generated by VB++ 6 always be usable by VC++ 7 applications ? Many thanks, Cliff
5
1891
by: meendar | last post by:
can anyone tell me what the static and dynamic library? thnkx in advance.
15
2327
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 native executable (i.e. no CLR support) whereas the various ..DLLs can be marked as having CLR...
6
10406
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 library. The libraries I'm trying to use all have Meyers Singletons in them, so they need to have...
1
1530
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 as static (which I don't want). I've tried various combinations of '-static' and '-shared' to no...
0
2220
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 form a shared library that can be imported from Python. While doing so i cannot be able to access...
0
10037
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11349
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11055
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10541
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9727
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8099
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5939
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4337
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3360
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.