Compiling & linking a multi-threaded program

Posted on 1998-09-21
Last Modified: 2013-12-14
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,
Question by:tanmh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 22

Expert Comment

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

Expert Comment

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?

Accepted Solution

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

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

Author Comment

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.

LVL 22

Expert Comment

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.

Author Comment

ID: 1173214
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.


LVL 22

Expert Comment

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.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

724 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