I am having an issue with my pi where I run gcc or make from the terminal and my main c file included in the compilation is deleted. I am using the wiringPi library to communicate with some sensors via i2c. The code does work, as I have been able to properly compile things without deletion before. But now whenever I run make or gcc the main c file is deleted.

Things look like this: imu_header.h imu_main.c makefile

My header holds definitions of registers and my main file connects to the device and performs reads and writes. I have also compiled code that did none of that and just printed hello world with the same main file deletion.

Here is my gcc code:

gcc -Wall -o imu_main.c imu_header.h -lwiringPi

Running this deletes the imu_main.c file.

Here is my makefile:

imuRun: imu_main.c imu_header.h
        gcc -Wall -o imu_main.c imu_header.h -lwiringPi

When I run make I also lose the imu_main.c file.

I am using the suggested gcc command from the wiringPi blink example:http://wiringpi.com/examples/blink/

Is there a syntax error here and I am doing something wrong? And what does the -Wall parameter do to the gcc command? I have started using a private github repo to store my code and prevent file loss, but this is preventing me from checking if my code even runs. Yesterday I upgraded and updated the Pi with the proper commands but that didn't change anything.

Thank you for your help.

-Mike :)

  • -o means "output". You tell GCC to overwrite your C file. Commented Jan 14, 2019 at 8:27

1 Answer 1


The -o option to gcc specifies the name to be given to the executable. You are saying name the executable as the input source code. That is almost certainly an error.

  • Thank you!! I just changed the makefile to include a name for the output file and when I ran make it didn't delete my main file!!
    – mike
    Commented Jan 13, 2019 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.