help-gplusplus
[Top][All Lists]
Advanced

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

Re: Loading & Linking Error


From: ubccis
Subject: Re: Loading & Linking Error
Date: 17 Jan 2005 13:54:01 -0800
User-agent: G2/0.2

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

-------------------------------------makefile


TeamMaker : TeamMaker.o Globals.o

cc = g++
CFLAGS = -g


default : TeamMaker

TeamMaker.o : TeamMaker.cpp Team.h Response.h Response.h Student.h
WeightInfo.h XMLFile.h
$(CC) $(CFLAGS) -c TeamMaker.cpp

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

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

clean :
rm -f *.o *.pdf TeamMaker core

#end
--------------------------------globals.cpp

#include "Globals.h"

-------------------------------TeamMaker.cpp

#include <ctime>

------------------------------XMLFile.h

//XMLFile.h
//Defines code for reading a basic XML file

#ifndef XMLFILE_H
#define XMLFILE_H

// signed/unsigned mismatch
#pragma warning(disable : 4018)
// double -> float conversion
#pragma warning(disable : 4244)

#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include "StringParser.h"
#include "Globals.h"

--------------------------------WeightInfo.h

#ifndef WEIGHTINFO_H
#define WEIGHTINFO_H

#include <map>
#include <vector>
#include "XMLFile.h"

--------------------------------TeamMaker.h

#ifndef TEAMMAKER_H
#define TEAMMAKER_H

#include <algorithm>
#include <iostream>
#include <fstream>
#include "Team.h"

--------------------Team.h

#ifndef TEAM_H
#define TEAM_H

#define MIN(a,b) (((a) < (b)) ? (a) : (b))

#include <strstream>
#include <vector>
#include "Response.h"
#include "Student.h"
#include "WeightInfo.h"

-------------------Student.h


#ifndef STUDENT_H
#define STUDENT_H

-------------------StringParser.h

//StringParser.h
//Defines helpful functions for parsing a string

#ifndef STRINGPARSER_H
#define STRINGPARSER_H

#include <string>

--------------------Reponse.h

#ifndef RESPONSE_H
#define RESPONSE_H

// dynamic_cast
#pragma warning(disable : 4541)

#include "XMLFile.h"
#include <map>

------------------Globals.h

//Globals.h
//Defines handy helper functions

#pragma warning(disable : 4786)

#ifndef GLOBALS_H
#define GLOBALS_H

#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>

























Matthew Leung wrote:
> Hi.  I keep getting this error in the ld phase of compilation.  What
> does undefined reference mean?
>
>
> make
> gcc -g -c Globals.cpp
> Globals.cpp:34:2: warning: no newline at end of file
> gcc -g -c TeamMaker.cpp
> In file included from
>
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/backward/strstream:51,
>                  from Team.h:6,
>                  from TeamMaker.h:7,
>                  from TeamMaker.cpp:1:
>
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/backward/backward_warning.h:32:2:
> warning: #warning This file includes at least one deprecated or
> antiquated header. Please consider using one of the 32 headers found
> in section 17.4.1.2 of the C++ standard. Examples include
substituting
> the <X> header for the <X.h> header for C++ includes, or <sstream>
> instead of the deprecated header <strstream.h>. To disable this
> warning use -Wno-deprecated.
> In file included from TeamMaker.h:7,
>                  from TeamMaker.cpp:1:
> Team.h: In member function `double Team::MinorityScore(const
WeightInfo&) const
>    ':
> Team.h:137: warning: converting to `int' from `const double'
> TeamMaker.cpp:19:2: warning: no newline at end of file
> gcc -o TeamMaker Globals.o TeamMaker.o
> Globals.o(.text+0x34): In function `LoadFile(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >)':
> /root/Desktop/TeamMaker/Globals.cpp:5: undefined reference to
> `std::basic_string<char, std::char_traits<char>, std::allocator<char>
> >::c_str() const'
> Globals.o(.text+0x4e): In function `LoadFile(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >)':
>
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/basic_string.h:872:
> undefined reference to `std::basic_ifstream<char,
> std::char_traits<char> >::basic_ifstream(char const*,
> std::_Ios_Openmode)'
> Globals.o(.text+0x5c): In function `LoadFile(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >)':
> /root/Desktop/TeamMaker/Globals.cpp:8: undefined reference to
> `std::allocator<char>::allocator()'
> Globals.o(.text+0x7b):/root/Desktop/TeamMaker/Globals.cpp:8:
undefined
> reference to `std::basic_string<char, std::char_traits<char>,
> std::allocator<char> >::basic_string(char const*,
std::allocator<char>
> const&)'
> Globals.o(.text+0x97): In function `LoadFile(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >)':
>
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/basic_string.h:872:
> undefined reference to `std::allocator<char>::~allocator()'


reply via email to

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