# Installation Guide

This document provides detailed installation instructions for the Network Chat Client project.

## Project Information

- **Author**: Molla Samser (Founder, RSK World)
- **Designer & Tester**: Rima Khatun
- **Website**: https://rskworld.in
- **Email**: info@rskworld.com, support@rskworld.com
- **Phone**: +91 93305 39277
- **Year**: 2026
- **License**: MIT

## Table of Contents

1. [System Requirements](#system-requirements)
2. [Prerequisites](#prerequisites)
3. [Installation Methods](#installation-methods)
4. [Windows Installation](#windows-installation)
5. [Linux Installation](#linux-installation)
6. [macOS Installation](#macos-installation)
7. [Configuration](#configuration)
8. [Verification](#verification)
9. [Troubleshooting](#troubleshooting)

## System Requirements

### Minimum Requirements
- **OS**: Windows 10+, Ubuntu 18.04+, CentOS 7+, macOS 10.14+
- **RAM**: 512MB minimum, 1GB recommended
- **Disk Space**: 100MB for installation, 50MB for runtime
- **Network**: TCP/IP support, port 54000 (default)

### Recommended Requirements
- **OS**: Windows 11, Ubuntu 20.04+, CentOS 8+, macOS 11+
- **RAM**: 2GB or more
- **Disk Space**: 500MB for full installation with examples
- **Network**: Stable internet connection for multi-client testing

## Prerequisites

### Required Software

#### Compilers
- **Windows**: Visual Studio 2019+ with C++ development tools
- **Linux**: GCC 7+ or Clang 7+
- **macOS**: Xcode 10+ or Clang 7+

#### Build Tools
- **CMake** 3.16 or higher
- **Make** (for Linux/macOS)
- **Git** (for cloning repository)

#### Optional Dependencies
- **OpenSSL** (for encryption features)
- **Git** (for version control)

### OpenSSL Installation

#### Windows
1. Download OpenSSL for Windows from: https://slproweb.com/products/Win32OpenSSL.html
2. Install to default location (e.g., `C:\OpenSSL-Win64`)
3. Add OpenSSL to system PATH
4. Restart command prompt

#### Ubuntu/Debian
```bash
sudo apt-get update
sudo apt-get install libssl-dev
```

#### CentOS/RHEL
```bash
sudo yum groupinstall "Development Tools"
sudo yum install openssl-devel
```

#### macOS
```bash
brew install openssl
```

## Installation Methods

### Method 1: Using Build Scripts (Recommended)

#### Windows
```cmd
# Clone repository
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client

# Run build script
scripts\build.bat
```

#### Linux/macOS
```bash
# Clone repository
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client

# Make build script executable
chmod +x scripts/build.sh

# Run build script
./scripts/build.sh
```

### Method 2: Using CMake

```bash
# Clone repository
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client

# Create build directory
mkdir build
cd build

# Configure project
cmake ..

# Build project
cmake --build .

# Install (optional)
cmake --install .
```

### Method 3: Using Make (Linux/macOS)

```bash
# Clone repository
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client

# Build project
make

# Install (optional)
sudo make install
```

### Method 4: Manual Compilation

#### Windows (Visual Studio)
```cmd
# Set environment variables
set INCLUDE=%INCLUDE%;C:\OpenSSL-Win64\include
set LIB=%LIB%;C:\OpenSSL-Win64\lib

# Compile client
cl /std:c++17 /I.\include /Fe:bin\chat_client.exe src\chat_client.cpp src\utils.cpp src\message_queue.cpp ws2_32.lib libcrypto.lib libssl.lib

# Compile server
cl /std:c++17 /I.\include /Fe:bin\chat_server.exe src\chat_server.cpp src\utils.cpp src\message_queue.cpp ws2_32.lib libcrypto.lib libssl.lib
```

#### Linux/macOS
```bash
# Compile client
g++ -std=c++17 -I./include -o bin/chat_client src/chat_client.cpp src/utils.cpp src/message_queue.cpp -lpthread -lssl -lcrypto

# Compile server
g++ -std=c++17 -I./include -o bin/chat_server src/chat_server.cpp src/utils.cpp src/message_queue.cpp -lpthread -lssl -lcrypto
```

## Windows Installation

### Step 1: Install Visual Studio
1. Download Visual Studio 2019 or later from: https://visualstudio.microsoft.com/
2. Select "Desktop development with C++" workload
3. Complete installation

### Step 2: Install OpenSSL (Optional)
1. Download OpenSSL for Windows
2. Install to default location
3. Add to system PATH

### Step 3: Clone Repository
```cmd
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client
```

### Step 4: Build Project
```cmd
# Using build script (recommended)
scripts\build.bat

# Or using CMake
mkdir build
cd build
cmake ..
cmake --build .
```

### Step 5: Verify Installation
```cmd
# Navigate to build directory
cd build\bin\Release

# Test executables
chat_client.exe --version
chat_server.exe --version
```

## Linux Installation

### Step 1: Install Development Tools
```bash
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install build-essential cmake git

# CentOS/RHEL
sudo yum groupinstall "Development Tools"
sudo yum install cmake git
```

### Step 2: Install OpenSSL (Optional)
```bash
# Ubuntu/Debian
sudo apt-get install libssl-dev

# CentOS/RHEL
sudo yum install openssl-devel
```

### Step 3: Clone Repository
```bash
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client
```

### Step 4: Build Project
```bash
# Using build script (recommended)
chmod +x scripts/build.sh
./scripts/build.sh

# Or using CMake
mkdir build
cd build
cmake ..
make

# Or using Make
make
```

### Step 5: Verify Installation
```bash
# Test executables
./build/bin/chat_client --version
./build/bin/chat_server --version
```

## macOS Installation

### Step 1: Install Xcode Command Line Tools
```bash
xcode-select --install
```

### Step 2: Install Homebrew (Optional)
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

### Step 3: Install Dependencies
```bash
# Install OpenSSL via Homebrew
brew install openssl

# Install CMake
brew install cmake
```

### Step 4: Clone Repository
```bash
git clone https://github.com/rskworld/network-chat-client.git
cd network-chat-client
```

### Step 5: Build Project
```bash
# Using build script (recommended)
chmod +x scripts/build.sh
./scripts/build.sh

# Or using CMake
mkdir build
cd build
cmake ..
make
```

### Step 6: Verify Installation
```bash
# Test executables
./build/bin/chat_client --version
./build/bin/chat_server --version
```

## Configuration

### Default Configuration
The project includes a default configuration file at `config/default.conf`.

### Custom Configuration
1. Copy default configuration:
```bash
cp config/default.conf config/user.conf
```

2. Edit configuration file:
```bash
nano config/user.conf
```

3. Key configuration options:
```ini
# Server settings
server.port=54000
server.max_clients=100

# Client settings
client.server_ip=127.0.0.1
client.server_port=54000

# Security settings
security.enable_encryption=true
security.encryption_algorithm=XOR

# Logging settings
server.enable_logging=true
client.enable_logging=true
```

### Environment Variables
You can override configuration using environment variables:
```bash
export CHAT_SERVER_PORT=54001
export CHAT_CLIENT_IP=192.168.1.100
export CHAT_LOG_LEVEL=DEBUG
```

## Verification

### Basic Test
1. Start server:
```bash
./bin/chat_server
```

2. In another terminal, start client:
```bash
./bin/chat_client
```

3. Test communication between multiple clients.

### Example Programs
Run example programs to verify functionality:
```bash
# Client examples
./bin/client_example

# Server examples
./bin/server_example
```

### Automated Tests
```bash
# Run test suite
make test

# Or with CMake
ctest
```

## Troubleshooting

### Common Issues

#### 1. Compiler Not Found
**Error**: `g++: command not found` or `cl: command not found`

**Solution**:
- **Windows**: Install Visual Studio with C++ development tools
- **Linux**: `sudo apt-get install build-essential`
- **macOS**: `xcode-select --install`

#### 2. OpenSSL Not Found
**Error**: `OpenSSL not found` or linking errors

**Solution**:
```bash
# Ubuntu/Debian
sudo apt-get install libssl-dev

# CentOS/RHEL
sudo yum install openssl-devel

# macOS
brew install openssl
```

#### 3. Permission Denied
**Error**: `Permission denied` when executing scripts

**Solution**:
```bash
chmod +x scripts/build.sh
chmod +x scripts/*.sh
```

#### 4. Port Already in Use
**Error**: `Address already in use` or `Port 54000 is busy`

**Solution**:
```bash
# Find process using port
netstat -tulpn | grep 54000
# or
lsof -i :54000

# Kill process
kill -9 <PID>

# Or use different port
./chat_server --port 54001
```

#### 5. Connection Refused
**Error**: `Connection refused` when client tries to connect

**Solution**:
- Ensure server is running
- Check firewall settings
- Verify IP address and port
- Try connecting to localhost (127.0.0.1)

#### 6. Build Failures on Windows
**Error**: Various compilation errors on Windows

**Solution**:
1. Use Visual Studio Developer Command Prompt
2. Ensure OpenSSL is properly installed
3. Check include and library paths
4. Use provided build script

### Debug Mode

Enable debug mode for troubleshooting:
```bash
# Build with debug symbols
make debug

# Or with CMake
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
```

### Log Files

Check log files for detailed error information:
```bash
# Server logs
tail -f logs/server.log

# Client logs
tail -f logs/client.log
```

### Performance Issues

For performance problems:
1. Check system resources
2. Monitor network activity
3. Review configuration settings
4. Enable performance logging

### Getting Help

If you encounter issues:

1. **Check Documentation**: Read this guide and API documentation
2. **Search Issues**: Check GitHub issues for similar problems
3. **Create Issue**: Report new issues with detailed information
4. **Contact Support**: Email info@rskworld.com

### System Information for Bug Reports

When reporting issues, include:
- Operating system and version
- Compiler version
- Build method (script, CMake, Make)
- Error messages
- Configuration used
- Steps to reproduce

## Advanced Installation

### Cross-Compilation

#### Cross-compile for Windows from Linux
```bash
# Install MinGW
sudo apt-get install mingw-w64

# Configure for cross-compilation
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw.cmake ..

# Build
make
```

### Docker Installation

Create Dockerfile:
```dockerfile
FROM ubuntu:20.04

RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    libssl-dev \
    git

WORKDIR /app
COPY . .

RUN mkdir build && cd build && \
    cmake .. && \
    make

CMD ["./build/bin/chat_server"]
```

Build and run:
```bash
docker build -t network-chat-client .
docker run -p 54000:54000 network-chat-client
```

### Package Installation

#### Debian Package
```bash
# Create package
dpkg-deb --build network-chat-client

# Install package
sudo dpkg -i network-chat-client.deb
```

#### RPM Package
```bash
# Create package
rpmbuild -bb network-chat-client.spec

# Install package
sudo rpm -i network-chat-client.rpm
```

## Uninstallation

### Remove Build Files
```bash
# Clean build directory
make clean

# Or remove entire build directory
rm -rf build/
```

### Remove Installation (if installed system-wide)
```bash
# Using Make
sudo make uninstall

# Manual removal
sudo rm -f /usr/local/bin/chat_client
sudo rm -f /usr/local/bin/chat_server
sudo rm -rf /etc/network-chat-client
```

### Remove Configuration
```bash
# Remove user configuration
rm -f config/user.conf

# Remove logs
rm -rf logs/

# Remove temporary files
rm -rf temp/
```

---

## Contact Information

**Installation Support:**
- **Email**: info@rskworld.com, support@rskworld.com
- **Phone**: +91 93305 39277
- **Website**: https://rskworld.in
- **Address**: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

---

© 2026 RSK World. All rights reserved.

*Content used for educational purposes only. View Disclaimer: https://rskworld.in/disclaimer.php*
