Mavlink control and Ardupilot linking

Good morning.

I’m stuck with my project with Pixhawk and Raspberry Pi. Currently I’m using mavlink_control.cpp to get Position, Velocity and High resolution IMU readings. I can set desired positions also. But i want to get Flight modes and states into that program, which is already there in the Ardupilot code and defined in defines.h program. I was not able to link these programs. So many undefined classes and parameter errors are coming. How can I get flightmode in mavlink_control.cpp??
Can someone help me??