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

Bugs & runtime error linking with LIBCMTD.DLL in Managed C++

Hello everyone

I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems

1. Using the New Project wizard, generate a Visual C++ .NET Class Library project (call it "Doomed") and a VC++ .NET Console Application as a tester (call it "DoomedTester") for the Class Library project. Compile both

BUG #1: When compiling the Doomed class library project, the linker yields the following warning

nochkclr.obj : warning LNK4099: PDB 'libc.pdb' was not found with 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\nochkclr.obj' or at 'C:\Projects\Doomed\Debug\libc.pdb'; linking object as if no debug inf

2. Add the following code to Doomed.h inside Doomed::Class1

file: Doomed.
-------------
// Doomed.

#pragma onc

using namespace System

namespace Doome

public __gc class Class

public: // Add thi
static void f(); // Add thi
}
3. Add the following code to Doomed.cpp and recompile

file: Doomed.cp
---------------
// This is the main DLL file

#include "stdafx.h
#include <cstdio> // Add thi
#include "Doomed.h

// Add the following code
namespace Doome

void Class1::f(

printf("%f", 1.0)

4. The linker can't resolve printf(), so add LIBCMTD.LIB to Linker->Input->Additional Dependencies, and relink

BUG #2: The linker returns with the following error

LIBCMTD.LIB(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartu

(Note: This could be resolved by linking with MSVCRTD.LIB instead, but this isn't what I want to do.

5. Add the dummy code "int main() {}" to Doomed.cpp and rebuild, which resolves the above linker error

BUG #3: The compiler didn't notice that my dummy main() isn't returning a value

6. Add the following code to DoomedTester.cpp and rebuild

file: DoomedTester.cp
---------------------
// This is the main project file for VC++ application project
// generated using an Application Wizard

#include "stdafx.h

#using <mscorlib.dll
#using <Doomed.dll> // Add thi
using namespace System

int _tmain(

Doomed::Class1::f(); // Add thi
return 0
7. Run DoomedTester.exe

BUG #4: I get the following exception

An unhandled exception of type 'System.StackOverflowException' occurred in doomed.dl

(Note: Again, this could be resolved by linking with MSVCRTD.LIB instead, but this isn't what I want to do.

8. From MS KB article 814472 (http://support.microsoft.com/?id=814472), follow the "Modify DLL That Contains Consumers That Use Managed Code and DLL Exports or Managed Entry Points" discussion and add ManagedWrapper.cpp to the Doomed project, and add the appropriate calling code to DoomedTester.cpp, and recompile. (Note at this point that I can remove the dummy main() from step 5, since there is code inside ManagedWrapper.cpp that implements DllMain().

BUG #5: The compiler fails with the following error

ManagedWrapper.cpp(46) : fatal error C1010: unexpected end of file while looking for precompiled header directiv

9. Add #include "stdafx.h" to the top of ManagedWrapper.cpp and recompile

10. Run DoomedTester.exe

BUG #6: I receive the following runtime error

Debug Error
Program c:\projects\doomed\debug\DoomedTester.ex
R600
- floating point not loade

At this point, I'm stuck. Is there anything I can do to eliminate this floating-point runtime error?

Thanks very much in advance

Whitney Ke
Software Enginee
Rain Bird Corporatio
http://www.rainbird.com
Nov 17 '05 #1
7 6521
I am reposting this question, because I have not received any response from a Microsoft support engineer. I am an MSDN Universal subscriber; what happened to the "guaranteed" 48-hour response?

Whitney Ke
Software Enginee
Rain Bird Corporatio
http://www.rainbird.co

----- wmkew wrote: ----

Hello everyone

I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems

1. Using the New Project wizard, generate a Visual C++ .NET Class Library project (call it "Doomed") and a VC++ .NET Console Application as a tester (call it "DoomedTester") for the Class Library project. Compile both

BUG #1: When compiling the Doomed class library project, the linker yields the following warning

nochkclr.obj : warning LNK4099: PDB 'libc.pdb' was not found with 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\nochkclr.obj' or at 'C:\Projects\Doomed\Debug\libc.pdb'; linking object as if no debug inf

2. Add the following code to Doomed.h inside Doomed::Class1

file: Doomed.
-------------
// Doomed.

#pragma onc

using namespace System

namespace Doome

public __gc class Class

public: // Add thi
static void f(); // Add thi
}
3. Add the following code to Doomed.cpp and recompile

file: Doomed.cp
---------------
// This is the main DLL file

#include "stdafx.h
#include <cstdio> // Add thi
#include "Doomed.h

// Add the following code
namespace Doome

void Class1::f(

printf("%f", 1.0)

4. The linker can't resolve printf(), so add LIBCMTD.LIB to Linker->Input->Additional Dependencies, and relink

BUG #2: The linker returns with the following error

LIBCMTD.LIB(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartu

(Note: This could be resolved by linking with MSVCRTD.LIB instead, but this isn't what I want to do.

5. Add the dummy code "int main() {}" to Doomed.cpp and rebuild, which resolves the above linker error

BUG #3: The compiler didn't notice that my dummy main() isn't returning a value

6. Add the following code to DoomedTester.cpp and rebuild

file: DoomedTester.cp
---------------------
// This is the main project file for VC++ application project
// generated using an Application Wizard

#include "stdafx.h

#using <mscorlib.dll
#using <Doomed.dll> // Add thi
using namespace System

int _tmain(

Doomed::Class1::f(); // Add thi
return 0
7. Run DoomedTester.exe

BUG #4: I get the following exception

An unhandled exception of type 'System.StackOverflowException' occurred in doomed.dl

(Note: Again, this could be resolved by linking with MSVCRTD.LIB instead, but this isn't what I want to do.

8. From MS KB article 814472 (http://support.microsoft.com/?id=814472), follow the "Modify DLL That Contains Consumers That Use Managed Code and DLL Exports or Managed Entry Points" discussion and add ManagedWrapper.cpp to the Doomed project, and add the appropriate calling code to DoomedTester.cpp, and recompile. (Note at this point that I can remove the dummy main() from step 5, since there is code inside ManagedWrapper.cpp that implements DllMain().

BUG #5: The compiler fails with the following error:

ManagedWrapper.cpp(46) : fatal error C1010: unexpected end of file while looking for precompiled header directive

9. Add #include "stdafx.h" to the top of ManagedWrapper.cpp and recompile.

10. Run DoomedTester.exe.

BUG #6: I receive the following runtime error:

Debug Error!
Program c:\projects\doomed\debug\DoomedTester.exe
R6002
- floating point not loaded
At this point, I'm stuck. Is there anything I can do to eliminate this floating-point runtime error??

Thanks very much in advance,

Whitney Kew
Software Engineer
Rain Bird Corporation
http://www.rainbird.com
Nov 17 '05 #2
wmkew wrote:
I am reposting this question, because I have not received any
response from a Microsoft support engineer. I am an MSDN Universal
subscriber; what happened to the "guaranteed" 48-hour response??


This doesn't answer your original question but ... in regard to the
guaranteed response time for MSDN subscribers, you need to post using an
email address that's known to MSDN. Since you're posting as
an*******@discussions.microsoft.com, you're not recognized as being an MSDN
subscriber. Note that you don't need to post with your real email address -
you can register an email alias (which doesn't need to be a real email
address at all), by going to:

http://support.microsoft.com/default...am.asp&SD=msdn

-cd
Nov 17 '05 #3
wmkew wrote:
Hello everyone,

I'm encountering a R6002 Runtime error and several bugs when trying
to generate a simple Managed C++ application with .NET 2003. The
main problem seems to arise from linking with LIBCMT(D).DLL. (My
requirement is that we can't link with MSVCRT(D).LIB.)


I'm not an expert on MC++, but I seem to recall reading somewhere that you
MUST use the DLL runtime library with MC++. Unfortunately, when I tried to
look up that tidbit of information, I was unable to find it anywhere.

Why is using the DLL CRT not an option for you?

-cd
Nov 17 '05 #4
Hi Carl

Thanks for your answer to my question regarding MSDN - I think I understand how to do it now....

Whitne

Nov 17 '05 #5


----- Carl Daniel [VC++ MVP] wrote: ----

wmkew wrote
Hello everyone
I'm encountering a R6002 Runtime error and several bugs when tryin

to generate a simple Managed C++ application with .NET 2003. Th
main problem seems to arise from linking with LIBCMT(D).DLL. (M
requirement is that we can't link with MSVCRT(D).LIB.


I'm not an expert on MC++, but I seem to recall reading somewhere that yo
MUST use the DLL runtime library with MC++. Unfortunately, when I tried t
look up that tidbit of information, I was unable to find it anywhere

Why is using the DLL CRT not an option for you

-c
Carl

Thanks for your response! I wonder if what you said regarding having to use the dynamic CRT with MC++ is true?! Well, what we're trying to do is to avoid potential DLL Hell with the CRT DLL, since we have to support multiple Windows OSes. That's the reason that we originally wanted to link with the static CRT. We don't want any unpleasant surprises if there's a different version of MSVCRT.DLL on a particular machine from the version with which we did our development. We're working around the static CRT issues by indeed linking with the CRT DLL, but because of that, we were planning to deliver MSVCRT.DLL with our product and place it in our product's current directory

Any thoughts
Whitney Ke
Software Enginee
Rain Bird Corporatio
http://www.rainbird.com
Nov 17 '05 #6
wmkew wrote:
Thanks for your response! I wonder if what you said regarding having
to use the dynamic CRT with MC++ is true?! Well, what we're trying
to do is to avoid potential DLL Hell with the CRT DLL, since we have
to support multiple Windows OSes. That's the reason that we
originally wanted to link with the static CRT. We don't want any
unpleasant surprises if there's a different version of MSVCRT.DLL on
a particular machine from the version with which we did our
development. We're working around the static CRT issues by indeed
linking with the CRT DLL, but because of that, we were planning to
deliver MSVCRT.DLL with our product and place it in our product's
current directory.


Actually, that issue isn't too bad anymore since VC7{.1} doesn't use
MSVCRT.DLL (rather, MSVCR70.DLL or MSVCR71.DLL). Placing the CRT dll in
your application's directory is the recommended deployment strategy. Unlike
MSVCRT.DLL, which exists in 23 versions on different versions of windows,
there is only a single version MSVCR70.DLL (likewise a single version of
MSVCR71.DLL).

-cd
Nov 17 '05 #7


----- Carl Daniel [VC++ MVP] wrote: ----

wmkew wrote
Thanks for your response! I wonder if what you said regarding havin
to use the dynamic CRT with MC++ is true?! Well, what we're tryin
to do is to avoid potential DLL Hell with the CRT DLL, since we hav
to support multiple Windows OSes. That's the reason that w
originally wanted to link with the static CRT. We don't want an
unpleasant surprises if there's a different version of MSVCRT.DLL o
a particular machine from the version with which we did ou
development. We're working around the static CRT issues by indee
linking with the CRT DLL, but because of that, we were planning t
deliver MSVCRT.DLL with our product and place it in our product'
current directory


Actually, that issue isn't too bad anymore since VC7{.1} doesn't us
MSVCRT.DLL (rather, MSVCR70.DLL or MSVCR71.DLL). Placing the CRT dll i
your application's directory is the recommended deployment strategy. Unlik
MSVCRT.DLL, which exists in 23 versions on different versions of windows
there is only a single version MSVCR70.DLL (likewise a single version o
MSVCR71.DLL)

-c

Interesting. Could one of the Microsoft support engineers please weigh in on this topic? I'd like to know for certain if in fact I can't use the static CRT with MC++.
Nov 17 '05 #8

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

Similar topics

1
by: mccoyn | last post by:
I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors: LINK : error LNK2020: unresolved token...
0
by: Steve McLellan | last post by:
Hi, Was wondering whether there's any more info on why the project I'm working on might not be able to link incrementally... as deadlines approach, waiting 3 minutes each link is not what I...
0
by: Tony | last post by:
I have a managed C++ Console Application, and C++ Windows Forms application where I am trying to use an unmanaged header/lib file combo that exposes a class for functionality... The trouble I run...
12
by: Markus Ewald | last post by:
I'm just experimenting around with the VisualC++ 2005 Express Edition Beta and found some strange behavior for which I can't seem to find a workaround. What I've done is set up two static library...
6
by: Marcelo | last post by:
Hello! I am developping a Visual C++ .NET multiple forms application, which uses FTP connection. When I use more than one form, and include the <afxinet.h> library (necessary for FTP connection),...
10
by: Julian | last post by:
I get the following error when i try to link a fortran library to a c++ code in .NET 2005. LINK : fatal error LNK1104: cannot open file 'libc.lib' the code was working fine when built using...
5
by: news.microsoft.com | last post by:
We have recently upgraded from VS2002 to VS2005 and I'm having a problem with the linker always performing a full link even though nothing has changed. In searching the newsgroups I found that I...
1
by: shakthi | last post by:
hi, am very much new to C++ windows programming.i took the foll code from net and just ran on MSVS2005.I get no compliation error.But when i buid it, it shows the foll errors: 1>------...
1
by: patelcm22 | last post by:
Hi, I am facing following errors while building my application. Error 4 fatal error LNK1169: one or more multiply defined symbols found C:\Documents and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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.