简体   繁体   中英

Undefined reference to the function 'check' (GCC compilation in MinGW)

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

在此处输入图片说明

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

在此处输入图片说明

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:

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM