Ошибка следующая
Код: Выделить всё
g++ -g -Wall -o citysim citysim.o utils.o
utils.o: In function `map_of_cities::read(std::basic_string)':
/home/rryder1/cs302/labs/lab4/utils.cpp:95: multiple definition of `map_of_cities::read(std::basic_string)'
citysim.o:/home/rryder1/cs302/labs/lab4/utils.h:61: first defined here
citysim.o: In function `map_of_cities::read(std::basic_string)':
citysim.cpp:(.text+0xcb): undefined reference to `city::city()'
citysim.cpp:(.text+0x244): undefined reference to `city::~city()'
citysim.cpp:(.text+0x2a3): undefined reference to `city::~city()'
citysim.o: In function `std::vector::_M_insert_aux(__gnu_cxx::__normal_iterator, city const&)':
citysim.cpp:(.text._ZNSt6vectorI4citySaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector::_M_insert_aux(__gnu_cxx::__normal_iterator, city const&)]+0xd2): undefined reference to `city::~city()'
citysim.cpp:(.text._ZNSt6vectorI4citySaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector::_M_insert_aux(__gnu_cxx::__normal_iterator, city const&)]+0x27d): undefined reference to `city::~city()'
citysim.o: In function `__gnu_cxx::new_allocator::destroy(city*)':
citysim.cpp:(.text._ZN9__gnu_cxx13new_allocatorI4cityE7destroyEPS1_[__gnu_cxx::new_allocator::destroy(city*)]+0x18): undefined reference to `city::~city()'
citysim.o:citysim.cpp:(.text._ZSt8_DestroyI4cityEvPT_[void std::_Destroy(city*)]+0x14): more undefined references to `city::~city()' follow
utils.o: In function `map_of_cities::read(std::basic_string)':
utils.cpp:(.text+0xacd): undefined reference to `city::city()'
utils.cpp:(.text+0xc68): undefined reference to `city::~city()'
utils.cpp:(.text+0xcc7): undefined reference to `city::~city()'
collect2: ld returned 1 exit status
Вот мой файл utils.h
Код: Выделить всё
#ifndef __CITY_DEFS_H__
#define __CITY_DEFS_H__
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
//#include ALL HEADER FILES NEEDED FOR THIS HEADER FILE
class city {
friend ostream &operator
Подробнее здесь: [url]https://stackoverflow.com/questions/22240639/confusing-compiler-error[/url]
Мобильная версия