-2

When attempting to compile, I'm getting the following error:

1>main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall Area::createArea(void)" (?createArea@Area@@QAEXXZ)" in Funktion "_main". 1>D:\C++ Projekte\EREBOS_2\Debug\EREBOS_2.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.

English translation:

1> main.obj: error LNK2019: unresolved external reference to Symbol "" public: void __thiscall Area :: create area (void) " (? create area Area @@@QAEXXZ) "function in" _main "1> D:. \ C ++ Projects \ EREBOS_2 \ Debug \ EREBOS_2.exe: fatal error LNK1120: 1 unresolved externals.

What does this mean? How can I fix it?

The code:

#include <iostream>
#include "windows.h"
#include "MainMenu.h"
#include "MainPlayer.h"
#include <ctime>
#include <string>

int y;
int x;

using namespace std;

void createArea()
{
    int area[15][15];

    for(int y = 0; y < 15; y++)
    {
        for (int x = 0; x < 15; y++)
        {
            area[x][y] = 0;
        }
    }
    //---------------------------------
    for(int counter = 0; counter < 15; counter++)
    {
        area[1][y] = 1;
        area[15][y] = 1;
    }
    //--------------------------------------
    for (int y = 0; y <15; y++)
    {
        for (int x = 0; x < 15; x++)
        {
            cout << area[x][y];
        }
    }
}

#include <iostream>
#include "windows.h"
#include "MainMenu.h"
#include <ctime>
#include <string>
using namespace std;

void MainMenu:: createMenu()
{
    int typed;
    system("cls");
    cout << endl;
    cout << endl;
    cout << "   --------------" << endl;
    cout << "   | 1) Start   |" << endl;
    cout << "   | 2) Hilfe   |" << endl;
    cout << "   | 3) Credits |" << endl;
    cout << "   | 4) Beenden |" << endl;
    cout << "   --------------" << endl;
    cin >> typed;
    if(typed == 1)
    {
        cout << "...still a whole lot of work to do..." << endl;
    }
}

#include <string>
class MainMenu
{
public:
    void createMenu();
};

#include <iostream>
#include "windows.h"
#include "MainMenu.h"
#include "MainPlayer.h"
#include <ctime>
#include <string>

using namespace std;

void Mainplayer:: showData()
{
    using namespace std;
    int health = 100;
    int xp = 0;
    int lvl = 1;
    int gold = 10;
    std:: string Name = "Namenloser";
    system("cls");
    cout << "-----------------------" << endl;
    cout << "Name: " << Name << endl;
    cout << "Leben: " << health << "/100" << endl;
    cout << "Erfahrung: " << xp << "/" << lvl*10 << endl;
    cout << "Level: " << lvl << "/50" << endl;
    cout << "Gold: " << gold << endl;
    cout << "------------------------" << endl;
}

#include <string>
class Mainplayer
{
    public:
        int health;
        int xp;
        int lvl;
        int gold;
        std:: string Name;
        void showData();
        int playercoordy;
        int playercoordx;
};

#include <iostream>
#include "windows.h"
#include "MainMenu.h"
#include "MainPlayer.h"
#include "Area.h"
#include <ctime>
#include <string>
using namespace std;

void maingame();

int main()
{
    system("title EREBOS 2");
    Mainplayer MainChar; 
    MainMenu menu;
    Area MainArea; 
    menu.createMenu();
    MainChar.showData();
    MainArea.createArea();
    getchar();
    getchar();
}
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
Jan1902
  • 193
  • 1
  • 16
  • Sorry about the {, } and };.....my foul.... – Jan1902 Mar 05 '15 at 18:23
  • Welcome to Stack Overflow! I've edited your code to space the different code files better; adding new lines can clear this up. Also, please try and have the important errors in English; I've gone and translated it using Google Translate; feel free to edit if it didn't translate properly. – Chris Forrence Mar 05 '15 at 18:56
  • Those are linker errors, not compiler errors. C++ is first compiled, then linked. Resolving linker errors is generally a different process than resolving compiler errors. – crashmstr Mar 05 '15 at 19:02
  • Do you also have an answer or just this comment ? :D – Jan1902 Mar 05 '15 at 19:07
  • And thanks for the english translation :) – Jan1902 Mar 05 '15 at 19:07

1 Answers1

2

The message means you try to call "public: void __thiscall Area::createArea(void)" but then the linker doesn't find that function.

The closest thing I see is MainArea.createArea(); - I'm guessing that either you haven't implemented the function (in Area.cpp, which you didn't show us), or you simply aren't linking Area.o, or not in the needed sequence.

See What is an undefined reference/unresolved external symbol error and how do I fix it?

Community
  • 1
  • 1
Dronz
  • 1,970
  • 4
  • 27
  • 50