Running "Who's Afraid of C++?" code on Visual C++ program : LUSENET : Steve Heller's books : One Thread

I'm running Visual C++ version 5.0 on Windows98.

In trying to run the program (p. 85, Who's Afraid of C++? 1st edition), I receive the following compile errors:

Compiling... basic02.cpp Linking... basic02.obj : error LNK2001: unresolved external symbol "public: __thiscall string::~string(void)" (??1string@@QAE@XZ) basic02.obj : error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class string const &)" (??6@YAAAVostream@@AAV0@ABVstring@@@Z) basic02.obj : error LNK2001: unresolved external symbol "class istream & __cdecl operator>>(class istream &,class string &)" (??5@YAAAVistream@@AAV0@AAVstring@@@Z) basic02.obj : error LNK2001: unresolved external symbol "public: __thiscall string::string(void)" (??0string@@QAE@XZ) Debug/basic02.exe : fatal error LNK1120: 4 unresolved externals Error executing link.exe.

basic02.exe - 5 error(s), 0 warning(s)

I've placed the "string6.h" header file in the same file with the rest of the source code and other files.

Is there an easy fix so that not only this program, but the remaining code in Who's Afraid of C++?, will run on Visual C++? Thx!

P.S. Great book!

-- Joe Wiggins (, April 17, 1999


Hi Joe,

I had the same problem. You can build any of the programs from "WAOC++?" book using VC++ 5.0 (same version I'm using). Just ensure you add the directory that contains Steve's "stharch.a" library to the VC++ library search path. Do the same thing for the includes, because Steve supplies other files that are needed for building the projects, such as a version of assert called wassert.h, also common.h, and more as you know. So VC++ will need to know where to find all of these files when the time comes to build your projects.

Best Regards,


-- Mac (, April 19, 1999.



Try this. It's not the easiest, but it does work:

1. Create a new project (basic02 or as applicable). 2. Place any headers that are needed to build the project into the directory with your other source files (the project directory). THIS STEP IS THE KEY. Ensure you place all needed files in the project directory. (In this case:,, string6.h). The way you determine this is by checking each file to see which headers are required 3. Insert into your project the source file(s) to be compiled. In this case and header file(s) do(es) not get compiled). To do this, choose Project>Add to Project>Files... 4. One note of caution: You must ensure that your #include statements tell the compiler where to look "" means project directory, <> means default include directory.

Let me know if you have any other questions... or if you figure out a better way of doing this.

Best Regards,


-- Mac (, April 21, 1999.


I just found an even easier way to build these projects in Visual C++ 5.0.

1. Under Tools>Options>Directories>Show Directories for:>Include files, add the directory that contains Steve Heller's includes (e.g., c:\djgpp\whos\code or similar)

2. Under Tools>Options>Directories>Show Directories for:>Library files, add the directory that contains Steve Heller's stharch.a library (e.g., c:\djgpp\lib or similar)

3. Place your project files into the Visual C++ project directory (e.g., C:\Program Files\DevStudio\MyProjects\WAoCpp\basic02). You do not need to move the header and library files -- we took care of them in steps one and two.

4. Insert the project's .cc files into the project using Project>Add to Project>Files...

I think this is where you had your problems last time -- you may have forgotten to insert into the project. This file is the implementation of the string6.h file, so it will certainly need to be compiled with the project.

5. You can leave the header and library files in their respective directories, a you told Visual C++ where to find them in steps one and two above.

This method works and is easier to use than my last Email's method. Good luck.

Best Regards,


-- Mac (, April 22, 1999.

Moderation questions? read the FAQ