# Installation Guide for Linux (WSL)

Since you're running on Linux/WSL, follow these steps to compile and run the library:

## Step 1: Install Build Dependencies

Run these commands in your terminal:

```bash
# Update package list
sudo apt-get update

# Install build essentials (gcc, make, etc.)
sudo apt-get install -y build-essential

# Install Video4Linux2 development headers
sudo apt-get install -y libv4l-dev

# Install udev development headers (for USB device access)
sudo apt-get install -y libudev-dev
```

## Step 2: Verify Build Tools

Check that the tools are installed:

```bash
# Should show version numbers
gcc --version
make --version
pkg-config --version
```

## Step 3: Compile the Library

Navigate to the library directory and install:

```bash
cd /mnt/c/Users/Bamigos/Desktop/c_library
npm install
```

## Step 4: Test the Library

Run the test suite:

```bash
npm test
```

Or run the simple verification:

```bash
node test/simple-test.js
```

## Troubleshooting

### If you get permission errors for sudo:

You can try installing without sudo by using a package manager that doesn't require root:

```bash
# Using conda (if available)
conda install gcc make

# Or use the automated setup script:
chmod +x setup.sh
./setup.sh
```

### If npm install fails:

1. Clear npm cache:
   ```bash
   npm cache clean --force
   ```

2. Remove node_modules and try again:
   ```bash
   rm -rf node_modules
   npm install
   ```

3. Try building manually:
   ```bash
   npx node-gyp rebuild
   ```

### For WSL-specific issues:

Make sure your camera is accessible in WSL:
```bash
# List USB devices
lsusb

# Check video devices  
ls -la /dev/video*
```

## What happens next:

1. ✅ **If compilation succeeds**: You'll see "gyp info ok" and can run `npm test`

2. ✅ **If tests pass**: The library is ready to use in your Electron app

3. ❌ **If compilation fails**: Check the error messages and ensure all dependencies are installed

4. ⚠️ **If tests fail but compilation succeeded**: This is normal if no camera is connected

## Quick Verification

Run this to check if everything is set up correctly:

```bash
node -e "
try {
  const lib = require('./index.js');
  console.log('✅ Library loaded successfully');
  console.log('ℹ️  Connect your Logitech MX Brio and run: npm test');
} catch(e) {
  console.log('❌ Library failed to load:', e.message);
  console.log('💡 Make sure compilation completed successfully');
}
"
```