使用GMP设置Netbeans,如何指定编译选项?

时间:2018-12-03 11:15:13

标签: c++ windows netbeans gmp

我正在尝试在Windows的Netbeans中使用GMP。构建失败,输出如下:

cd 'C:\Users\dev1\Documents\NetBeansProjects\Simple Test'
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/dev1/Documents/NetBeansProjects/Simple Test'
"/C/MinGW/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/simple_test.exe
make.exe[2]: Entering directory `/c/Users/dev1/Documents/NetBeansProjects/Simple Test'
mkdir -p dist/Debug/MinGW-Windows
g++     -o dist/Debug/MinGW-Windows/simple_test build/Debug/MinGW-Windows/main.o 
build/Debug/MinGW-Windows/main.o: In function `ZN17__gmp_binary_plus4evalEP12__mpz_structPKS0_m':
c:/mingw/include/gmpxx.h:196: undefined reference to `__gmpz_add_ui'
build/Debug/MinGW-Windows/main.o: In function 
c:/mingw/include/gmpxx.h:1497: undefined reference to `__gmpz_init'
//...same thing
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/simple_test.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/dev1/Documents/NetBeansProjects/Simple Test'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/dev1/Documents/NetBeansProjects/Simple Test'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)

这是我在Netbeans中更改的设置,并猜测错误在哪里

project properites

如何使GMP起作用,以便可以在源代码中使用它?

这绝对是Netbeans上的设置,因为我可以使用g++ test.cpp -o test.exe -lgmpxx -lgmp在命令行中对其进行编译

1 个答案:

答案 0 :(得分:1)

mathGl / MinGW undefined reference Netbeans IDE那里得到了答案

  1. 右键单击项目并转到属性
  2. 在左窗格中选择链接器
  3. 单击库旁边的“ ...”
  4. 点击“添加选项”
  5. 选择“其他选项”,然后输入-lgmpxx -lgmp
  6. 单击确定

    现在应该看到... Netbeans