How to compile from Source Codes and the Tools

General discussion about computer chess...
gaard
Posts: 127
Joined: Thu Jun 10, 2010 1:39 am
Real Name: Martin Wyngaarden
Location: Holland, Michigan

Re: How to compile from Source Codes and the Tools

Post by gaard » Wed Feb 02, 2011 4:44 am

Prima wrote:
gaard wrote:http://dl.dropbox.com/u/11904592/pgort.zip

Here are pgort90 and pgort100. They should do the trick. There are 4 depending on if you are compiling for amd64 or x86 and for both VS2010 compilers or VS2008.

Both Ultimate and Professional editions of Visual Studio have the optimizing compiler. I thought the standard edition did as well. It is not always evident from the GUI however. Get a command and run "link". If you see the option /LTCG, then there should not be a problem.

On a side note, MS put out a free optimizing compiler some years ago in the MSVCPP Toolkit 2003. It's not fully compliant, however, but it does produce very fast binaries when it works.
Gaad, thanks for your consideration and help.

After installing your pgor90 & 100.dll (placed in c:\Windows\System32), I still get incompatible error report. I did notice a difference between the pgort100.dll and the pgort100.dll I got from the inter: yours is 34.8KB and mine is 100KB. Still got the same error though

Here's the exact message attached.
The username is actually gaard, not gaad, though gaad does sound flattering being so close to God :)

I have seen that error before and I don't think it is related to the missing pgort dll. I believe it is an issue with linking to the correct run time libraries. If you could, try to link with /MD /NODEFAULTLIB:libcmt.lib or
/MT /NODEFAULTLIB:msvcrt.lib and see if that does it.

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Wed Feb 02, 2011 6:06 am

gaard wrote:The username is actually gaard, not gaad, though gaad does sound flattering being so close to God :)

I have seen that error before and I don't think it is related to the missing pgort dll. I believe it is an issue with linking to the correct run time libraries. If you could, try to link with /MD /NODEFAULTLIB:libcmt.lib or
/MT /NODEFAULTLIB:msvcrt.lib and see if that does it.
Sorry about the name-mispell gaard :oops: .

I appreciate your advise and offer to help but here's the thing; I just started learning how to compile about roughly 1week +. Thanks to Kingliveson for the tutoring he provided to me on the first (or second page) of this topic.

Any way,.... .translation: I'm a newbie at this, let alone know how to "link" files etc.

If you can tell me how to do this linkage, it will be another "compile knowledge" gained and appreciated :D . Also, if you prefer to do picture-tutorials or write the instructions here on how to "link" correct run time libraries, it is fine with me. Thanks gaard.

PS: My compiler is Microsoft Visual Studio 2010. It's a 30-day trial. As I'm typing this on the forum, I just completed installing another 30-day trial compiler: Microsoft Visual Studio 2010 Express.

The 31-day trial Intel C++ Compiler XE 2011 installed on Jna. 24.2011 (just after 1 week of usage)started asking for license! Now I can't use it for compile anymore.

Best.

gaard
Posts: 127
Joined: Thu Jun 10, 2010 1:39 am
Real Name: Martin Wyngaarden
Location: Holland, Michigan

Re: How to compile from Source Codes and the Tools

Post by gaard » Wed Feb 02, 2011 7:10 am

Prima wrote:
gaard wrote:The username is actually gaard, not gaad, though gaad does sound flattering being so close to God :)

I have seen that error before and I don't think it is related to the missing pgort dll. I believe it is an issue with linking to the correct run time libraries. If you could, try to link with /MD /NODEFAULTLIB:libcmt.lib or
/MT /NODEFAULTLIB:msvcrt.lib and see if that does it.
Sorry about the name-mispell gaard :oops: .

I appreciate your advise and offer to help but here's the thing; I just started learning how to compile about roughly 1week +. Thanks to Kingliveson for the tutoring he provided to me on the first (or second page) of this topic.

Any way,.... .translation: I'm a newbie at this, let alone know how to "link" files etc.

If you can tell me how to do this linkage, it will be another "compile knowledge" gained and appreciated :D . Also, if you prefer to do picture-tutorials or write the instructions here on how to "link" correct run time libraries, it is fine with me. Thanks gaard.

PS: My compiler is Microsoft Visual Studio 2010. It's a 30-day trial. As I'm typing this on the forum, I just completed installing another 30-day trial compiler: Microsoft Visual Studio 2010 Express.

The 31-day trial Intel C++ Compiler XE 2011 installed on Jna. 24.2011 (just after 1 week of usage)started asking for license! Now I can't use it for compile anymore.

