Link errors building rather simple application which uses C++ IO facilities

From: Ney André de Mello Zunino (zunino_at_inf.ufsc.br)
Date: 06/21/04


Date: Sun, 20 Jun 2004 23:32:50 -0300

Hello.

I am having trouble building a simple project that uses one of the
Standard C++ Library's IO facilities. The following is a stripped-down
version that illustrates the problem:

[beginning of sample program]
#include <fstream>

int main(int argc, char* argv[])
{
   std::ofstream saida("saida.txt");
}
[end of sample program]

This is the makefile I am using to build it:

[beginning of makefile]
proj = teste
libspadrao = kernel32.lib msvcrt.lib msvcprt.lib

opcomp = /c /EHs /G7 /WL /MT
oplink = /incremental:no /subsystem:windows /release /nodefaultlib
/verbose:lib

$(proj).exe: $(proj).obj
   link $(oplink) $(libspadrao) $(proj).obj

$(proj).obj: $(proj).cpp
   cl $(opcomp) $(proj).cpp
[end of makefile]

And finally, this is the undesirable output I get from the linker. I
tried using dumpbin in order to find where the missing symbols are
defined, but to no avail.

[beginning of relevant linker output]
quadrado.obj : error LNK2019: unresolved external symbol "long const
std::_BADOFF" (?_BADOFF@std@@3JB) referenced in function "protected:
virtual class std::fpos<int> __thiscall std::basic_streambuf<char,struct
std::char_traits<char> >::seekoff(long,int,int)"
(?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE
?AV?$fpos@H@2@JHH@Z)

quadrado.obj : error LNK2019: unresolved external symbol "__int64
std::_Fpz" (?_Fpz@std@@3_JA) referenced in function "public: __thiscall
std::fpos<int>::fpos<int>(long)" (??0?$fpos@H@std@@QAE@J@Z)

quadrado.obj : error LNK2019: unresolved external symbol "public: static
class std::locale::id std::ctype<char>::id"
(?id@?$ctype@D@std@@2V0locale@2@A) referenced in function "class
std::ctype<char> const & __cdecl std::use_facet<class std::ctype<char>
>(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@Y
AABV?$ctype@D@0@ABVlocale@0@@Z)

quadrado.obj : error LNK2019: unresolved external symbol "private:
static int std::locale::id::_Id_cnt" (?_Id_cnt@id@locale@std@@0HA)
referenced in function "public: __thiscall std::locale::id::operator
unsigned int(void)" (??Bid@locale@std@@QAEIXZ)

quadrado.exe : fatal error LNK1120: 4 unresolved externals
[end of relevant linker output]

What is missing in my build setting? Shouldn't msvcprt.lib include the
C++'s IO-related symbols which are said to be missing?

Thank you,

-- 
Ney André de Mello Zunino


Relevant Pages

  • Re: compiling external modules
    ... excuse me, I've found the reason for the missing ... exported symbols in the C-source. ... I will continue simplifying the Makefile... ... Regards, ...
    (Linux-Kernel)
  • makefile delimma
    ... Each of the tasks call a seperate makefile. ... Each of these individual tasks are dependant of several files within a ... one to run and one to report missing data. ... So I need to have wrappers that will take unvalidated input. ...
    (comp.unix.programmer)
  • Re: nmap 4.03 compile failing under hp-ux 11.11
    ... your Makefile is missing a library dependency. ... text/plain ...
    (comp.security.unix)
  • Re: [SLE] Compiling Perl Modules (Frequencies.pm) and IVTV
    ... > This call is missing the -fPIC. ... You'd have to check the Makefile to see ... > shared library needs to be compiled as position independent code. ... appears in the RTjpeg makefile, but when I run it I still get the exact same ...
    (SuSE)

Loading