gnuplot
c++
makefile
eps
sudo apt-get install libgnuplot-iostream-dev
example.cpp
#include"gnuplot-iostream.h"
#include<bits/stdc++.h>
Gnuplot gp;
using namespace std;
int main(){
gp << "set term postscript eps enhance color\n";
vector<pair<double, double>> m, m1;
for(int i = 0;i < 10;i++){
m.push_back(pair<double, double>(i, pow(i, 2)));
m1.push_back(pair<double, double>(i, pow(i, 3)));
}
gp << "set output \"example.eps\"\n";
gp << "set title \"power of 2\"\n";
gp << "plot" << gp.file1d(m) << "with lines title \"square\", " << gp.file1d(m1) << "with points title \"cubic\"\n";
gp << "set output\n";
}
g++ -o example example.cpp -lboost_system -lboost_iostreams -lboost_filesystem
由於在make
的auto compile的link
時,會把LDFLAGS
放在最前面,這時後會因為不需要這些東西所以沒有連結這些東西(因為需要得東西都放在後面),所以要另外寫link
的部份,強制放在最後
Makefile
CC=g++
LDFLAGS+= -lboost_system -lboost_filesystem -lboost_iostreams
dep:
gcc -lstdc++ -M *.cpp > dep
-include dep
all: example
example:example.o
$(CC) -o $@ $^ $(LDFLAGS)