Best.
Believe it or not, I have VS 2010 Ultimate but I never even use the GUI. The command line has always been easier for me and I recommend you try it too unless you're managing multiple solutions and huge projects.

1) See that you have vcvarsall.bat in your PATH. If not, go to environmental variables (My Computer > Properties) and add it. Mine is C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

2) Open a command prompt in the directory with the source code that you want to compile. Type vcvarsall amd64, or vcvarsall x86, if you want to build a 32-bit binary. This will setup your PATH to use the correct directories for you include/library files and linker and compiler.

3) First type "cl" at the command prompt and report back what version of the MS compiler you are using.

4) "C:\>cl *.cpp" will compile all the source files in the current directory. In the case of your issue with the run time libraries you will want to try "cl /MT /NODEFAULTLIB:msvcrt.lib *.cpp" or "cl /MD /NODEFAULTLIB:libcmt.lib *.cpp" Instrumenting a file requires you add the /c switch when compiling, and then "link /LTCG:PGI /OUT:filename *.obj" and then after profiling use "link /LTCG:PGO /OUT:filename *.obj" to compile with the profile data to build the optimized binary.

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Wed Feb 02, 2011 7:36 am

gaard wrote:Believe it or not, I have VS 2010 Ultimate but I never even use the GUI. The command line has always been easier for me and I recommend you try it too unless you're managing multiple solutions and huge projects.

1) See that you have vcvarsall.bat in your PATH. If not, go to environmental variables (My Computer > Properties) and add it. Mine is C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

2) Open a command prompt in the directory with the source code that you want to compile. Type vcvarsall amd64, or vcvarsall x86, if you want to build a 32-bit binary. This will setup your PATH to use the correct directories for you include/library files and linker and compiler.

3) First type "cl" at the command prompt and report back what version of the MS compiler you are using.

4) "C:\>cl *.cpp" will compile all the source files in the current directory. In the case of your issue with the run time libraries you will want to try "cl /MT /NODEFAULTLIB:msvcrt.lib *.cpp" or "cl /MD /NODEFAULTLIB:libcmt.lib *.cpp" Instrumenting a file requires you add the /c switch when compiling, and then "link /LTCG:PGI /OUT:filename *.obj" and then after profiling use "link /LTCG:PGO /OUT:filename *.obj" to compile with the profile data to build the optimized binary.
Thanks gaard. No.1 and no.2 checked out okay in my OS. On step 3, after typing "cl", the Microsoft Visual Studio 2010 professional reported the version I was using for me. It didn't ask for me about version, nor did I have to tell it the version I used.

Step 4 is where I'm having some confusion. Do I place the source code files of an engine I wish to compile in c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC?
If yes, is it better for me to place the source files as "it is" in this VC file OR, do I place the source code files in a folder (i e, EngineSRC) and place it in this VS?

Another thing, are there spaces between these "Linking compile"? For example,
"cl /MT/NODEFAULTLIB:msvcrt.lib *.cpp", OR
"cl /MD /NODEFAULTLIB:libcmt.lib *.cpp"...?

What of the quotation marks, do I include them in the command prompt for compiles? I got an error when I tried. I've attached it for you.
Attachments
CompileLinking-1.PNG
Command Prompt error message

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Wed Feb 02, 2011 7:53 am

By the way, the version I'm using is: Microsoft (R) C/C++ Optimizing Version 16.00.30319.01 for x64......

gaard
Posts: 127
Joined: Thu Jun 10, 2010 1:39 am
Real Name: Martin Wyngaarden
Location: Holland, Michigan

Re: How to compile from Source Codes and the Tools

Post by gaard » Wed Feb 02, 2011 9:05 am

Prima wrote:
gaard wrote:Believe it or not, I have VS 2010 Ultimate but I never even use the GUI. The command line has always been easier for me and I recommend you try it too unless you're managing multiple solutions and huge projects.

1) See that you have vcvarsall.bat in your PATH. If not, go to environmental variables (My Computer > Properties) and add it. Mine is C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

2) Open a command prompt in the directory with the source code that you want to compile. Type vcvarsall amd64, or vcvarsall x86, if you want to build a 32-bit binary. This will setup your PATH to use the correct directories for you include/library files and linker and compiler.

3) First type "cl" at the command prompt and report back what version of the MS compiler you are using.

