error status: exit status 1 'S1' was not declared in this scope

int lm1 = 2;
int lm2 = 3;
int rm1 = 4;
int rm2 = 5;

int s1 = 6;
int s2 = 7;
int s3 = 8;
int s4 = 9;
int s5 = 10;
int s6 = 11;
int s7 = 12;
int s8 = 13;

void setup() {
pinMode(lm1, OUTPUT);
pinMode(lm2, OUTPUT);
pinMode(rm1, OUTPUT);
pinMode(rm2, OUTPUT);
pinMode(s1, INPUT);
pinMode(s2, INPUT);
pinMode(s3, INPUT);
pinMode(s4, INPUT);
pinMode(s5, INPUT);
pinMode(s6, INPUT);
pinMode(s7, INPUT);
pinMode(s8, INPUT);
}

void loop()
{
if((S1==0)&&(S2==0)&&(S3==0)&&(S4==0)&&(S5==0)&&(S6==1)&&(S7==1)&&(S8==1))
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}
if((S1==1)&&(S2==1)&&(S3==1)&&(S4==0)&&(S5==0)&&(S6==0)&&(S7==0)&&(S8==0))
{
digitalWrite(lm1,0);
digitalWrite(lm2,1);
digitalWrite(rm1,1);
digitalWrite(rm2,0);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}

if((S1==0)&&(S2==0)&&(S3==0)&&(S4==1)&&(S5==1)&&(S6==0)&&(S7==0)&&(S8==0))
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
digitalWrite(rm1,1);
digitalWrite(rm2,0);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}

if((S1==0)&&(S2==0)&&(S3==0)&&(S4==0)&&(S5==0)&&(S6==0)&&(S7==0)&&(S8==0))
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}

if((S1==1)&&(S2==1)&&(S3==1)&&(S4==1)&&(S5==1)&&(S6==1)&&(S7==1)&&(S8==1))
{
digitalWrite(lm1,0);
digitalWrite(lm2,0);
digitalWrite(rm1,0);
digitalWrite(rm2,0);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}

if((S1==0)&&(S2==0)&&(S3==1)&&(S4==0)&&(S5==0)&&(S6==1)&&(S7==0)&&(S8==0))
{
digitalWrite(lm1,0);
digitalWrite(lm2,1);
digitalWrite(rm1,1);
digitalWrite(rm2,0);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}

if((S1==0)&&(S2==1)&&(S3==0)&&(S4==0)&&(S5==0)&&(S6==0)&&(S7==1)&&(S8==0))
{
digitalWrite(lm1,0);
digitalWrite(lm2,1);
digitalWrite(rm1,1);
digitalWrite(rm2,0);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}

if((S1==1)&&(S2==0)&&(S3==0)&&(S4==0)&&(S5==0)&&(S6==0)&&(S7==0)&&(S8==1))
{
digitalWrite(lm1,0);
digitalWrite(lm2,1);
digitalWrite(rm1,1);
digitalWrite(rm2,0);
}
else
{
digitalWrite(lm1,1);
digitalWrite(lm2,0);
delay(1000);
digitalWrite(rm1,0);
digitalWrite(rm2,1);
delay(1000);
}
}

You declare variables s1, s2, s3, … but in your code use S1, S2, S3, … C++ is case sensitive so they are not the same.

if((S1==0)&&(S2==0)&&(S3==0)&&(S4==0)&&(S5==0)&&(S6==1)&&(S7==1)&&(S8==1))

If S1 through S8 are pin numbers, the above evaluates to

if((6==0)&&(7==0)&&(8==0)&&(9==0)&&(10==0)&&(11==1)&&(12==1)&&(13==1))

So how can that if statement ever evaluate to anything other than false?

If S1 through S8 are pin numbers you need to read the pins with digitalRead() to get their states.

Read the how to use this forum sticky to see how to properly post code and some advice on how to get the most from the forum.

Check out "const" in Arduino: const

Also, have a look at the Auto Format feature

And if you are interested have a look at this: Using millis() for timing. A beginners guide

My guess is that you are using 8 sensors for some kind of line following vehicle. You should probably take care of the cases when the number of sensors activated is not exactly 2.

const int lm1 = 2;
const int lm2 = 3;  // PWM pin
const int rm1 = 4;
const int rm2 = 5;  // PWM pin

const byte SensorPins[8] = {6, 7, 8, 9, 10, 11, 12, 13};
const char SensorWeights[8] = { -4, -3, -2, -1, 1, 2, 3, 4};
const int BaseSpeed = 100;  // Adjust speed to taste


void setup()
{
  pinMode(lm1, OUTPUT);
  pinMode(lm2, OUTPUT);
  pinMode(rm1, OUTPUT);
  pinMode(rm2, OUTPUT);
  for (int i = 0; i < 8; i++)
    pinMode(SensorPins[i], INPUT);
}

void loop()
{
  int direction = 0;

  for (int i = 0; i < 8; i++)
    direction += SensorWeights[i] * digitalRead(SensorPins[i]);

  // 'directon' is now a number that is negative if you need to steer left and
  // positive if you need to steer right
  int leftSpeed = BaseSpeed + direction;  // Slower to turn left, Faster to turn right
  int rightSpeed = BaseSpeed - direction; // Faster to turn left, Slower to turn right
  MoveForward(leftSpeed, rightSpeed);
}

void MoveForward(int leftSpeed, int rightSpeed)
{
  digitalWrite(lm1, 1);
  analogWrite(lm2, 255 - leftSpeed);

  digitalWrite(rm1, 0);
  analogWrite(rm2, rightSpeed);
}