This is a quick summary of how to write and run a C program in Linux.
A Simple Hello World
1. Issue the command "sudo nano hello-world.c" to launch the nano editor;
2. Enter the code below in nano. Press Ctrl-X then press Y to save.
#include <stdio.h>
int main()
{
printf("Hello, World! \n");
return 0;
}
3. Issue the command "gcc hello-world.c -o myfirstcprogram" to compile;
4. Issue the command "./myfirstcprogram" to execute it.
Reference:
HOW TO WRITE AND RUN A C PROGRAM ON THE RASPBERRY PI
http://www.circuitbasics.com/how-to-write-and-run-a-c-program-on-the-raspberry-pi/
This blog is for keeping my study notes, sharing knowledge and showing the products of my study.. I welcome your feedback...
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
2019/12/03
2017/08/28
Linux - How to solve the problem of "/usr/bin/ld: cannot find -lxxx"
When compiling applications or lib source codes, sometime we will encounter error message such as the one shown below.
/usr/bin/ld: cannot find -lxxx
/usr/bin/ld: cannot find -lxxx
Depending on the code being compiled, the error message may look like:
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lltdl
/usr/bin/ld: cannot find -lXlst
The xxx represents the name of the library, for example, libc.so, libltdl.so, libXtst.so. The naming rule is: lib + library name (i.e. xxx) + .so.
Subscribe to:
Posts (Atom)