$? returns the exit value of previous command (that's where the 0 comes from). What exactly are you trying to do here:
if ( $?LD_LIBRARY_PATH ) then
In addition you have to use  in bash instead of (). You can test if string length is nonzero with [ ! -z "$VARIABLE" ], but you cannot use wildcards (like ?) in variable names (if that was what you tried to do?) As far as I can see, you could just use:
There is no need for the whole if-then-else structure. It doesn't matter if LD_LIBRARY_PATH is previously unset.