?
Solved

Compiling & linking a multi-threaded program

Posted on 1998-09-21
8
Medium Priority
?
472 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 140 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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
 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

755 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