0

I am learning my first language C++ and doing so by using a guidebook. Recently i got stuck with a problem an error called "undefined reference to BigDog(int)". For information all code written here is copied examples taken from the book.

I am using Code::blocks on ubuntu 14.04

The code is in two files:

main.cpp

#include<iostream>


using namespace std;

void BigDog(int KibblesCount);

int main()
{
BigDog(3);
return 0;
}

mystuff.cpp

#include<iostream>

using namespace std;

void BigDog(int KibblesCount)
{
    cout << "I'm a lucky dog" << endl;
    cout << "I have" << KibblesCount << " pieces of food" << endl;

}

When i compile this in code::block i get the following error "undefined reference to 'BigDog(int)'"

Any help is appreciated.

Jonas
  • 1
  • 1
  • Looks like you might be missing an include... – scohe001 Jul 01 '15 at 19:01
  • @scohe001, An include shouldn't fix a linker error. – chris Jul 01 '15 at 19:03
  • [See this question.](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) You likely want these two files to be in the same project. – chris Jul 01 '15 at 19:04
  • I added the proper include and now it works. Thank you very much for the help. – Jonas Jul 01 '15 at 19:36

0 Answers0