Re: Debug/Fig06_05.exe : fatal error LNK1120: 4 unresolved externals by Doug
Doug
Mon Jun 21 11:31:35 CDT 2004
m wrote:
>i run my program i have this error (i have #include "time.h" in my
>file )
>
>w--------------------Configuration: Fig06_05 - Win32
>Debug--------------------
>Linking...
>Fig06_05.obj : error LNK2001: unresolved external symbol "public: void
>__thiscall Time::setTime(int,int,int)" (?setTime@Time@@QAEXHHH@Z)
>Fig06_05.obj : error LNK2001: unresolved external symbol "public: void
>__thiscall Time::printStandard(void)" (?printStandard@Time@@QAEXXZ)
>Fig06_05.obj : error LNK2001: unresolved external symbol "public: void
>__thiscall Time::printMilitary(void)" (?printMilitary@Time@@QAEXXZ)
>Fig06_05.obj : error LNK2001: unresolved external symbol "public: __thiscall
>Time::Time(void)" (??0Time@@QAE@XZ)
>Debug/Fig06_05.exe : fatal error LNK1120: 4 unresolved externals
>hen
Usually errors like that indicate you've declared but not defined the
functions, yet someone is trying to use them. Where are the functions
defined?
Note also there is a Standard C header time.h, which you should reference
with:
#include <time.h>
It has nothing to do with the linker errors you reported. If you have named
one of your own headers time.h, and you're using VC6 or earlier, you may be
running into a problem with the VC6 build system's dependency tracking.
There is a file sysincl.dat which contains names of files that should be
excluded from dependency checking, and it nominally contains the names of
system headers, which should change only when you update your compiler and
need to recompile the world anyway. Unfortunately, the names in sysincl.dat
don't refer to just system headers, but instead refer to like-named files
wherever they occur. So if you have your own time.h, and you update it,
files which #include it may not be recompiled, if that's the only reason to
build them. Solution? Either avoid the names in sysincl.dat, or do what I do
and rename sysincl.dat to take it out of the equation. The file is typically
found here:
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\SYSINCL.DAT
I rename it to "del.SYSINCL.DAT.del", and if you do rename it, IIRC you have
to exit the IDE and do a "Rebuild All" when you return to it. To test it,
you can modify your local time.h file (NOT the system header!) and see if it
triggers a rebuild.
This problem was fixed in VC.NET, which excludes specific directories from
dependency checking.
--
Doug Harrison
Microsoft MVP - Visual C++