Solved

Compiling & linking a multi-threaded program

Posted on 1998-09-21
8
438 Views
Last Modified: 2013-12-14
hi,
I set up the project settings according to VC++ InfoView. But when I build the program, I get the following errors:

libcimtd.lib(streamb.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z)

libcimtd.lib(ifstream.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z)

libcimtd.lib(iostrini.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z)

libcimtd.lib(cerrinit.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z)

libcimtd.lib(filebuf1.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z)

Pls advise what is wrong. Is there anything wrong with the way i compile/link the program? Are there special libraries or include files that I must add? Do I have add anything to the Program settings?

Thanks and regards,
Andrea
0
Comment
Question by:tanmh
8 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1173208
Is this for a debug or release version?  I think that is the debug version of operator new, which might not be availalble in a release version ofthe libraries.  This might happen if you use an incorect preprocessor symbol (#define) in a release version.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1173209
For example, if you have the line "#define new DEBUG_NEW" in the source code for a release version, it might do this.  You could also have this specified in the project's settings under te C++ tab in the "Preprocessor Definitions" box.

Is this an MFC project?
0
 

Accepted Solution

by:
juerg earned 70 total points
ID: 1173210
You have to set following:
Project, Settings.., C++, Category: Code Generation
 use runTime library = MultiThreaded.

Do This for release and debug

Regards
 Juerg
0
 

Expert Comment

by:helenag
ID: 1173211
I wrote a program yesterday and I met the same problem. The tip is to compile all the files that includes the program separate and then build it! Try this tip!
greatest regards Helena
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:tanmh
ID: 1173212
hi all,
thanks for all your comments.
pardon my ignorance but how do I check if mine is a release/debug version? My project is a Win 32 console application, not MFC.

Juerg & Helena, I've tried your suggestions, but still the errors appear.
Nietod, there are no #define in my files.

Regards,
Andrea
0
 
LVL 22

Expert Comment

by:nietod
ID: 1173213
>> how do I check if mine is a release/debug version?
Go to the "Build" menu and then the "Set Active Configuration" item.  A dialog will appear that lists the configurations and shows the current one highlighted.

What is "libcimtd.lib"  Is this a lib file you created from your own source code?  Or is it an external library written by someone else that is being linked in?  If the later, I think it was written to be used from a debug build that has the new operator overloaded.
0
 

Author Comment

by:tanmh
ID: 1173214
hi,
Nietod, below is the answer to your question which I've extracted
from the help files.
----------------------------------------------------------------
Two sets of iostream functions are now included in Visual C++. The old iostream functions now exist in their own libraries: LIBCID.LIB, LIBCIMTD.LIB, and MSVCIRTD.LIB. The new iostream functions, as well as many other new functions, exist in the Standard C++ libraries: LIBCPD.LIB, LIBCPMTD.LIB, and MSVCPRTD.LIB.

C Run-Time
Debug Library
(without iostream)   Characteristics  Option  Defined
------------------   ---------------  ------  -------
LIBCMTD.LIB          Multithreaded,   /MTd    _DEBUG,
                     static link              _MT    

------------------------------------------------------------

By the way, I've solved the linking problem by setting my project
to Release instead of Debug + the settings suggested by Juerg. And I use _beginthread & _endthread instead of CreateThread.

But I don't know why it doesn't work under Debug version.

Andrea












0
 
LVL 22

Expert Comment

by:nietod
ID: 1173215
I think the problem must be that you explicitly entered this .lib file to be linked into your project.  You shouldn't need to do that.  VC will do it automatically.  That way it will choose the right one to be linked in dependig on whethor or not you are creating a debug or release version.  

Make sure this library isn't listed in the project workspace.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 114
Dynamically allocate memory 9 56
Safe conversion? 4 58
show out valin of json for debugging in visaul c++ 1 16
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now