Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Receive error LNK2019: unresolved external symbol "_declspec(dllimport

Status
Not open for further replies.
Apr 9, 2007
3
US
Hi,



I'm trying to build a simple C++ program using Visual C++ 2005 Express Edition and I'm running into these errors. I followed the instructions according to this link

and I still have problems. Here is the code I'm trying to build...


Code:
#include <iostream>

void main()

{
std::cout << "\n Hello World. \n"; 
std::cout << std::endl;
}

Here is the output.


1>Linking...

1>Test3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std:: operator<<<char,struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (__imp_??$?6DU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z) referenced in function _main

1>C:\Documents and Settings\Kevin\My Documents\Visual Studio 2005\Projects\Test\Debug\Test3.exe : fatal error LNK1120: 1 unresolved externals

1>Build log was saved at file://c:\Documents and Settings\Kevin\My Documents\Visual Studio 2005\Projects\Test\Test3\Debug\BuildLog.htm


I've read many similar posts but all of the solutions didn't work for me. Please help.



Thanks
 
Strange... That program should compile just fine. (although technically main() should always return an int, even though some compilers allow void).

Can you go into your Project Settings and post what you have in the C/C++ & Linker "Command Line" panels. Maybe some of those settings got messed up?

You've already tried doing a "Build->Clean Solution", and then rebuilding right?
 
Hey cpjust,

yeah, i just tried cleaning the solution and then rebuilding. I still get the same error.

Here is the configuration in the Linker 'command line' panel...

/OUT:"C:\Documents and Settings\Kevin\My Documents\Visual Studio 2005\Projects\Test\Debug\Test2.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\Test2.exe.intermediate.manifest" /DEBUG /PDB:"c:\Documents and Settings\Kevin\My Documents\Visual Studio 2005\Projects\Test\debug\Test2.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /ERRORREPORT:pROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib

Thanks for your help
 
Hey cpjust,

so i just found the solution. I needed to include the path to the msvcprt.lib file in my linker options. Apparently, it was looking for the msvcprtd.lib instead. After i made the configuration change, it worked. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top