mathGl/MinGW未定义参考Netbeans IDE [英] mathGl / MinGW undefined reference Netbeans IDE
问题描述
我正在尝试编译以下代码:
I'm trying to compile the below code :
#include <cstdlib>
#define HAVE_STRUCT_TIMESPEC
#include <mgl2/mgl.h>
using namespace std;
int main() {
mglGraph gr;
gr.FPlot("sin(pi*x)");
gr.WriteFrame("test.png");
return 0;
}
我正在使用Netbeans IDE,Win 10 64x ....但一直出现此错误:
I'm using Netbeans IDE , Win 10 64x .... but keep getting this error :
感谢您的帮助.
cd'C:\ Users \ SAQERpc \ Documents \ NetBeansProjects \ Plotting'
C:\ MinGW \ msys \ 1.0 \ bin \ make.exe -f Makefile CONF =调试
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE = SUBPROJECTS = .build-conf
make.exe [1]:进入目录/c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/plotting.exe
make.exe[2]: Entering directory
/c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
mkdir -p build/Debug/MinGW-Windows
rm -f构建/调试/MinGW-Windows/main.o.d"
g ++ -c -g -MMD -MP -MF"build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g ++ -o dist/Debug/MinGW-Windows/plotting build/Debug/MinGW-Windows/main.o -lmgl
build/Debug/MinGW-Windows/main.o:在函数ZN8mglGraphC1Eiii':
c:/mingw/include/mgl2/mgl.h:39: undefined reference to
_imp ___ ZTV8mglGraph'中
c:/mingw/include/mgl2/mgl.h:42:对_imp__mgl_create_graph_gl'
c:/mingw/include/mgl2/mgl.h:48: undefined reference to
_imp__mgl_create_graph的未定义引用
build/Debug/MinGW-Windows/main.o:在函数ZN8mglGraphD1Ev':
c:/mingw/include/mgl2/mgl.h:53: undefined reference to
_imp ___ ZTV8mglGraph'中
c:/mingw/include/mgl2/mgl.h:53:对_imp__mgl_use_graph'
c:/mingw/include/mgl2/mgl.h:53: undefined reference to
_imp__mgl_delete_graph的未定义引用
build/Debug/MinGW-Windows/main.o:在函数ZN8mglGraph11SetFontSizeEd':
c:/mingw/include/mgl2/mgl.h:122: undefined reference to
_imp__mgl_set_font_size'中
build/Debug/MinGW-Windows/main.o:在函数ZN8mglGraph10WriteFrameEPKcS1_':
c:/mingw/include/mgl2/mgl.h:399: undefined reference to
_imp__mgl_write_frame'中
build/Debug/MinGW-Windows/main.o:在函数ZN8mglGraph5FPlotEPKcS1_S1_':
c:/mingw/include/mgl2/mgl.h:1973: undefined reference to
_imp__mgl_fplot'中
collect2.exe:错误:ld返回1退出状态
make.exe [2]: * [dist/Debug/MinGW-Windows/plotting.exe]错误1
make.exe [2]:离开目录/c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory
/c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
make.exe:* [.build-impl]错误2
cd 'C:\Users\SAQERpc\Documents\NetBeansProjects\Plotting'
C:\MinGW\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory /c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/plotting.exe
make.exe[2]: Entering directory
/c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/plotting build/Debug/MinGW-Windows/main.o -lmgl
build/Debug/MinGW-Windows/main.o: In function ZN8mglGraphC1Eiii':
c:/mingw/include/mgl2/mgl.h:39: undefined reference to
_imp___ZTV8mglGraph'
c:/mingw/include/mgl2/mgl.h:42: undefined reference to _imp__mgl_create_graph_gl'
c:/mingw/include/mgl2/mgl.h:48: undefined reference to
_imp__mgl_create_graph'
build/Debug/MinGW-Windows/main.o: In function ZN8mglGraphD1Ev':
c:/mingw/include/mgl2/mgl.h:53: undefined reference to
_imp___ZTV8mglGraph'
c:/mingw/include/mgl2/mgl.h:53: undefined reference to _imp__mgl_use_graph'
c:/mingw/include/mgl2/mgl.h:53: undefined reference to
_imp__mgl_delete_graph'
build/Debug/MinGW-Windows/main.o: In function ZN8mglGraph11SetFontSizeEd':
c:/mingw/include/mgl2/mgl.h:122: undefined reference to
_imp__mgl_set_font_size'
build/Debug/MinGW-Windows/main.o: In function ZN8mglGraph10WriteFrameEPKcS1_':
c:/mingw/include/mgl2/mgl.h:399: undefined reference to
_imp__mgl_write_frame'
build/Debug/MinGW-Windows/main.o: In function ZN8mglGraph5FPlotEPKcS1_S1_':
c:/mingw/include/mgl2/mgl.h:1973: undefined reference to
_imp__mgl_fplot'
collect2.exe: error: ld returned 1 exit status
make.exe[2]: * [dist/Debug/MinGW-Windows/plotting.exe] Error 1
make.exe[2]: Leaving directory /c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory
/c/Users/SAQERpc/Documents/NetBeansProjects/Plotting'
make.exe": * [.build-impl] Error 2
建立失败(退出值2,总时间:2秒)
BUILD FAILED (exit value 2, total time: 2s)
推荐答案
您需要告诉链接程序一个包含所有mathGL函数的库名称.在Netbeans 8.2中,您可以通过以下方式做到这一点(我假设您的项目是"C/C ++应用程序"):
You need to tell linker a library name, containing all the mathGL functions. In Netbeans 8.2 you can do that in the following way (I'm assuming your project is "C/C++ Application"):
- 打开您的项目属性
- 点击左侧窗格中的链接器"
- 找到库"行,然后单击右侧带有"..."的按钮
- 在右窗格中单击添加选项..."
- 选择其他选项"并键入"-lmgl"
- 点击确定"
- 重建项目
最后一个名为选择选项"的弹出窗口应如下所示:
This final popup window, titled "Select Option", should look like this:
这篇关于mathGl/MinGW未定义参考Netbeans IDE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!