Examining the list of shared libraries (DLLs in Windows-speak) of a compiled program can give a clue, because typically each language has a specific distinctive library to provide the runtime environment.
For example, on my Linux PC, running the ldd
command on an executable produced the following tell-tale output:
ldd *redacted*
linux-gate.so.1 => (0x0042e000)
libxerces-c.so.28 => /usr/local/lib/libxerces-c.so.28 (0x004b0000)
*redacted*.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x05f28000)
libm.so.6 => /lib/libm.so.6 (0x00a61000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x05be0000)
libc.so.6 => /lib/libc.so.6 (0x00906000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00a93000)
/lib/ld-linux.so.2 (0x008e7000)
The use of libc.so
suggests C or C++. The use of libstdc++.so
suggests C++. In fact that was a C++ program.
Searching the program executable for human readable strings can also given clues, especially if it has debugging information present.
For example, running the strings
command on that same executable revealled (among much other text) the following tell-tale strings:
virtual std::ostream* XmlToDcs::AmsResultsHandler::createOutputFileIfPossible()
pointer != static_cast< unsigned int >(-1)
std::ofstream* XmlToDcs::IndexElementsHandler::createStatementsFile(const tm&, char, char, unsigned int)
EamResultsHandler.cpp
The first three look like fragments of C++, the last looks like the name of a C++ source code file.