Article Title: multi-threaded programs in Linux compile makefile files. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In Linux, the command for compiling a multi-threaded program is:
Gcc-lpthread-o file. c
In Linux, use a cross compiler to compile a multi-threaded program running in uclinux. The makefile file is as follows:
CFLAGS =-Wall-OS-Dlinux-D _ linux _-Dunix-D _ uClinux _-DEMBED
LDFLAGS =-Wl,-elf2flt LOCAL_LIBS =/usr/local/arm-elf/lib/libpthread.
CC = arm-elf-gcc
LD = arm-elf-gcc
TARGT = test
OBJ = $ (TARGT). o
SRC = $ (TARGT). c
All: $ (TARGT)
%. O: %. c
$ (CC) $ (CFLAGS)-c $ <-o $ @
$ (TARGT): $ (OBJ) $ (LOCAL_LIBS)
$ (CC) $ (CFLAGS) $ (LDFLAGS)-o $ @ $ (OBJ) $ (LOCAL_LIBS) $ (LDLIBS)
Clean:
-Rm-f $ (EXEC) *. elf *. gdb *. o |