Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Install pgplot on your Ubuntu system by running the following command in the terminal:
sudo apt-get install pgplot5
  1. Once pgplot is installed, navigate to the directory where you have your source code files.

  2. Create a file named 'Makefile' in that directory and open it in a text editor.

  3. In the Makefile, add the following lines:

CC = /usr/bin/gcc
LIBS = -lpgplot -lcpgplot -lg2c -lX11 -lm
CFLAGS = -I/usr/include -I/usr/local/pgplot -O2

all: your_program

your_program : your_program.c
    $(CC) $(CFLAGS) -o your_program your_program.c $(LIBS)

clean:
    rm -f your_program
  1. Replace 'your_program' with the name of your program. Make sure the source file is named the same way.

  2. Save the Makefile and exit the text editor.

  3. In the terminal, navigate to the directory with the Makefile and run the command 'make'. This will compile your program using the pgplot libraries.

  4. If there are no errors, you can run your program by typing './your_program' in the terminal.