How to convert Arduino example sketch to a complete c++ project?
Basically *.ino is *.cpp without headers. So you can 


rename it to *.cpp,
If you have any functions which are used before they have been defined, provide declarations for each function before its first use
#include &lt;Arduino.h&gt; on the top 
#include &lt;Wire.h&gt; if you are using Wire and so on


and you have "normal" CPP file.

If you are making library this way, than you create also *.h file, where you declare all exported functions and objects and #include that file in your *.cpp as first line (than you do not need/have to forward declare any of that exported functions)

You may like to take a look at https://github.com/arduino/Arduino.git https://github.com/sudar/Arduino-Makefile and https://github.com/ladislas/bare-arduino-project

the Bare Arduino have 2 projects each using 2 libraries, so you can get inspiration there