Installation
EasyMenu is a header-only library, which means you don't need to compile or link against any separate library files. Simply include the headers in your project and start using the library immediately.
Requirements
- C++11 or later compiler
- Standard C++ library
- Supported platforms: Windows, Linux, macOS
Getting the Library
Download or clone the EasyMenu library from the repository. The public API is located in the Include/ folder, which contains all the headers you need to use the library.
Using EasyMenu with g++ (GCC)
To use EasyMenu with g++ or other command-line compilers, you need to tell the compiler where to find the library headers using the -I (include path) flag.
Basic Compilation
If you have a source file main.cpp that uses EasyMenu, compile it like this:
g++ main.cpp -o myprogram -I path/to/EasyMenu/Include
Understanding the -I Flag
The -I flag tells the compiler to add the specified directory to the list of paths it searches when looking for header files. This allows you to use:
#include <EasyMenu.h>
in your code, and the compiler will find it in the path you specified.
Example Project Structure
MyProject/
├── src/
│ └── main.cpp
├── lib/
│ └── EasyMenu/
│ └── Include/
│ ├── EasyMenu.h
│ └── EasyMenuComponents.h
└── build/
Compilation Command for Above Structure
g++ src/main.cpp -o build/myprogram -I lib/EasyMenu/Include
Minimal Working Example
Create a file called main.cpp:
#include <iostream>
#include <EasyMenu.h>
int main() {
EasyMenu menu("Test Menu");
menu.AddItem("Option 1");
menu.AddItem("Option 2");
menu.AddItem("Exit");
unsigned int choice = menu.RunMenu();
std::cout << "You selected: " << choice << std::endl;
return 0;
}
Compile and run:
g++ main.cpp -o test -I path/to/EasyMenu/Include
./test
Using EasyMenu with Visual Studio
Visual Studio users have two convenient methods for including EasyMenu in their projects. Choose the method that best fits your project structure.
Method 1: Copy the Include Folder Into Your Project
This method is straightforward and keeps the library self-contained within your project.
Steps
- Copy the
Include/folder from the EasyMenu library into your Visual Studio project directory. - Your project structure should look like this:
MyProject/
├── MyProject.vcxproj
├── main.cpp
└── Include/
├── EasyMenu.h
├── EasyMenuComponents.h
└── Core/
└── ...
Using the Headers
Visual Studio automatically searches the project directory for headers, so you can include the library using a relative path:
#include "Include/EasyMenu.h"
Or, if you prefer, you can use:
#include <EasyMenu.h>
Visual Studio will find the headers in the Include/ folder automatically.
When to Use This Method
- Simple, single-project solutions
- When you want the library to be self-contained within the project
- For quick prototyping and testing
Method 2: Add Include Path in Visual Studio Settings
This method is recommended when you store libraries in a central location outside your project directory, or when multiple projects share the same library installation.
Step-by-Step Instructions
- Open your project in Visual Studio.
- In the Solution Explorer, right-click on your project name and select Properties.
- In the Property Pages dialog, navigate to:
Configuration Properties → C/C++ → General → Additional Include Directories - Click on the dropdown next to Additional Include Directories and select <Edit...>.
- Click the New Line button (folder icon) and add the path to the EasyMenu
Includefolder.
Example Path
If you have EasyMenu stored in C:\Libraries\EasyMenu, add:
C:\Libraries\EasyMenu\Include
Using the Headers
After configuring the include path, you can include the library headers using standard angle brackets:
#include <EasyMenu.h>
#include <EasyMenuComponents.h>
When to Use This Method
- When the library is stored outside your project directory
- When multiple projects share the same library installation
- For professional development environments with centralized library management
Visual Studio Example Program
Create a new Console Application project and add this code to your main.cpp:
#include <iostream>
#include <EasyMenu.h>
int main() {
EasyMenu menu("Visual Studio Test");
menu.AddItem("Create new file");
menu.AddItem("Open existing file");
menu.AddItem("Save file");
menu.AddItem("Exit");
unsigned int selection = menu.RunMenu();
if (selection > 0) {
std::cout << "You selected option: " << selection << std::endl;
} else {
std::cout << "No selection made." << std::endl;
}
return 0;
}
Build and run the project (F5 or Ctrl+F5).
Verifying Installation
To verify that EasyMenu is correctly installed and configured:
- Create a simple test program that includes
EasyMenu.h - Compile the program using your chosen method
- If compilation succeeds without errors, the library is correctly installed
- Run the program to verify that the menu displays correctly
Next Steps
Now that you have EasyMenu installed, you can:
- Follow the Quick Start guide to create your first menu
- Explore the API documentation to learn about all available features
- View examples for common use cases