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
Solved

Compiling & linking a multi-threaded program

Posted on 1998-09-21
8
449 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 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