473,703 Members | 2,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "DoomedTest er") 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\no chkclr.obj' or at 'C:\Projects\Do omed\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(crt 0.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.cp p 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.ex e

BUG #4: I get the following exception

An unhandled exception of type 'System.StackOv erflowException ' 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.cp p, 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.ex e

BUG #6: I receive the following runtime error

Debug Error
Program c:\projects\doo med\debug\Doome dTester.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 6551
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 "DoomedTest er") 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\no chkclr.obj' or at 'C:\Projects\Do omed\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(crt 0.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.cp p 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.ex e

BUG #4: I get the following exception

An unhandled exception of type 'System.StackOv erflowException ' 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.cp p, 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.ex e.

BUG #6: I receive the following runtime error:

Debug Error!
Program c:\projects\doo med\debug\Doome dTester.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*******@discu ssions.microsof t.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
4326
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 (0600000E) PatInfo::.ctor LINK : error LNK2020: unresolved token (0600000F) PatInfo::Finalize LINK : fatal error LNK1120: 2 unresolved externals I've striped everything out of this library except for the single class which has an empty constructor...
0
1247
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 need. Despite having /INCREMENTAL in the options, and despite not breaking any of the documentation criteria for incremental linking, it just refuses to do it. With /TEST and /VERBOSE I see the text below, and I don't understand why it's invoking...
0
1656
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 into seems trivial enough, but a solution I've yet to find. I get the following errors when trying to compile may application... error LNK2001: unresolved external symbol "public: virtual class ATL::CStringT<char,class...
12
3471
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 projects for Lua 5.0.2 and LuaBind beta-6, compiling both with no CLR support and configured to use the Multithreaded DLL runtime. Then I created a new console application which makes use of these two static libraries (of course, also set to MT...
6
3841
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), the linker errors occur: error LNK2005: "void * __cdecl operator new(unsigned int)"(??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
10
2682
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 .NET2003. also, when I do not try to link the fortran library (just to see if that was the cause), it builds the exe without any problems. i don't even know how to begin addressing this problem...any help would be
5
2052
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 could add "/test" to the linker options and it would tell me why it was causing it to re-link (full link). This is what I get. Linking... LINK : file alignment: 512, section alignment: 4096 LINK : LINK options changed; performing full link LINK...
1
2202
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>------ Build started: Project: testcon, Configuration: Debug Win32 ------ 1>Linking... 1>libcmtd.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 1>C:\SAMPLES\testcon\Debug\testcon.exe : fatal error...
1
2306
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 Settings\chirag.patel\Desktop\Game\GameTest\Debug\GameTest.exe 1 Error 2 error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) uafxcwd.lib Error 3 error LNK2005: "void * __cdecl operator new(unsigned int)"...
0
8660
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8955
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
7849
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
6585
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
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4419
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...
0
4675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2430
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2056
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.