-1

I've browsed a lot of questions about this, but none seem to be experiencing the exact same problem as I am. The exact error message is:

g++ -Wall -o Main Main.cpp 
Undefined symbols for architecture x86_64:
  "World::World(int)", referenced from:
      _main in Main-vskeMa.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Could it be a namespacing issue? As you can see above, I'm compiling on the command line using g++. Here are the relevant files:

main.cpp

#include <iostream>
#include <cstdlib>
#include "World.h"

using namespace std;

int main()
{
    cout << "-- Program Started --" << endl;

    World theWorld (4);

    return 0;
}

World.h

#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <time.h>
#include <stdlib.h>
#include "Biome.h"

#define TILE_SIZE 10
#define WORLD_DIM 10
#define NUM_BIOMES 5

using namespace std;

class World{
 public:
  World(int);
 protected:
    Biome* biomeArray[WORLD_DIM][WORLD_DIM];
};

World.cpp

#include "World.h"

using namespace std;


/* functions */

/* constructor */
World::World(int numCities){
  cout << "creating the world with " << numCities << " cities...";
  for (int i=0; i<WORLD_DIM; i++){
    for (int j=0; j<WORLD_DIM; j++){
      int random =  rand() % NUM_BIOMES;
        Biome* aBiome = createBiome(random);
      cout << aBiome->name << endl;

    }
  }

  cout << "done!" << endl;
}

Any help would be greatly appreciated, thanks!

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
jtruskow
  • 29
  • 5

1 Answers1

0

Could it be a namespacing issue?

No. You are not even using namespaces.

As you can see above, I'm compiling on the command line using g++.

No, you're not. You did not compile or link World.cpp.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055