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

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

  1. Copy the Include/ folder from the EasyMenu library into your Visual Studio project directory.
  2. 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

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

  1. Open your project in Visual Studio.
  2. In the Solution Explorer, right-click on your project name and select Properties.
  3. In the Property Pages dialog, navigate to:
    Configuration Properties
    → C/C++
    → General
    → Additional Include Directories
  4. Click on the dropdown next to Additional Include Directories and select <Edit...>.
  5. Click the New Line button (folder icon) and add the path to the EasyMenu Include folder.

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

Note: Make sure to set the include path for all configurations you plan to use (Debug, Release, etc.). You can select "All Configurations" from the Configuration dropdown at the top of the Property Pages dialog.

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:

  1. Create a simple test program that includes EasyMenu.h
  2. Compile the program using your chosen method
  3. If compilation succeeds without errors, the library is correctly installed
  4. Run the program to verify that the menu displays correctly
Success! If your program compiles and runs without errors, EasyMenu is ready to use in your project.

Next Steps

Now that you have EasyMenu installed, you can: