WeatherAppCPP is a C++ application that retrieves weather information using the OpenWeatherMap API.
Before building and running WeatherAppCPP, ensure that you have the following prerequisites installed:
- CMake (minimum version 3.12)
To build WeatherAppCPP, follow these steps:
- Clone the repository to your local machine.
- Navigate to the root directory of the project.
- Create a build directory:
mkdir build cd build
- Run CMake to generate build files:
cmake ..
- Build the project:
cmake --build .
Before running WeatherAppCPP, you need to sign up for an account on OpenWeatherMap to obtain an API key. It's completely free for the our case.
You will generate an API key in this link api keys.
After obtaining your API key, follow these steps to run WeatherAppCPP:
-
Navigate to the build/debug directory:
cd build/debug
-
Run the executable with the following arguments:
<api_key>
: Your OpenWeatherMap API key<city>
: The name of the city for which you want to retrieve weather information<units>
: Units for temperature (metric or imperial)
Example:
./WeatherAppCPP <api_key> <city> <units>
-
After running the executable, the output will display the temperature, humidity, and weather conditions for the specified city.
In this project, I used the cpprest library my Microsoft to send requests to the API. All the necessary files are put in the Dependecies folder. The linking is made via cmake.