473,400 Members | 2,163 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,400 software developers and data experts.

Creating a .NET wrapper around C library

Hi guys,

I would like to find out if :
1) Is the above possible?

I have tried to wrap a C library that our company produces in a .Net class
library and am receiving the
following error:

LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol
_main referenced in function _mainCRTStartup

Now....what seems to be weird is when I comment out the line that I am
referencing from the C library,
I have no problems linking....however, the minute I include the line....I
get the above error. Am I doing
something wrong? I thought that since the previous library was created as a
library, then just linking it
in and making sure I cover the Managed C++ part of the puzzle correctly, I
would have no problems.

Please comment.

Thanks
Paul
Nov 17 '05 #1
5 4878
"Paul Brun" <pb**********@pbrun.net> wrote in message
news:u1**************@TK2MSFTNGP10.phx.gbl...
I would like to find out if :
1) Is the above possible?
Yes, it is.
I have tried to wrap a C library that our company produces in a .Net class
library and am receiving the
following error:

LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol
_main referenced in function _mainCRTStartup


Can it be that this issue is biting you:
http://support.microsoft.com/?id=814472

Regards,
Will
Nov 17 '05 #2
Hi
If u r using a managed extension for .Net Application development the recompile ur c lib code on .Net with managed optio
or if u want to use unmanaged c extension lib code then use unmanaged option in ur .Net development environment.
Nov 17 '05 #3
I have read this article in detail and have gone through their
recommendations, but it doesn't
help. The library that I am linking with statically does not contain an
entry point for "main", it
is a "lib", so this really doesn't make to much sense.

The article states:

-------------
Managed Extensions for C++ projects that are created as DLLs by default do
not link to native C/C++ libraries such as the C run-time (CRT) library,
ATL, or MFC and do not use any static variables. Additionally, the project
settings specify that the DLLs should be linked with the /NOENTRY option
enabled.
-------------

What does that mean? I won't be able to link with my C library at all. I do
have the /NOENTRY option in my project
settings.

Any other options?

Thanks
Paul
"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl...
"Paul Brun" <pb**********@pbrun.net> wrote in message
news:u1**************@TK2MSFTNGP10.phx.gbl...
I would like to find out if :
1) Is the above possible?


Yes, it is.
I have tried to wrap a C library that our company produces in a .Net class library and am receiving the
following error:

LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol
_main referenced in function _mainCRTStartup


Can it be that this issue is biting you:
http://support.microsoft.com/?id=814472

Regards,
Will

Nov 17 '05 #4
However, if I compile without the managed option, then I won't be able to
have a VB application use the class, right?

Paul

"Rakesh Khanduja" <ra*************@hotmail.com> wrote in message
news:12**********************************@microsof t.com...
Hi,
If u r using a managed extension for .Net Application development the recompile ur c lib code on .Net with managed option or if u want to use unmanaged c extension lib code then use unmanaged

option in ur .Net development environment.
Nov 17 '05 #5
My suggestion:

1) try getting the unmanaged DLL compiled all by itself without any
errors as part of the .NET solution.
if you have problems making this work, take the unmanaged project file used by Microsoft and replace the source files within it with your files.


2) decide whether or not you are going to use a proxy layer DLL that
has the managed to unmanaged C++ class mappings, or are you going to
call the unmanaged code directly from your managed code

3) start with one small test case from your .NET application and get
it to work so that you know you are doing the basics right

For the managed project that you start, remember to select "debug
unmanaged" code if you want to be able to step into unmanaged code
from your managed code.

Good luck.

Frank
Nov 17 '05 #6

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

Similar topics

1
by: Mark McEahern | last post by:
I just wrote a very simple wrapper for the PayFlow Pro SDK (see below). A friend of mine did this before, but I didn't have access to his source, so I took it as a learning opportunity for me to...
5
by: Fred Paris | last post by:
Hi I'm writing a class to act as a wrapper around a C library. This C library exposes functions like: SetSomeInfo( char *pTheInfo ); In my wrapper class, the info in question is in a STL...
5
by: niidjan | last post by:
I would like to know more about C++ wrappers. What is a wrapper object in C++ and why is it neccessary? I am trying to create a templated linked list data structure to store any object or primitive...
19
by: C# Learner | last post by:
What's a nice way to create a non-blocking pause in execution? Will I need to use some kind of timer for this, or is there a nicer way?
0
by: Brandon Langley | last post by:
I'm trying to utilize some code written in a C# class library (DLL) via a C++ wrapper. The reason for the C++ wrapper is to make the code available from within a Wise dialog, which only allows...
4
by: Stephen | last post by:
Hi I am currently developing a web application that has a third party component on it. The third party component is a graph component from Xceed that uses a number of dlls. The problems occur...
3
by: markww | last post by:
Hi, I have a wrapper around some 3rd party database library function. The pseudo code looks like the following - it is meant to open a table in a database, extract values from a table, then copy...
16
by: utab | last post by:
Dear all, In programming terminology, what is a wrapper and where is it used? Regards
9
by: ma740988 | last post by:
Assume I have a vendor file called ' vendor.h'. Within the file there's two methods memalign and cforward. It is my understanding that the memalign function is a wrapper around malloc. cforward...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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
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
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,...

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.