Author Topic: Undefined reference to play(SDL_Surface*)  (Read 4945 times)

Offline wilbefast

  • Multiple posting newcomer
  • *
  • Posts: 16
Undefined reference to play(SDL_Surface*)
« on: September 26, 2009, 06:08:35 pm »
Hi everyone  :?

I know this is borderline "programming" stuff but since Codeblock has special ways it likes you to link and include I thought I'd post it here - after all, I'm following a tutorial more or less word for word so in theory it should compile just fine ("should" ha ha ha). So, yeah, I keep getting this error in the main:

Code
Undefined reference to play(SDL_Surface*)

screenshot

"Play" is a function that takes an SDL_Surface and draws stuff on it, in this case the default screen, but that's not important. Before anyone starts, I have indeed included "play.h" where the function is defined as:

Code
#ifndef PLAY_H_INCLUDED
#define PLAY_H_INCLUDED

void play(SDL_Surface* screen);
// (...)

#endif

"play.c" is some 300 lines of code so I won't paste it in here. I made sure the files were indeed well included, as if I don't include "play.h" I get a different and altogether more familiar error:

Code
'play' not defined in this scope


I'm pretty sure there's some option I haven't checked somewhere, but generally functions work fine without encouragement. What am I doing wrong?


William

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Undefined reference to play(SDL_Surface*)
« Reply #1 on: September 26, 2009, 06:25:33 pm »
Hi everyone  :?

I know this is borderline "programming" stuff but since Codeblock has special ways it likes you to link and include I thought I'd post it here - after all, I'm following a tutorial more or less word for word so in theory it should compile just fine ("should" ha ha ha). So, yeah, I keep getting this error in the main:

The question is no borderline "programming" at all, it IS a programming question. Code::Blocks has NO special ways to link and include since it is not a compiler neither a linker. All Code::Blocks does is send what you instructed to the toolchain that you selected (GCC, MSVC, Digital Mars, Intel, ...), and that's it. In other words, you are asking in the wrong place.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Undefined reference to play(SDL_Surface*)
« Reply #2 on: September 26, 2009, 06:47:57 pm »
You should probably read something about how a build-process works.

If you do not know the difference between including header-files and linking libraries, you are missing some absolutely basic knwowledge and are definitely in the wrong forum.



That's what I answered in another thread with nearly the same question.
Learn the (programming) basics, read the (C::B) manual and you will find the answer.

And if not ... either stop programming or ask in the correct forum.


Topic locked !!