Re: LNK2019: unresolved external symbol "__declspec(dllimport)
 
Ed Dana <EDanaII@Cox.net> wrote:
OK, as a C++ newbie, can someone tell me why this program:
========================================
#include <iostream>
using namespace std;
int Test(int argc, char *argv[]) {
  std::cout << "'Sup, Holmes?";
  return 0;
}
========================================
generates this error:
========================================
Error 1 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  main.obj
========================================
I don't know.  Your program compiled, linked, and executed for me
error-free, once I changed "Test" to "main", as you also apparently did
(given the last line of the error).
C:\tmp>cat x.cpp
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
   std::cout << "'Sup, Holmes?";
   return 0;
}
C:\tmp>cl /EHsc x.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for
80x86
Copyright (C) Microsoft Corporation.  All rights reserved.
x.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.
/out:x.exe
x.obj
C:\tmp>x
'Sup, Holmes?
C:\tmp>
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.