1. file XXX.so
This file command will output the file type of the given file. It will work for .so files. Look for ELF XX-bit in the output. It will tell you whether the file is 32 bits or 64 bits compiled.
2. readelf -h XXX.so
Thie readelf command will output the information about elf files. Look for Class: ELFXX where XX will tell you whether the file is 32 bit or 64 bit compiled
Please note that readelf -h works for archive files (.a) as well.
For windows, see Dumpbin command