简体   繁体   中英

How can I get VSCode to find gmp.h after it has been successfully installed on Windows 10?

After installing and following the instructions for GMP (using mingw64 since I am on windows) and verifying the installation was correct using make check I tried running the following code in VSCode using the command g++ -g \\path\\file.cpp -lgmpxx -lgmp -o \\path\\file.exe :

#include <gmp.h>
#include <iostream>

using namespace std;

int main()
{
    mpz_class a,b,c;
    cout << "Hello World\n";
    a = 1234;
    b = "5678";
    c = a+b;
    return 0;
}

But get the error error: 'mpz_class' was not declared in this scope . So the include path in VSCode is incorrectly set up or the installation was messed up. I am wondering how to fix this: is this VSCode's includePath (compilerPath is not set up), an installation issue (I could not determine the default install location for windows systems since everything I found was for Linux), or is there something else I missed? I saw a flag for ./configure that was --enable-cxx but I wanted to ask before running make clean and retrying with that flag turned on since it takes forever.

I feel like this is something dead simple since I cannot find any help from googling.

Thank you for any help!

EDIT: I have tried running the code not in VSCode and it still has the same issue so I am not so sure it's VSCode.

I don't know anything about GMP, but you seem to include the wrong header.

#include <gmpxx.h> worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM