This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Create how to compile program in c.md
the witcher39e765c06cc8
diff --git a/Reverse Engineering/how to compile program in c.md b/Reverse Engineering/how to compile program in c.mdnew file mode 100644index 0000000..ebfd8b0--- /dev/null+++ b/Reverse Engineering/how to compile program in c.md@@ -0,0 +1,152 @@+To compile a program in C, you typically use a compiler like GCC (GNU Compiler Collection). Here's a step-by-step guide on how to compile a C program:++### 1. **Install GCC (if not installed)**+Before compiling, ensure that GCC is installed on your system. You can check by typing:++```bash+gcc --version+```++If it's not installed, you can install it using:++- On **Ubuntu/Debian**:++ ```bash+ sudo apt-get install build-essential+ ```++- On **Fedora/CentOS**:++ ```bash+ sudo dnf groupinstall "Development Tools"+ ```++- On **macOS** (via Homebrew):++ ```bash+ brew install gcc+ ```++### 2. **Write Your C Program**+Create a C file with a `.c` extension, e.g., `program.c`. Here's a simple C program as an example:++```c+#include <stdio.h>++int main() {+ printf("Hello, World!\n");+ return 0;+}+```++### 3. **Compile the Program**+To compile the C file, use the following command in the terminal:++```bash+gcc -o program program.c+```++- **`gcc`**: The command to invoke the GCC compiler.+- **`-o program`**: This option specifies the output file name (`program` in this case). If you omit `-o program`, the default output will be a file named `a.out` on Linux/macOS or `a.exe` on Windows.+- **`program.c`**: The name of the source code file you are compiling.++### 4. **Run the Compiled Program**+Once the program is compiled successfully, you can run the executable file:++- On **Linux/macOS**:++ ```bash+ ./program+ ```++- On **Windows**:++ ```bash+ program.exe+ ```++### 5. **Compile with Debugging Information (Optional)**+If you want to debug your program with tools like GDB, compile with debugging symbols by adding the `-g` flag:++```bash+gcc -g -o program program.c+```++This includes additional information that is useful for debugging but doesn't affect the program's performance during normal execution.++### 6. **Compile with Warnings (Optional)**+To compile the program and enable warnings (helpful for catching potential issues), use the `-Wall` flag:++```bash+gcc -Wall -o program program.c+```++This will show you common warnings about your code.++# To compile a C program targeting a 32-bit architecture using GCC on a 64-bit system, you can use the `-m32` option. Here's how to do it:++### 1. **Install 32-bit Libraries**+Before compiling for 32-bit, you may need to install the 32-bit libraries and development tools on your system.++- On **Ubuntu/Debian**:++ ```bash+ sudo apt-get install gcc-multilib g++-multilib+ ```++- On **Fedora/CentOS**:++ ```bash+ sudo dnf install glibc-devel.i686 libgcc.i686+ ```++- On **Arch Linux**:++ ```bash+ sudo pacman -S lib32-gcc-libs+ ```++### 2. **Compile the Program for 32-bit**+Once the 32-bit libraries are installed, compile your C program using the `-m32` option:++```bash+gcc -m32 -o program program.c+```++### 3. **Explanation of the Command**+- **`gcc`**: The GCC compiler command.+- **`-m32`**: Tells GCC to generate a 32-bit binary.+- **`-o program`**: Specifies the output file name (`program`).+- **`program.c`**: The name of the source code file.++### 4. **Run the 32-bit Program**+After compiling, you can run the program as usual:++- On **Linux/macOS**:++ ```bash+ ./program+ ```++- On **Windows**:++ ```bash+ program.exe+ ```++### 5. **Compile with Debugging or Warnings (Optional)**+To include debugging information or enable warnings while targeting 32-bit, you can combine the flags:++- For debugging:++ ```bash+ gcc -m32 -g -o program program.c+ ```++- For warnings:++ ```bash+ gcc -m32 -Wall -o program program.c+ ```++This will compile your program to run on a 32-bit architecture while maintaining debugging information or warning flags, as needed.