In an interactive session:
syms any of the names corresponding to variables you will need to change. Calculate lhs(eqn)-rhs(eqn) and assign that to a variable.
Now call matlabFunction on the variable. Pass it the 'file' option and a file name. For example EQN.m . Pass it the 'vars' option using a cell array. In the first entry of the cell array put a vector of variable names of the variables you want solved for, in the order you want returned. The rest of the variables, the ones that will be provided as numeric parameters rather than solved for, you can either put into a vector in the second cell entry, or you can list them one at a time as cell entries.
That done, switch to the code you will be using for building the compiled application. In it, build an anonymous function that takes a single parameter, and calls EQN passing that parameter straight through, and then passing the numeric values in the same order as you specified in the 'vars' option.
Now you can pass that function handle to fsolve.
Notice that the symbolic work is done only at the interactive session, and is used to write an m file that does not use the symbolic toolbox. Notice that the code to be compiled does not use the symbolic toolbox: it only calls the m file and that file is purely numeric.
By the way, it is safer if your interactive session code initializes S1 to sym(0) instead of 0.