vector<string> causes LNK2005/4006 errors 
Author Message
 vector<string> causes LNK2005/4006 errors

I get a LNK2005 error when this single line of code is added to a source
file.

     vector <string> List;

The error output is:

nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void

nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator

second definition ignored

I have tried various combinations of "include", "exclude" and "force" in the
Project|Settings|Link dialog, but everything I've tried makes things worse.

I also tried this,

     vector<string> *pList = new vector<string>;

and got the same error.

I get the same thing whether the code is inside an extern "C" block or not,
or whether its a local or global declaration.

Is there some secret combination/sequence of libraries that will fix this?
Or do I need some update for a buggy library?

Steve



Sun, 18 Apr 2004 06:44:15 GMT  
 vector<string> causes LNK2005/4006 errors
I believe it's a link order thing. You have to make sure that nafxcwd.lib (the
MFC library) is linked before libcpmtd.lib (the 'STL' library).

I can't remember the details. Good luck.

Quote:

> I get a LNK2005 error when this single line of code is added to a source
> file.

>      vector <string> List;

> The error output is:

> nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void

> nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator

> second definition ignored

> I have tried various combinations of "include", "exclude" and "force" in the
> Project|Settings|Link dialog, but everything I've tried makes things worse.

> I also tried this,

>      vector<string> *pList = new vector<string>;

> and got the same error.

> I get the same thing whether the code is inside an extern "C" block or not,
> or whether its a local or global declaration.

> Is there some secret combination/sequence of libraries that will fix this?
> Or do I need some update for a buggy library?

> Steve



Sun, 18 Apr 2004 07:17:41 GMT  
 vector<string> causes LNK2005/4006 errors
Ok, so I added nafxcwd.lib and libcpmtd.lib (in that order) to both
Project|Settings|Link|Object/Library modules, and
Project|Settings|Link|Ignore Libraries.  I no longer get the LNK2005 error,
which is good because now it will create the DLL.  But I still get the
LNK4006 error.

Since I can build the DLL now, it's no longer a critical problem, but I'd
like to be able to get rid of that annoying LNK4006 warning.

Anyone have any other suggestions?

Steve


Quote:
> I believe it's a link order thing. You have to make sure that nafxcwd.lib
(the
> MFC library) is linked before libcpmtd.lib (the 'STL' library).

> I can't remember the details. Good luck.


> > I get a LNK2005 error when this single line of code is added to a source
> > file.

> >      vector <string> List;

> > The error output is:

> > nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator
delete(void

> > nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator


libcpmtd.lib(delop.obj);

- Show quoted text -

Quote:
> > second definition ignored

> > I have tried various combinations of "include", "exclude" and "force" in
the
> > Project|Settings|Link dialog, but everything I've tried makes things
worse.

> > I also tried this,

> >      vector<string> *pList = new vector<string>;

> > and got the same error.

> > I get the same thing whether the code is inside an extern "C" block or
not,
> > or whether its a local or global declaration.

> > Is there some secret combination/sequence of libraries that will fix
this?
> > Or do I need some update for a buggy library?

> > Steve



Sun, 18 Apr 2004 22:44:27 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. <<<<<<<Parsing help, please>>>>>>>>

2. attempt to #include <algorithm> and <vector> cause compilation errors

3. vector<string> data loss

4. problem with vector <string>

5. Warnings for std::vector<std::string>

6. vector <string>

7. Wrong constructor used for vector<string>.

8. typedef std::vector<std::string> Vector_String

9. question from vector<string>

10. convert string to vector<char>

11. vector<std::string>

12. Compiler warning with vector<string>

 

 
Powered by phpBB® Forum Software