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.
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:
gcc --version
If it's not installed, you can install it using:
On Ubuntu/Debian:
sudo apt-get install build-essentialOn Fedora/CentOS:
sudo dnf groupinstall "Development Tools"On macOS (via Homebrew):
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:
#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:
gcc -o program program.c
gcc: The command to invoke the GCC compiler.-o program: This option specifies the output file name (programin this case). If you omit-o program, the default output will be a file nameda.outon Linux/macOS ora.exeon 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:
./programOn Windows:
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:
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:
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:
sudo apt-get install gcc-multilib g++-multilibOn Fedora/CentOS:
sudo dnf install glibc-devel.i686 libgcc.i686On Arch Linux:
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:
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:
./programOn Windows:
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:
gcc -m32 -g -o program program.cFor warnings:
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.