cannot find -lplot - fedora

cannot find -lplot - fedora

本文关键字:fedora -lplot find cannot      更新时间:2023-10-16

我在终端上使用sudo yum install gnuplot安装了gnuplot。我有一个 cpp 文件,它使用 gnuplot。我编译没有错误。在链接时,发生错误。

编译 : g++ -c plot.cpp友情链接 : g++ -o exe plot.o -lplot

法典:

int main()
{
FILE *pipe = popen("gnuplot -persist", "w");
// set axis ranges
fprintf(pipe,"set xrange [0:11]n");
fprintf(pipe,"set yrange [0:]n");
int b = 5;int a;
// to make 10 points
std::vector<int> x (10, 0.0); // x values
std::vector<int> y (10, 0.0); // y values
for (a=0;a<10;a++) // 10 plots
{
    x[a] = a;
    y[a] = 2*a;// some function of a
    fprintf(pipe,"plot '-'n");
    // 1 additional data point per plot
    for (int ii = 0; ii <= a; ii++) {
        fprintf(pipe, "%d %dn", x[ii], y[ii]); // plot `a` points
    }
    fprintf(pipe,"en");    // finally, e
    fflush(pipe);   // flush the pipe to update the plot
    usleep(1000000);// wait a second before updating again
}
return 0;
}

添加一个标志-L /where/ever/you/have/the/lib -lplot以指定libplot.a所在的位置,如果你需要该库的话。但是,从您的代码来看,您似乎只是将数据输入gnuplot但不链接到任何libplot.a