1

I seem to be getting the rookie error where it says, undefined reference to 'check', as shown below:

enter image description here

This should not be a problem, as I have in fact made a check.h and included in hiker.c, as shown below:

enter image description here

Does anybody know the source of this problem? I have just started using MinGW(as I wanted to learn programming C on Windows).

Here is a picture of the main function. I can add the code too if necessary:

enter image description here

SDG
  • 2,260
  • 8
  • 35
  • 77
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – vsoftco Oct 12 '15 at 03:40
  • 1
    Make sure you add `hiker.c` in your Makefile/compilation command. Read the linked duplicate (C++, but C-related issues are also mentioned). – vsoftco Oct 12 '15 at 03:40

1 Answers1

2

I guess that check function is implemented in a file check.c

You must link that file also, because of your check.h export the prototype to let the compiler know how the check function is structured, but the linker needs the check function code compiled and reachable.

What you need is to compile using a command like this:

gcc -Wall hiker.c check.c -o hiker.exe

Take also note that linker is giving you another error about WinMain@16 This means that you started a windows application project, I guess you must change your project to console project type.

LPs
  • 16,045
  • 8
  • 30
  • 61
  • I can't seem to find any resources on how to change from a WinMain@16 to a console project. Could you point me in the right direction? – SDG Oct 13 '15 at 00:58
  • @SharanDuggirala In Code::Blocks the option to change this is under: Project -> Properties then select the 'Build Type' tab and look for the 'Type' drop-down box. Make sure to do this with both your Debug and Release versions. BTW I think the best way is to restart creating a new project. – LPs Oct 13 '15 at 08:36
  • But I written this project using notepad in a folder. I am not sure why that option came up at all. Why would it be better for me to start a new project? – SDG Oct 13 '15 at 14:06
  • @SharanDuggirala ok. In this case I have a new question: is there a main function in your code? – LPs Oct 13 '15 at 17:58
  • @SharanDuggirala try renaming it to int WinMain (int, char**) – LPs Oct 13 '15 at 20:41