This repository contains a simple Huffman compressor program.
The project is written in C++17. Example compile commands are shown below.
On Windows (MSYS2/MinGW or WSL) using g++:
g++ -std=c++17 -O2 -Icompressor -Ilib src/main.cpp compressor/huffman.cpp -o compressor.exeOn Unix-like systems (Linux, macOS):
g++ -std=c++17 -O2 -Icompressor -Ilib src/main.cpp compressor/huffman.cpp -o compressorNotes:
- Adjust include paths (-I...) if your directory layout differs.
- If you want to build with separate object files or a Makefile, create a simple Makefile that compiles src/main.cppandcompressor/huffman.cpp.
Usage (Windows):
./compressor.exe {input_path} {output_path} {operation}Usage (Unix):
./compressor {input_path} {output_path} {operation}Parameters:
- {input_path}: path to the input file to encode or decode.
- {output_path}: path where the output will be written.
- {operation}: one of the valid operations below.
Valid operations:
- -e: encode the input file to compressed format.
- -d: decode a compressed file back to original.
Examples:
Encode a file:
./compressor.exe test/test.txt test/test_compressed.huf -eDecode a file:
./compressor.exe test/test_compressed.huf test/test_decoded.txt -d- If you see missing header errors, make sure the -Icompressorand-Ilibinclude paths point to the directories that contain header files used by the sources (for examplecompressor/huffman.handlib/minHeap.h).
- If you want a silent build: add -sto strip symbols.
- For large files, ensure you have enough memory and disk space.