For me, sanity was barely preserved as it cost me three solid days of frustration. Someone once wrote (in equivalent French): "All the mornings of the world are without return." For me, a few of those figurative mornings involve more than one sense of the word "return".
I write this so that you can avoid that downtime. I believe this document is current and relevant at the time of writing, after which there are no guarantees (of course).
spld
(the Sicstus Linker):
To use splfr and spld, you must also include Microsoft Visual Studio (or at least its C compiler and linker). The easiest way is to run vcvars32.bat from the Visual Studio distribution.
Free, lightweight, easy-to-use, and easy-to-learn tools for the hobbyist, novice, and student developer.
You need to install Microsoft Visual C++ 2005 Express Edition and the Platform SDK. From http://msdn.microsoft.com/vstudio/express/visualc/download/:
1. Make sure you're ready! Before installing, you must uninstall any previous Beta, CTP or Tech Preview versions of SQL Server 2005, Visual Studio 2005, and the .NET Framework 2.0. 2. Download and install Download and install Visual C++ 2005 Express Edition!! ... 4. Install the Platform SDK You will now want to install the Microsoft Platform Software Development Kit (SDK).However, if you want to deploy your executable to any machine (other than the compile machine), crucially you will want to avoid installing:
Additional Downloads Microsoft Visual Studio Express Editions 2005 Service Pack 1
spld
, i.e. I'm assuming
you want to be able to run the executables on machines other than the
compile host, you will have to jump through some hoops. The reason for
this is to do with how DLLs (Dynamic Link Libraries) are baroquely
organized in Windows XP via manifests.
In particular, since we are compiling with Visual C++ 2005, we have to
also distribute the runtime system for Visual C++ 2005
(msvcr80.dll
).
One difficulty that immediately arises is that the appropriate runtime DLL for Visual C++ 2005 is not the same as Visual C++ 2005 Express Edition, which in turn is not the same as Visual C++ 2005 Express Edition with Service Pack 1 or some other "hotfix" version.
There are three ways to re-distribute Visual C++ DLLs for applications built with Visual C++:
Using Visual C++ Redistributable Merge Modules to install a particular Visual C++ library as shared side-by-side assemblies into the native assembly cache (WinSxS folder).First method requires the enduser to have administrator rights and for the develop to package things in an installer. Plus it's not available as an option for the free version of Visual C++. So that's out unless you want to buy Visual Studio.
Using Visual C++ Redistributable Package (VCRedist_x86.exe, VCRedist_x64.exe, VCRedist_ia64.exe) to install all Visual C++ libraries as shared side-by-side assemblies into the native assembly cache (WinSxS folder).In other words, second method asks the enduser to install the libraries from Microsoft, i.e. the enduser should download and run
vcredist_x86.exe
. This is the Microsoft recommended
route for Express Edition compiled applications. Sounds good but it
seems like (but I forget whether) it requires the user to have admin
privileges.
You have to have the exact right version though. But comically, this is unavailable for download for the latest version of Visual Express C++ Express (SP1), plus the executable isn't installed by the compiler so you couldn't have redistributed it anyway.
Relevant threads: How to deplay VC 2005 Express SP 1 solutions? / VC++ 2005 redistributable
[This last thread is a classic. Contains beautifully poignant dialogue like the following:
We have no plans of posting SP1 version of VCRedist for download. You should be using version of vcredist_*.exe installed by VS2005 SP1.
The reply is:
I like to kindly remind you that the SP1 does not install/upgrade a vcredist_*.exe for C++ Express Edition. My posting regarding this issue is not answered in the Express Forum.
Is it possible to get any more comical than that?]
Install a particular Visual C++ assembly as a private assembly for the application using files provide in the Program Files\Microsoft Visual Studio 8\VC\Redist directory.We discuss method 3 in the next section.
I've extracted the relevant parts below:
1) On the machine you have Express installed, create the following folder and subfolders in your \program files\microsoft visual studio 8\VC folder: redist\x86\Microsoft.VC80.CRT 2) Copy msvcr80.dll, msvcp80.dll, msvcm80.dll from \windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd into: \program files\microsoft visual studio 8\VC\redist\x86\Microsoft.VC80.CRT 3) in the above Microsoft.VC80.CRT folder, create a new file named: Microsoft.VC80.CRT.manifest 4) Paste the following content into the above manifest file:Now you have a new folder in your Visual C++ Express installation that can be re-used when ever you need it. To deploy these files, simply copy the Microsoft.VC80.CRT folder you just created to your program folder. That's it. So for example, if your application executable resides in C:\Program Files\MyApp, you'll have a folder named: C:\Program Files\MyApp\Microsoft.VC80.CRT that contains the 4 files I mentioned (3 DLLs and one manifest file you created by hand)
The problem is that method 3 above doesn't work when you are using Visual C++ 2005 Express Edition with SP1. I complained about it and the solution is to uninstall SP1.
Relevant thread: VC++ 2005 Express deployment problem
I also set my PATH to include the appropriate Sicstus Prolog bin directory.
Using the Visual Studio Command window, I just cd to my application directory and type:
spld --static --resources-from-sav treebankview.sav -o tbv.exeThis creates both
tbv.exe
and tbv.exe.manifest
.
Put them both in a new application directory, in my case:
treebankviewer
. And then add to that directory the
Microsoft.VC80.CRT
directory and contents as specified in
the previous section.
Simply zip encode the application directory for distribution and it's truly standalone and runnable without admin privileges.