Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Errors Running C Code Libraries

796 Views - Created 09/02/2021

09/02/2021

Posted by:
Andr22

Andr22 Avatar

My Raspberry Pi 4 B is running Raspberry Pi OS. I am trying to compile and run ABE_ADCDACPi.c.



However, I keep getting all sorts of various errors. I believe I am correct in compiling it by using -nostartfiles as the .c and .h files do not use the make function commonly found in C programs. This appears to work and creates a file called a.out, however I can't run it. If someone could explain to me clearly how to compile and execute this code I would be extremely grateful. I am a total beginner when it comes to this, I just need to run this code for a project I am working on. Thanks

09/02/2021

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hello

Can you try compiling the demo-adcread.c program in the same directory as the ABE_ADCDACPi.c file?

Use the command "gcc ABE_ADCDACPi.c demo-adcread.c -o demo-adcread" to create an executable file called demo-adcread

If the demo file compiles and runs then it is probably the -nostartfiles parameter that is causing the problems with your program.

09/02/2021

Posted by:
Andr22

Andr22 Avatar

Quote from andrew
Hello Can you try compiling the demo-adcread.c program in the same directory as the ABE_ADCDACPi.c file? Use the command "gcc ABE_ADCDACPi.c demo-adcread.c -o demo-adcread" to create an executable file called demo-adcread If the demo file compiles and runs then it is probably the -nostartfiles parameter that is causing the problems with your program.

After attempting this I get a huge list of errors saying "error: stray '\1' in the program" etc

09/02/2021

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

It looks like the program files have somehow picked up some stray characters which are causing the compiler to fail.

Can you try cloning a new copy of our GitHub repository onto your Raspberry Pi using the command below and see if that has the same issues?


git clone https://github.com/abelectronicsuk/ABElectronics_C_Libraries.git

09/02/2021

Posted by:
Andr22

Andr22 Avatar

That seems to have fixed it now thanks

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.