Microsoft visual studio 112008中lable的长宽无法设置么? 若能,如何设置? 望大虾帮忙!! 于此谢谢。

评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
第一章 ASP.NET 教程 (基础)
第二章 ASP.NET 教程(高级)How to Install and Run GMP on Windows Using MPIR
(Published March 1st, 2010)
/how-to-install-and-run-gmp-on-windows-using-mpir/
To perform arbitrary-precision arithmetic in C and C++ programs on Windows, I use . In particular, I use , a . MPIR is a simple alternative to using GMP under
I will show you how to install MPIR in Microsoft Visual C++ as a static, 32-bit library. I will also show you how to install the optional C++ interface — also as a static, 32-bit library. I will provide two example C programs that call the GMP integer and floating-point functions, and two equivalent C++ programs — programs that use the same GMP functions, only indirectly through the C++ interface.
1. Download What You Need
To install MPIR and run it under Visual C++ as I have, you’ll need four things:
Microsoft Visual C++ (I use ).
A file archiver (I use ).
The MPIR source code and Visual C++ solution (I use , which is based on GMP version 4.2.1).
The Yasm assembler (I use ).
(I won’t describe how to install Visual C++ or 7-zip.)
2. Prepare to Build MPIR
MPIR must be built with Visual C++; to prepare for that, do the following:
From mpir-1.3.1.tar.gz, use your file archiver to extract mpir-1.3.1. from mpir-1.3.1.tar, extract folder mpir-1.3.1.
Copy \mpir-1.3.1\build.vc9\yasm.rules to the Visual C++ project defaults directory (mine is C:\Program Files\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\).
Rename file yasm-0.8.0-win32.exe to yasm.exe.
Move yasm.exe to the Visual C++ binary directory (mine is C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\).
3. Build MPIR
Here’s how to build MPIR as a static Win32 library:
Open the MPIR Visual C++ solution \mpir-1.3.1\build.vc9\mpir.sln.
You get the following error message if you are using Visual Studio Express:
The project consists entirely of configurations that require support for platforms which are not installed on this machine. The project cannot be loaded.
This message is referring to the 64-bit projects, which we won’t be using anyway. Hit &Enter& to ignore (do this eight times — one for each 64-bit project in the solution.)
Right click on &Solution &mpir& (14 projects)&, select &Properties& and then click on &Configuration Properties& and then click on &Configuration Manager&. In the box labeled &Active solution configuration& select &Release& and then click &Close& and then click &OK&.
Build the version of the library you want by right clicking on the project name and selecting &Build& (I built lib_mpir_p4, labeled in the readme file as the &MPIR library using Pentium IV assembler&).
A successful build of lib_mpir_p4, which should take less than two minutes, gives this message:
Build: 6 succeeded, 0 failed, 0 up-to-date, 0 skipped
(You can ignore the compiler warning messages.)
Optional: for C++ interface only: Build the C++ interface by right clicking on project lib_mpir_cxx and selecting &Build& (again, ignore the compiler warning messages).
4. Install the MPIR Library in Visual C++
To install MPIR in Visual C++, you need to copy three files from the MPIR build directory into corresponding Visual C++ directories:
Copy files mpir.lib and mpir.pdb from
\mpir-1.3.1\build.vc9\lib_mpir_p4\Win32\Release\
to the Visual C++ library directory
C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\.
Copy \mpir-1.3.1\build.vc9\lib_mpir_p4\Win32\Release\mpir.h
to the Visual C++ include directory
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\.
Optional: for C++ interface only: To install the library for the C++ interface, you need to copy three files from the MPIR build directory into corresponding Visual C++ directories:
Copy files mpirxx.lib and mpirxx.pdb from
\mpir-1.3.1\build.vc9\lib_mpir_cxx\Win32\Release\
to the Visual C++ library directory
C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\.
Copy \mpir-1.3.1\build.vc9\lib_mpir_cxx\Win32\Release\mpirxx.h
to the Visual C++ include directory
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\.
(Unless you want to build another library, you can delete the folder mpir-1.3.1 at this point, and perhaps file mpir-1.3.1.tar.gz too. You might also want to wait until you run the test programs below.)
5. Configure Your Visual C++ Project to Use MPIR
Open an existing Visual C++ solution or create a new one.
Right click on the project name and select &Properties&. Then click &Configuration Properties&, then click &Linker&, and then click &Command Line&. In the &Additional options& box, enter &mpir.lib& and click OK.
Optional: for C++ interface only: Also add &mpirxx.lib& to the command line:
Right click on the project name and select &Properties&. Then click &Configuration Properties&, then click &C/C++&, and then click &Code Generation&. In the &Runtime Library& pulldown menu, select &Multi-threaded (/MT)& and click OK. This takes care of the linker warning message you would otherwise get:
LINK : warning LNK4098: defaultlib ‘LIBCMT’ conflicts wi use /NODEFAULTLIB:library
Writing a C/C++ Program that Uses the Standard GMP Interface
To access the GMP functions through their standard interface from your C/C++ source code, you must include the file &mpir.h&, as follows:
#include &mpir.h&
(A vanilla GMP program would have the line &#include &gmp.h&& other than this, there are no source code differences.)
The MPIR GMP functions are documented in the , which is essentially the same document as the .
Here are two C programs I wrote that you can use to test out the standard GMP interface: one uses some integer functions, and one uses some floating-point functions:
C Program Using GMP Integers Through the Standard Interface
#include &stdio.h&
#include &mpir.h&
int main (int argc, char *argv[])
mpz_t aBigPO2;
mpz_init(aBigPO2);
mpz_set_ui(aBigPO2, ); //2^30
mpz_mul(aBigPO2,aBigPO2,aBigPO2); //2^60
mpz_mul(aBigPO2,aBigPO2,aBigPO2); //2^120
mpz_mul(aBigPO2,aBigPO2,aBigPO2); //2^240
mpz_mul(aBigPO2,aBigPO2,aBigPO2); //2^480
mpz_mul(aBigPO2,aBigPO2,aBigPO2); //2^960
mpz_mul(aBigPO2,aBigPO2,aBigPO2); //2^1920
mpz_out_str(stdout,10,aBigPO2);
printf (&\n&);
mpz_clear(aBigPO2);
This prints out 21920:
(I verified this with ).
C Program Using GMP Floating-Point Numbers Through the Standard Interface
#include &stdio.h&
#include &mpir.h&
int main (int argc, char *argv[])
mpf_t aSmallPO2;
mpf_init2(aSmallPO2,4449); //Set precision to 4449 bits
mpf_set_d (aSmallPO2,0.515625); //2^-30
mpf_mul(aSmallPO2,aSmallPO2,aSmallPO2); //2^-60
mpf_mul(aSmallPO2,aSmallPO2,aSmallPO2); //2^-120
mpf_mul(aSmallPO2,aSmallPO2,aSmallPO2); //2^-240
mpf_mul(aSmallPO2,aSmallPO2,aSmallPO2); //2^-480
mpf_mul(aSmallPO2,aSmallPO2,aSmallPO2); //2^-960
mpf_mul(aSmallPO2,aSmallPO2,aSmallPO2); //2^-1920
mpf_out_str (stdout,10,0,aSmallPO2);
printf (&\n&);
mpf_clear(aSmallPO2);
In case you are wondering, 4449 bits of precision is the minimum needed to print all the digits of 2-1920, which is:
(I verified this with ).
Writing a C++ Program that Uses the GMP C++ Interface
(To use the C++ interface you will have had to have followed the build steps labeled &optional& above.)
To access the GMP functions through their C++ interface, you must include the file &mpirxx.h&, as follows:
#include &mpirxx.h&
(A vanilla GMP program would have the line &#include &gmpxx.h&& instead.)
Also, your source code will require this additional line, if you want to remove the compiler warnings due to mpirxx.h:
#pragma warning(disable: 4800)
Without this, you will get about a dozen warning messages like this:
c:\program files\microsoft visual studio 9.0\vc\include\mpirxx.h(1610) : warning C4800: ‘int’ : forcing value to bool ‘true’ or ‘false’ (performance warning)
The MPIR GMP C++ interface is documented in the
(and the ).
Here are two C++ programs I wrote that you can use to test out the GMP C++ interface: they are the equivalent of the two C programs above, except they’re expressed much more naturally (as to be expected in a C++ program):
C++ Program Using GMP Integers Through the C++ Interface
#include &iostream&
#pragma warning(disable: 4800)
#include &mpirxx.h&
#pragma warning(default: 4800)
int main (int argc, char *argv[])
mpz_class aBigPO2;
aBigPO2 = ; //2^30
aBigPO2*=aBigPO2; //2^60
aBigPO2*=aBigPO2; //2^120
aBigPO2*=aBigPO2; //2^240
aBigPO2*=aBigPO2; //2^480
aBigPO2*=aBigPO2; //2^960
aBigPO2*=aBigPO2; //2^1920
cout && aBigPO2 &&
(This gives the same output as the C program above.)
C++ Program Using GMP Floating-Point Numbers Through the C++ Interface
#include &iostream&
#include &iomanip&
#pragma warning(disable: 4800)
#include &mpirxx.h&
#pragma warning(default: 4800)
int main (int argc, char *argv[])
mpf_class aSmallPO2(0,4449); //Init to 0, precision 4449 bits
aSmallPO2 = 0.515625; //2^-30
aSmallPO2*=aSmallPO2; //2^-60
aSmallPO2*=aSmallPO2; //2^-120
aSmallPO2*=aSmallPO2; //2^-240
aSmallPO2*=aSmallPO2; //2^-480
aSmallPO2*=aSmallPO2; //2^-960
aSmallPO2*=aSmallPO2; //2^-1920
cout && setprecision (1343) && aSmallPO2 &&
The value of 1343 to setprecision is the precision in decimal digits.
The output differs slightly from it’s corresponding C program (the number is shifted one place and has the corresponding exponent to match):
Besides the much cleaner syntax of the C++ programs, the underlying GMP functions — &*_init&, &*_clear&, &*_mul&, etc. — are hidden in the C++ classes.
For Further Information
This article is my distillation of the MPIR readme file for a specific build scenario — please refer to \mpir-1.3.1\build.vc9\readme.txt for details on other builds.
Acknowledgement
Thanks to Brian Gladman for answering my questions and for suggesting I explore the C++ interface.
Comments: 88
You can follow any responses to this entry through the
Featured Article
Latest Articles

我要回帖

更多关于 visual studio 11 的文章

 

随机推荐