help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading & Linking Error


From: Robert Heller
Subject: Re: Loading & Linking Error
Date: Tue, 18 Jan 2005 00:44:36 +0100

  ubccis@gmail.com,
  In a message on 17 Jan 2005 13:54:01 -0800, wrote :

u> I'm trying to compile VC++ code in GNU gcc (without any modifications).
u> The program compiles in VC++, but we need it to run on a linux box.
u> Is it only the makefile that needs to be fixed, or do I need to correct
u> some of the included libraries?

Fix the makefile first, then if it is still having problems come back. 
At the very least, a whole pile of the errors will go away, leaving a
smaller number to deal with.

u> 
u> -------------------------------------makefile
u> 
u> 
u> TeamMaker : TeamMaker.o Globals.o
u> 
u> cc = g++

This should really be

CXX = g++

u> CFLAGS = -g
u> 
u> 
u> default : TeamMaker
u> 
u> TeamMaker.o : TeamMaker.cpp Team.h Response.h Response.h Student.h
u> WeightInfo.h XMLFile.h
u> $(CC) $(CFLAGS) -c TeamMaker.cpp

$(CXX) $(CFLAGS) -c TeamMaker.cpp

u> 
u> Globals.o : Globals.cpp Globals.h
u> $(CC) $(CFLAGS) -c Globals.cpp

$(CXX) $(CFLAGS) -c Globals.cpp

u> 
u> TeamMaker : Globals.o TeamMaker.o
u> $(CC) -o TeamMaker Globals.o TeamMaker.o

$(CXX) -o TeamMaker Globals.o TeamMaker.o

u> 
u> clean :
u> rm -f *.o *.pdf TeamMaker core
u> 
u> #end
u> --------------------------------globals.cpp
u> 
u> #include "Globals.h"
u> 
u> -------------------------------TeamMaker.cpp
u> 
u> #include <ctime>
u> 
u> ------------------------------XMLFile.h
u> 
u> //XMLFile.h
u> //Defines code for reading a basic XML file
u> 
u> #ifndef XMLFILE_H
u> #define XMLFILE_H
u> 
u> // signed/unsigned mismatch
u> #pragma warning(disable : 4018)
u> // double -> float conversion
u> #pragma warning(disable : 4244)
u> 
u> #include <fstream>
u> #include <iostream>
u> #include <string>
u> #include <vector>
u> #include <stack>
u> #include "StringParser.h"
u> #include "Globals.h"
u> 
u> --------------------------------WeightInfo.h
u> 
u> #ifndef WEIGHTINFO_H
u> #define WEIGHTINFO_H
u> 
u> #include <map>
u> #include <vector>
u> #include "XMLFile.h"
u> 
u> --------------------------------TeamMaker.h
u> 
u> #ifndef TEAMMAKER_H
u> #define TEAMMAKER_H
u> 
u> #include <algorithm>
u> #include <iostream>
u> #include <fstream>
u> #include "Team.h"
u> 
u> --------------------Team.h
u> 
u> #ifndef TEAM_H
u> #define TEAM_H
u> 
u> #define MIN(a,b) (((a) < (b)) ? (a) : (b))
u> 
u> #include <strstream>
u> #include <vector>
u> #include "Response.h"
u> #include "Student.h"
u> #include "WeightInfo.h"
u> 
u> -------------------Student.h
u> 
u> 
u> #ifndef STUDENT_H
u> #define STUDENT_H
u> 
u> -------------------StringParser.h
u> 
u> //StringParser.h
u> //Defines helpful functions for parsing a string
u> 
u> #ifndef STRINGPARSER_H
u> #define STRINGPARSER_H
u> 
u> #include <string>
u> 
u> --------------------Reponse.h
u> 
u> #ifndef RESPONSE_H
u> #define RESPONSE_H
u> 
u> // dynamic_cast
u> #pragma warning(disable : 4541)
u> 
u> #include "XMLFile.h"
u> #include <map>
u> 
u> ------------------Globals.h
u> 
u> //Globals.h
u> //Defines handy helper functions
u> 
u> #pragma warning(disable : 4786)
u> 
u> #ifndef GLOBALS_H
u> #define GLOBALS_H
u> 
u> #include <iostream>
u> #include <fstream>
u> #include <string>
u> #include <cstring>
u> #include <cmath>
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> 
u> Matthew Leung wrote:
u> > Hi.  I keep getting this error in the ld phase of compilation.  What
u> > does undefined reference mean?
u> >
u> >
u> > make
u> > gcc -g -c Globals.cpp
u> > Globals.cpp:34:2: warning: no newline at end of file
u> > gcc -g -c TeamMaker.cpp
u> > In file included from
u> >
u> 
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/backward/strstream:51,
u> >                  from Team.h:6,
u> >                  from TeamMaker.h:7,
u> >                  from TeamMaker.cpp:1:
u> >
u> 
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/backward/backward_warning.h:32:2:
u> > warning: #warning This file includes at least one deprecated or
u> > antiquated header. Please consider using one of the 32 headers found
u> > in section 17.4.1.2 of the C++ standard. Examples include
u> substituting
u> > the <X> header for the <X.h> header for C++ includes, or <sstream>
u> > instead of the deprecated header <strstream.h>. To disable this
u> > warning use -Wno-deprecated.
u> > In file included from TeamMaker.h:7,
u> >                  from TeamMaker.cpp:1:
u> > Team.h: In member function `double Team::MinorityScore(const
u> WeightInfo&) const
u> >    ':
u> > Team.h:137: warning: converting to `int' from `const double'
u> > TeamMaker.cpp:19:2: warning: no newline at end of file
u> > gcc -o TeamMaker Globals.o TeamMaker.o
u> > Globals.o(.text+0x34): In function `LoadFile(std::basic_string<char,
u> > std::char_traits<char>, std::allocator<char> >)':
u> > /root/Desktop/TeamMaker/Globals.cpp:5: undefined reference to
u> > `std::basic_string<char, std::char_traits<char>, std::allocator<char>
u> > >::c_str() const'
u> > Globals.o(.text+0x4e): In function `LoadFile(std::basic_string<char,
u> > std::char_traits<char>, std::allocator<char> >)':
u> >
u> 
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/basic_string.h:872:
u> > undefined reference to `std::basic_ifstream<char,
u> > std::char_traits<char> >::basic_ifstream(char const*,
u> > std::_Ios_Openmode)'
u> > Globals.o(.text+0x5c): In function `LoadFile(std::basic_string<char,
u> > std::char_traits<char>, std::allocator<char> >)':
u> > /root/Desktop/TeamMaker/Globals.cpp:8: undefined reference to
u> > `std::allocator<char>::allocator()'
u> > Globals.o(.text+0x7b):/root/Desktop/TeamMaker/Globals.cpp:8:
u> undefined
u> > reference to `std::basic_string<char, std::char_traits<char>,
u> > std::allocator<char> >::basic_string(char const*,
u> std::allocator<char>
u> > const&)'
u> > Globals.o(.text+0x97): In function `LoadFile(std::basic_string<char,
u> > std::char_traits<char>, std::allocator<char> >)':
u> >
u> 
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/basic_string.h:872:
u> > undefined reference to `std::allocator<char>::~allocator()'
u> 
u>                                            

                                     \/
Robert Heller                        ||InterNet:   heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller  ||            heller@deepsoft.com
http://www.deepsoft.com              /\FidoNet:    1:321/153






                                             

reply via email to

[Prev in Thread] Current Thread [Next in Thread]