Search code examples
c++windowsnetbeansgmp

Setting up Netbeans with GMP, how to specify compile options?


I'm trying to use GMP in Netbeans on Windows. The build fails giving the output:

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)

Here are the settings I changed in Netbeans and guess where the error lies

project properites

How can I get GMP to work so I can use it in my source code?

It's definitely a setting on Netbeans as I can compile it from the command line with g++ test.cpp -o test.exe -lgmpxx -lgmp


Solution

  • Got this answer from mathGl / MinGW undefined reference Netbeans IDE

    1. right click on project and go to properties

    2. in the left pane select linker

    3. click the "..." beside libraries

    4. click "add option"

    5. select "other option" and type in -lgmpxx -lgmp

    6. click ok

      Should now see... Netbeans