MathGL/C++ 入门程序未定义引用

MathGL/C++ Starter Program undefined references

提问人:Defiant1 提问时间:10/10/2023 最后编辑:genpfaultDefiant1 更新时间:10/10/2023 访问量:41

问:

我在编译 MathGL 示例程序时遇到问题。它在链接过程中失败。我在 Win10/64 的 Mingw64 环境中使用 MSYS2。

错误:

$ make
g++ -o test test.o
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe
: test.o:test.c:(.text+0x1a): undefined reference to `__imp_mgl_create_graph'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe
: test.o:test.c:(.text+0x43): undefined reference to `__imp_mgl_fplot'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe
: test.o:test.c:(.text+0x61): undefined reference to `__imp_mgl_write_frame'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe
: test.o:test.c:(.text+0x71): undefined reference to `__imp_mgl_delete_graph'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:8: test] Error 1

生成文件:

CC=g++
CFLAGS= -I. -lmgl -lodbc

%.o: %.c
    $(CC) -c -o $@ $< $(CFLAGS)

test: test.o
    $(CC) -o test test.o

法典:

#include <mgl2/mgl_cf.h>

int main(void) {

    HMGL gr = mgl_create_graph(600,400);
    mgl_fplot(gr,"sin(pi*x)","","");
    mgl_write_frame(gr,"test.png","");
    mgl_delete_graph(gr);

    return 0;

};
C++ makefile 未定义引用 msys2 mathgl

评论


答: 暂无答案