1

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

northerner
  • 756
  • 5
  • 21
  • 1
    Please see my answer for a similar question: https://stackoverflow.com/questions/52567436/mathgl-mingw-undefined-reference-netbeans-ide/52798532#52798532 – HEKTO Dec 09 '18 at 04:04
  • @HEKTO worked :D Not sure if I should I delete this question or mark as duplicate? – northerner Dec 09 '18 at 09:30
  • I wouldn't worry about that - the library you work with is different. And you can write your own answer for future generations – HEKTO Dec 09 '18 at 22:54

1 Answers1

1

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

Community
  • 1
  • 1
northerner
  • 756
  • 5
  • 21