Solved

Compiling & linking a multi-threaded program

Posted on 1998-09-21
8
432 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:tanmh
Comment Utility
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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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

11 Experts available now in Live!

Get 1:1 Help Now