0

Everything was compiling fine, and I've looked through about 10 different questions on here trying to solve it including this, this, and this. Please don't kill me, I've been beating my head against the wall for about 3 hours now. I've also tried building the offending file by itself and it seems to build fine, but when I build the project it still throws the same errors.

I've tried moving the include ".h's" into only the cpp files when possible which was most of the time but that still didn't help. When I change

BitBoards *newBoard = new BitBoards;

to

BitBoards *newBoard;

the error on that line goes away, but it still gives me the "undefined refrence to" the newBoard-> functions.

Is there anything else glaringly obvious, or not, that I should try?

The errors pop up in my logic file here: Ai_Logic.cpp

 //master bitboard for turn
BitBoards *newBoard = new BitBoards;
^^here
//master zobrist object for ai turn
ZobristH *mZobrist = new ZobristH;

//master evaluation object - evaluates board position and gives an int value (- for black)
evaluateBB *mEval = new evaluateBB;

newBoard->constructBoards();
^^and here as well as every instance of newBoard-> below

Ai_Logic.h:

#include <string>
#include <stack>
#include <thread>
class Pieces;
class ZobristH;
class BitBoards;
class MoveGen;
class evaluateBB;
class HashEntry;

class Ai_Logic
{
//stuff
};

Ai_Logic.cpp

#include "ai_logic.h"

#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <iostream>

#include "externs.h"
#include "move.h"
#include "evaluatebb.h"
#include "bitboards.h"
#include "movegen.h"
#include "zobristh.h"

BitBoards.h

class MoveGen;
class ZobristH;
class Move;

class BitBoards
{
//stuff
};

BitBoards.cpp

#include "bitboards.h"
#include <cmath>
#include <random>
#include <iostream>
#include <string>
#include <cstdio>

#include "externs.h"
#include "movegen.h"    

I think the problem might come from my MoveGen.h/cpp but i'm not entirely sure

MoveGen.h

#include <iostream>
#include <string>
#include "move.h"

class Pieces;
class BitBoards;
class ZobristH;


class MoveGen
{
//stuff
};

MoveGen.cpp

#include "movegen.h"
#include "bitboards.h"
#include "Pieces.h"   
Max C
  • 369
  • 5
  • 16
  • 1
    Your class declarations in header files don't appear to have closing braces or any real declarations. Is that a formatting issue or do your .h files really look like that? – vincent Jul 28 '17 at 02:35
  • No, sorry I suppose that was super unclear. They have tons of variables and functions I didn't include. They have closing braces. – Max C Jul 28 '17 at 02:37
  • This behavior also depends on whether `BitBoards` is a POD or not and has a default constructor. – miradulo Jul 28 '17 at 02:37
  • They all have the default class:class { }; constructors. What's POD? – Max C Jul 28 '17 at 02:39
  • There is not enough information here. Please provide a minimal example: https://stackoverflow.com/help/mcve. Are you declaring any virtual functions and not implementing them? – vincent Jul 28 '17 at 02:39
  • No virtual functions. I thought I did include a minimal example, I'm almost positive it's a linking issue since the only thing I've changed is a few functions taking different objects. If there's something specific I should include I can definitely do that. – Max C Jul 28 '17 at 02:41
  • Its not minimal if we can't run your code. – vincent Jul 28 '17 at 02:41
  • There is a difference between BitBoards and BitBoards* . One is a pointer (integer address) and doesn't instantiate the object. The other instantiates an object. – vincent Jul 28 '17 at 02:43
  • I'll try and add a stripped down version of the offending files right now. – Max C Jul 28 '17 at 02:45
  • How would I instantiate it without a pointer? Without it it says conversion from BitBoards* to non-scalar type BitBoards requested. – Max C Jul 28 '17 at 02:48
  • I think that might have actually fixed my issue. What I don't understand is that the previous mentioned declaration has been fine for weeks. Why did it decide it was no longer fine all of a sudden? – Max C Jul 28 '17 at 02:52

1 Answers1

1
#include bitboards.cpp 

In the Ai_Logic file seemed to do the trick. Absolutely no idea why.

Max C
  • 369
  • 5
  • 16
  • 1
    It seems that you don't understand 'declarations' or 'forward declarations'. This are terms you should look up. – vincent Jul 28 '17 at 03:42