ArduCopter i can't compile UserCode.cpp

Hello guys. I’m doing this for my school work. And I need to write my own code for UserCode but I can’t compile it when i try to compile it gives me error of AP_HAL library how can i compile only UserCode I need it for my homework

Suggest you supply details of your environment and a log/screenshot.

pi@raspberrypi:~/ardupilot/ArduCopter $ g++ UserCode.cpp -o usercode
In file included from UserCode.cpp:1:
Copter.h:28:10: fatal error: AP_HAL/AP_HAL.h: No such file or directory
#include <AP_HAL/AP_HAL.h>
compilation terminated.

when I try to compile only usercode.cpp it gives me an error like this and i don’t know how can i use that UserCode other than this