472,779 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

std::map<std::string, std::string> produces complie errors Managed C++ Class Library


I having having oodles of trouble using the std lib in my MC++ (VS.NET
2003) Class library. I figured out a simple sample to reproduce the
errors I am having. Create a MC++ (VS.NET 2003) class library and type
in the following code below:

#include <map>

using std::string;
using std::map;

using namespace System;
using namespace std;

namespace ManagedLib
public __gc class Class1

void DoNativeHashMap()
std::map<std::string,std::string> x;

when I go to complie this I get the following errors:

LINK : error LNK2020: unresolved token (0A000008) ??_7type_info@@6B@
LINK : error LNK2020: unresolved token (0A000009) _CxxThrowException
LINK : error LNK2020: unresolved token (0A00000A) exception.__ctor
LINK : error LNK2020: unresolved token (0A00000C) exception.__dtor
LINK : error LNK2020: unresolved token (0A00000E) delete
LINK : fatal error LNK1120: 5 unresolved externals

Ok so I figured this must have something to do with std::map because
when I just have std::string everything is beautiful.

So I add a reference to msvcrtd.lib (for debug config) and msvcrt.lib
(for release config) thinking that would do the trick then the errors
go awy but I then get this warning (not error):

ibcpmtd.lib(xlock.obj) : warning LNK4210: .CRT section exists; there
may be unhandled static initializers or terminators

I looked on the msdn site and found something about Converting Managed
Extensions for C++ Projects from Pure Intermediate Language to Mixed
Mode ->


I just can't imagine this is what one would have to do to use teh
std::map or std::set in a MC++ class library...

Can someonw confirm this...Please say it aint so :(

Help help would definitely be appretiated..



Nov 23 '05 #1
1 3624
Ok, So I did some additonal playing around after lookiing through that
MS article like 34 times while pulling my hair out :). I think i might
have answered my own question, but can anyone confirm this behavor?
Again I I am trying to do is us objects in the standard template lib no
fancy win32 API calls or AFX stuff, etc. Just stuff like std::list,
std::string, std::map, std::vector, etc. Everything complied and
"seems" to be running fine. I guess the only thing I did not do is add
the entry points song and dance and call some kind of ::intialize and
::terminate method as they described in the MS article.

I am a little worried (even though everything is working right now)
that because I didnt initialize the whatever static library variables
that CRT might require via ::intialize and ::terminate that I might run
into problems but figured since I am only trying to use the basic
std::string, std::map, etc type stuff that it shouldn't be a problem?

Anyway Here is what I did:

Went to the project properties pages ->Linker->Input:
1. Added __DllMainCRTStartup@12 to Force Symbol References
2. Added msvcrt.lib and msvcrtd.lib to Release and Debug configurations
3. Removed the nochkclr.obj
4. Add /noentry to the Additional Options field of the Command Line

Can Anyone confirm this or have they tried to access std::map in
managed c++ in vs.net2003?

Nov 26 '05 #2

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

Similar topics

by: gipsy boy | last post by:
// -- using namespace std; map<string,string> formMap; list<string> formParams; for(list<string>::iterator fit = formParams.begin(); fit!=formParams.end(); fit++) { cout << "key=" << *fit;...
by: Peter Jansson | last post by:
Hello, I have the following code: std::map<int,std::set<std::string> > k; k="1234567890"; k="2345678901"; //... std::set<std::string> myMethod(std::map<int,std::set<std::string> > k)...
by: jstanforth | last post by:
This is probably a very obvious question, but I'm not clear on what operators need to be implemented for std::map.find() to work. For example, I have a class MyString that wraps std::string, and...
by: Erik Wikström | last post by:
First of all, forgive me if this is the wrong place to ask this question, if it's a stupid question (it's my second week with C++), or if this is answered some place else (I've searched but not...
by: lada77 | last post by:
All, Just wondering if one of you very helpful guru's out there could comment on some odd behaviour I am seeing. I'm betting it is something obvious but I am not experienced enough to tell...
by: brzozo2 | last post by:
Hello, this program might look abit long, but it's pretty simple and easy to follow. What it does is read from a file, outputs the contents to screen, and then writes them to a different file. It...
by: jabbah | last post by:
I have some data in a map and I want to sort it. Currently I have implemented it like this: #include <iostream> #include <map> #include <string> using namespace std; int main(){
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.