linking gmp(xx) in visual studio 2k5

[email protected]
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <[email protected]>
Hey experienced people,

I have been trying to get gmp and it's c++ wrapper to work from Visual
Studio 2005 so I can add the capability to a program I have been
writing.  Anyway, it's taken a couple days but I got static libraries
built on my system two ways:

1)  The first set I got by simply installing MSYS and MinGW and
compiling, then adding the two *.a files in the Project Properties.

2)  The second set I got using Brian Gladman's "Building GMP and MPFR
with Microsoft Visual Studio 2005 and YASM", and added the two *.lib
files to the project properties.

I didn't use them both at the same time, I tried one, then the other.

I used the following simple code to test compile:

#include <conio.h>
#include <gmpxx.h>
#include <iostream>

using std::cout;

int main()
{
   mpz_class i;

   i = 6;

   cout << i;

   _getch();

   return 0;
}


When I try to compile with the second set of libraries (*.lib), vc2k5
gives me:
1>Linking...
1>gmpxx.lib(get_str.obj) : error LNK2019: unresolved external symbol
___gmpn_get_str referenced in function ___gmpz_get_str
1>gmpxx.lib(get_str.obj) : error LNK2001: unresolved external symbol
___gmpn_bases
1>.\Release/testconsole.exe : fatal error LNK1120: 2 unresolved
externals


When I try to compile with the first set of libraries (*.a), vc2k5
gives me:
1>Linking...
1>libgmp.a(memory.o) : warning LNK4217: locally defined symbol __iob
imported in function ___gmp_default_allocate
1>listiter.obj : error LNK2019: unresolved external symbol "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
operator<<(class std::basic_ostream<char,struct std::char_traits<char>
> &,struct __mpz_struct const *)" (??6@YAAAV?$basic_ostream@DU?
$char_traits@D@std@@@std@@AAV01@PBU__mpz_struct@@@Z) referenced in
function "class std::basic_ostream<char,struct std::char_traits<char>
> & __cdecl operator<<<struct __mpz_struct [1]>(class
std::basic_ostream<char,struct std::char_traits<char> > &,class
__gmp_expr<struct __mpz_struct [1],struct __mpz_struct [1]> const
&)" (??$?6$$BY00U__mpz_struct@@@@YAAAV?$basic_ostream@DU?
$char_traits@D@std@@@std@@AAV01@ABV?$__gmp_expr@$$BY00U__mpz_struct@@$
$BY00U1@@@@Z)
1>.\Release/testconsole.exe : fatal error LNK1120: 1 unresolved
externals



Now if I try "g++ -lgmpxx -lgmp"  code.cpp  inside MSYS with the *.a
files, it compiles and runs, so I am guessing there is a configuration
problem, but I am not very experienced with these types of things.
I'm not sure why the *lib files would give that particular error.

Any experience/help/insight would be much appreciated.

Thanks.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.