Linker error: unresolved external symbol
Hi,
I am trying to port unix code to windows using VC++ 6.0.
I have been able to somehow compile the code. The problem is now that I am getting some linker errors which I don't know why. Following is a list of some of those errors:
Code:
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall ofstream::ofstream(void)" (__imp_??0ofstream@@QAE@XZ)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ofstream::`vbase destructor'(void)" (__imp_??_Dofstream@@QAEXXZ)
Decision.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ofstream::`vbase destructor'(void)" (__imp_??_Dofstream@@QAEXXZ)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ostream & __thiscall ostream::operator<<(char)" (__imp_??6ostream@@QAEAAV0@D@Z)
Decision2.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ostream & __thiscall ostream::operator<<(char)" (__imp_??6ostream@@QAEAAV0@D@Z)
Decision.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ostream & __thiscall ostream::operator<<(char)" (__imp_??6ostream@@QAEAAV0@D@Z)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class ostream_withassign cerr" (__imp_?cerr@@3Vostream_withassign@@A)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class filebuf * __thiscall ofstream::rdbuf(void)const " (__imp_?rdbuf@ofstream@@QBEPAVfilebuf@@XZ)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ofstream::open(char const *,int,int)" (__imp_?open@ofstream@@QAEXPBDHH@Z)
TimerU.obj : error LNK2001: unresolved external symbol _getrusage
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall ios::precision(int)" (__imp_?precision@ios@@QAEHH@Z)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall ios::width(int)" (__imp_?width@ios@@QAEHH@Z)
TimerU.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall ofstream::close(void)" (__imp_?close@ofstream@@QAEXXZ)
GMClass.obj : error LNK2001: unresolved external symbol __imp__fprintf
GMClass.obj : error LNK2001: unresolved external symbol __imp__system
GMClass.obj : error LNK2001: unresolved external symbol __imp__freopen
GMClass.obj : error LNK2001: unresolved external symbol __imp__fgetc
In addition I am also getting the following warnings:
Code:
LINK : warning LNK4049: locally defined symbol "_exit" imported
LINK : warning LNK4049: locally defined symbol "_strtok" imported
LINK : warning LNK4049: locally defined symbol "_fgets" imported
LINK : warning LNK4049: locally defined symbol "_strstr" imported
Could someone plz help me out?
Thanks
Zeato
Re: Linker error: unresolved external symbol
Any thoughts folks?
Zeato
Re: Linker error: unresolved external symbol
Well, what are your link settings? It looks like you're not linking in a C runtime library.
Viggy
Re: Linker error: unresolved external symbol
I have defaults except that I added libc.lib. Following is the complete list:
Quote:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LIBC.LIB
Thanks
Zeato
Re: Linker error: unresolved external symbol
Hmm, mine are the same. It does look like you've got all the LIB files listed twice. However, that wouldn't be why your link is failing.
Are you using a Microsoft compiler? What version? LIBC.LIB is a release mode CRT, for single threaded apps. If you're compiling in debug mode, this library will not work. Also, this library would automatically be linked in, if you compile with the /ML command line option.
Here's a link to the CRT libraries. Incidentally, 'libc.lib' is not shipped with Dev Studio 7.x (.NET).
Viggy
Re: Linker error: unresolved external symbol
Hi,
It appears that it is something that is more complicated than that. I tried compiling it in release build with no success. Same is the case with removing libc.lib altogether (note that I do have /ML option).
I have never experienced such a problem and as you can see the problem is with the very basic functions like fprintf, fgetc, etc. Also, if you notice, linker has something prepended to the function names e.g., __imp__fgetc.
Any suggestions?
Zeato
Re: Linker error: unresolved external symbol
What compiler are you using?
Viggy
Re: Linker error: unresolved external symbol
Microsoft Visual C++ 6.0
Zeato
Re: Linker error: unresolved external symbol
I have posted my project @ the following URL:
http://www.geocities.com/dr_zeato/GMTDemo.zip
Thanks
Zeato