Skip to content

Building on Windows

Mark Lesswing edited this page Mar 7, 2017 · 1 revision

If you're looking for how to build apps that use libRETS (in C++) on Windows, look at LinkAgainstOnWindows. If you are using .NET, also check out http://wiki.rets.org/wiki/LibRETS_in_VB.NET.

The directions below are for building libRETS itself on Windows. If you are attempting to build a Windows C++ application, you will need to source distribution to get the headers, but you do not need to rebuild libRETS as you can use the pre-packaged binary from http://www.crt.realtors.org/projects/rets/librets/downloads/.

First, you need to install cygwin ( http://www.cygwin.com). Once that is done, modify the cygwin.bat file to include:

CALL "C:\Program Files\Microsoft Visual Studio 9\Common7\Tools\vsvars32.bat"

This line depends on the version of Visual Studio you have installed and on your own drive path and whether or not you are on an x86 or x64 machine. Please make the appropriate substitutions.

Also note that there is a file called \cygwin\bin\link.exe that gets in the way of the Microsoft linker, also called link.exe. Since not all of the Makefiles for the various vendor projects fully qualify the linker name, you need to remove or rename the Cygwin version.

mkdir c:\librets Note: This directory can not be below any directory with a blank within the path name(s) (e.g it can not be below "\Documents and Settings" or "\Program Files"). To make things easiest upon yourself, use c:\librets and these instructions.

cd c:\librets svn checkout https://code.crt.realtors.org/svn/librets/librets/trunk librets If you are using VS2003: svn co https://code.crt.realtors.org/svn/librets/vendor/windows vendor If you are using VS2005: svn co https://code.crt.realtors.org/svn/librets/vendor/vs2005 vendor If you are using VS2008 on an x86 machine: svn co https://code.crt.realtors.org/svn/librets/vendor/vs2008-x86 vendor If you are using VS2008 on an x64 machine: svn co https://code.crt.realtors.org/svn/librets/vendor/vs2008-x64 vendor Cd librets\project\build Copy config.vc.dist config.vc Edit config.vc Cd \librets\librets nmake /f Makefile.vc In order to develop for either x86 or x64 platforms on the same machine, you'll need to make some configuration changes to your .bash_profile file as well as using a custom Cygwin startup process. In the first case, add the following lines to your .bash_profile (of course, update the paths to what you use on your machine):

if [ "$TARGET_CPU" == "x86" ] ; then export JAVA_HOME=/cygdrive/c/Program\ Files\ (x86)/Java/jdk1.6.0_18 export JAVA_HOME_WIN="C:\Program Files (x86)\Java\jdk1.6.0_18" export PERL_HOME=/cygdrive/c/Perl export PYTHON_HOME=/cygdrive/c/Python26-x86 if [ "X$VCTOOLS" == "X" ] ; then export VCTOOLS="c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC" fi fi

if [ "$TARGET_CPU" == "x64" ] ; then export JAVA_HOME=/cygdrive/c/Program\ Files/Java/jdk1.6.0_18 export JAVA_HOME_WIN="C:\Program Files\Java\jdk1.6.0_18" export PERL_HOME=/cygdrive/c/Perl64 export PYTHON_HOME=/cygdrive/c/Python26 if [ "X$VCTOOLS" == "X" ] ; then export VCTOOLS="c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC" fi fi Instead of using /cygwin.bat to start your environment, make a copy of the SetEnv.Cmd file (typically found at \Program Files\Microsoft SDKs\Windows\v7.0\Bin) and call it Cygwin.Cmd. Next, apply the following patch to it:

85d84 < :: Set the command prompt text color based on the build configuration. 91d89 < COLOR 0E 95d92 < COLOR 02 166c163 < CLS

::CLS 676a674

689c687 < SET TARGET_CPU=

::SET TARGET_CPU= 690a689,698

:: -------------------------------------------------------------------------------------------- :: Set color based upon architecture. x86 is black on white. x64 is light aqua on blue. :: -------------------------------------------------------------------------------------------- IF "%TARGET_CPU%" == "x86" COLOR f0 ::IF "%TARGET_CPU%" == "x64" COLOR f4 IF "%TARGET_CPU%" == "x64" COLOR 1b

c:\cygwin\bin\bash --login -i Lastly, you can create shortcuts to invoke the proper environment. For example, in order to invoke the x64 version, use the following shortcut:

C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K C:\cygwin\CygWin64.Cmd /Release /x64 Also refer to the the current documentation at https://code.crt.realtors.org/projects/librets/browser/librets/trunk/doc/build/windows.txt