4) "C:\>cl *.cpp" will compile all the source files in the current directory. In the case of your issue with the run time libraries you will want to try "cl /MT /NODEFAULTLIB:msvcrt.lib *.cpp" or "cl /MD /NODEFAULTLIB:libcmt.lib *.cpp" Instrumenting a file requires you add the /c switch when compiling, and then "link /LTCG:PGI /OUT:filename *.obj" and then after profiling use "link /LTCG:PGO /OUT:filename *.obj" to compile with the profile data to build the optimized binary.
Thanks gaard. No.1 and no.2 checked out okay in my OS. On step 3, after typing "cl", the Microsoft Visual Studio 2010 professional reported the version I was using for me. It didn't ask for me about version, nor did I have to tell it the version I used.

Step 4 is where I'm having some confusion. Do I place the source code files of an engine I wish to compile in c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC?
If yes, is it better for me to place the source files as "it is" in this VC file OR, do I place the source code files in a folder (i e, EngineSRC) and place it in this VS?

Another thing, are there spaces between these "Linking compile"? For example,
"cl /MT/NODEFAULTLIB:msvcrt.lib *.cpp", OR
"cl /MD /NODEFAULTLIB:libcmt.lib *.cpp"...?

What of the quotation marks, do I include them in the command prompt for compiles? I got an error when I tried. I've attached it for you.
That's good news. You've got the same compiler that is packaged with VS 2010 Ultimate.

The quotations are not needed on the command line and there should be spaces between the switches. /MT is separate from /NODEFAULTLIB:msvcrt.lib. You can dump the source files anywhere you want, for example, EngineSRC. Just make sure to cd to that directory to compile or, in Win 7 you can Shift-Right click and you get an option to "Open command window here", same thing.
Untitled.png
Untitled2.png
Apparently I was wrong before and the correct command line is >cl /MT *.cpp /link /NODEFAULTLIB:msvcrt.lib

You'll notice I am using the /W0 switch to suppress all warnings which is generally a bad idea but I didn't want to be bothered by them right now :)

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Wed Feb 02, 2011 10:34 am

gaard,

I did the Shit + Right click and got the Open Command Prompt here option. All okay.

When I type this in the command prompt; vcvarsall amd64, I get a message stating:
"vcvarsall is not recognized as an internal or external command"...

which I've attached here. Windows is beginning to tick me off. I'm only tolerating Windows because most or all UCI engines are readily available in Windows format.
Attachments
CommandPrompt Error.PNG
Command Prompt Compile error message

gaard
Posts: 127
Joined: Thu Jun 10, 2010 1:39 am
Real Name: Martin Wyngaarden
Location: Holland, Michigan

Re: How to compile from Source Codes and the Tools

Post by gaard » Wed Feb 02, 2011 3:58 pm

Prima wrote:gaard,

I did the Shit + Right click and got the Open Command Prompt here option. All okay.

When I type this in the command prompt; vcvarsall amd64, I get a message stating:
"vcvarsall is not recognized as an internal or external command"...

which I've attached here. Windows is beginning to tick me off. I'm only tolerating Windows because most or all UCI engines are readily available in Windows format.
You need to add this directory to your PATH in environment variables: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

Here is a walk through showing you how to do that:
http://www.itechtalk.com/thread3595.html

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Wed Feb 02, 2011 6:56 pm

gaard wrote:You need to add this directory to your PATH in environment variables: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

Here is a walk through showing you how to do that:
http://www.itechtalk.com/thread3595.html
Done. I added this directory to the "System Variables" section. Then I did Shift + Right mouse click on the source-folder and upon typing :
vcvarsall amd64 and still get this message:
"vcvarsall" is not recognized as an internal or external command, operable program or batch file"
.

I've attached the path to where I added it in System Environments. In my case, I defined the Variables as VCVARSALL and its Value is defined as the path:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
Attachments
EnvironmentVariables-2.PNG

gaard
Posts: 127
Joined: Thu Jun 10, 2010 1:39 am
Real Name: Martin Wyngaarden
Location: Holland, Michigan

Re: How to compile from Source Codes and the Tools

Post by gaard » Wed Feb 02, 2011 8:34 pm

Prima wrote:
gaard wrote:You need to add this directory to your PATH in environment variables: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

Here is a walk through showing you how to do that:
http://www.itechtalk.com/thread3595.html
Done. I added this directory to the "System Variables" section. Then I did Shift + Right mouse click on the source-folder and upon typing :
vcvarsall amd64 and still get this message:
"vcvarsall" is not recognized as an internal or external command, operable program or batch file"
.

I've attached the path to where I added it in System Environments. In my case, I defined the Variables as VCVARSALL and its Value is defined as the path:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
You need to find "PATH" in the list and add this to the end of it:

;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

Make sure there is a semi-colon between this entry and the one that you are pasting it behind.

Post Reply