473,779 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hello,

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>
#include<string >

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

using namespace System;
using namespace std;

namespace ManagedLib
{
public __gc class Class1
{
public:
Class1(){};
~Class1(){};

void DoNativeHashMap ()
{
std::map<std::s tring,std::stri ng> x;
return;
}
};
};

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

Linking...
LINK : error LNK2020: unresolved token (0A000008) ??_7type_info@@ 6B@
LINK : error LNK2020: unresolved token (0A000009) _CxxThrowExcept ion
LINK : error LNK2020: unresolved token (0A00000A) exception.__cto r
LINK : error LNK2020: unresolved token (0A00000C) exception.__dto r
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(xlo ck.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 ->

http://msdn.microsoft.com/library/de...oMixedMode.asp

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..

Regards

Max

Nov 23 '05 #1
1 3756
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 __DllMainCRTSta rtup@12 to Force Symbol References
2. Added msvcrt.lib and msvcrtd.lib to Release and Debug configurations
respectively
3. Removed the nochkclr.obj
4. Add /noentry to the Additional Options field of the Command Line
page

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

1
6718
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; formMap.insert(make_pair(*fit,*(++fit)));
5
8752
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) throw(std::runtime_error)
13
4642
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 which also implements ==, <, <=, >, >=, etc. (Those operators are tested and working correctly.) If I assign map = "world", it saves the MyString's correctly in the map. But a subsequent call to map.find("hello") returns map.end(). Even more...
19
6165
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 found anything). Here's the problem, I have two sets of files, the name of a file contains a number which is unique for each set but it's possible (even probable) that two files in different sets have the same numbers. I want to store these...
4
11727
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 right away. Here is my code snippet and the results that I am seeing: #include <map> #include <iostream> int
2
2261
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 uses map<and heavy overloading. The problem is, the output file differs from input, and for the love of me I can't figure out why ;p #include <iostream> #include <fstream> #include <sstream>
2
2789
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(){
0
9474
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
10137
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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
9928
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
8959
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...
0
6724
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
5373
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...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
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.