If openLdap is not compiled with SASL support then the use of -x switch is not needed since it will default to using simple bind.
When I ran with ldapsearch I did as follows...
% ./ldapsearch -D "CN=Bob" -W "CN=Bob" Enter LDAP Password: password
The absence of the -x switch with ldapsearch tells me that you are not doing a simple bind here but are instead using SASL. Assuming the absence of the -x isn't a typo, that would explain the discrepancy in results between your program and ldapsearch.
-Patrick