How to build the F# compiler from source - f#

After the recent announcement that the F# compiler source was available under the apache license I decided I'd like to have a go at building the compiler from source. However, I fell at the first post as there seems to be a missing file “Microsoft.FSharp-proto.Targets”. Is this the same “Microsoft.FSharp-proto.Targets” that is available in “Microsoft F#, August 2010 Community Technology Preview”? What other steps are necessary to build the compiler. Will the F# team be providing a script that “just works” to build the compiler?

I haven't run these yet (PC configuration problems?), but there's a detailed set of instructions in the source distribution at compiler/2.0/Nov2010/README.html.
These instructions are a little different to the ones #desco wrote that relate to the previous CTP.

Not so long ago before this announcement I've written about building compiler from sources supplied with F# CTP (F#: Building compiler from sources.). Hope nothing was changed since that time.

I just downloaded and successfully compiled F# so I thought I'd add an update.
I downloaded from http://fsharppowerpack.codeplex.com/SourceControl/list/changesets
I extracted the files and navigated to fsharppowerpack-66272\compiler\2.0\Aug2011
It contains a readme.html that suggests a number of ways to build.
With that readme I made the following script which successfully compiled F# for me.
Install NUnit first if you want to compile the unit tests.
set MSB40=C:\Windows\Microsoft.NET\Framework\v4.0.30319\
set Path=%Path%;%MSB40%
cd src
msbuild fsharp-proto-build.proj /p:TargetFramework=cli\4.0
ngen install ..\Proto\cli\4.0\bin\fsc-proto.exe
msbuild fsharp-library-build.proj /p:TargetFramework=cli\4.0
msbuild fsharp-compiler-build.proj /p:TargetFramework=cli\4.0
msbuild fsharp-library-unittests-build.proj /p:TargetFramework=cli\4.0
msbuild fsharp-compiler-unittests-build.proj /p:TargetFramework=cli\4.0
ngen install ..\Debug\cli\4.0\bin\fsi.exe
pause
Note: I already had VS2010 and the FSharpPowerPack installed.

Related

Z3-OPT binary files for the windows 64 bit machine

I am trying to get Z3-OPT (optimization) binary files for the windows 64-bit machine. To make these files, I already tried to compile the code from the unstable branch. However, I could not compile them as my Visual Studio Community edition does not contain "nmake" command. I tried to follow instructions on the following page:
https://github.com/Z3Prover/z3
Can anyone share with me the latest Z3-OPT binary files?
Z3-opt is now the same as Z3, so you can just use the main links for downloading Z3.
The releases are in: https://github.com/Z3Prover/bin/tree/master/releases
There is also a folder with nightly builds.
You have to enable C++ features in VS before you get the command line build tools. This involves updating the installation of VS itself, something you can do from "Apps and Features" (in Windows 10) or similar place in previous versions of Windows. There is already some online discussions about this question. For example, https://developercommunity.visualstudio.com/content/problem/39632/adding-nmake-to-vs2017.html.

Is it possible to use TensorFlow C++ API on Windows?

I'm interested in incorporating TensorFlow into a C++ server application built in Visual Studio on Windows 10 and I need to know if that's possible.
Google recently announced Windows support for TensorFlow: https://developers.googleblog.com/2016/11/tensorflow-0-12-adds-support-for-windows.html
but from what I can tell this is just a pip install for the more commonly used Python package, and to use the C++ API you need to build the repo from source yourself: How to build and use Google TensorFlow C++ api
I tried building the project myself using bazel, but ran into issues trying to configure the build.
Is there a way to get TensorFlow C++ to work in native Windows (not using Docker or the new Windows 10 Linux subsystem, as I've seen others post about)?
Thanks,
Ian
It is certainly possible to use TensorFlow's C++ API on Windows, but it is not currently very easy. Right now, the easiest way to build against the C++ API on Windows would be to build with CMake, and adapt the CMake rules for the tf_tutorials_example_trainer project (see the source code here). Building with CMake will give you a Visual Studio project in which you can implement your C++ TensorFlow program.
Note that the tf_tutorials_example_trainer project builds a Console Application that statically links all of the TensorFlow runtime into your program. At present we have not written the necessary rules to create a reusable TensorFlow DLL, although this would be technially possible: for example, the Python extension is a DLL that includes the runtime, but does not export the necessary symbols to use TensorFlow's C or C++ APIs directly.
There is a detailed guide by Joe Antognini and a similar TensorFlow ReadMe at GitHub explaining the building of TensorFlow source via CMake. You also need to have SWIG installed on your machine which allows connecting C/C++ source with the Python scripting language. I did use Visual CMAKE (cmake-gui) with the screen capture shown below.
In the CMake configuration, I used Visual Studio 15 2017 compiler. Once this stage successfully completes, you can click on the Generate button to go ahead with the actual build process.
However, on Visual Studio 2015, when I attempted building via the "ALL_BUILD" project, the setup gave me "build tools for v141 cannot be found" error. This did not go away even when I attempted to retarget my solution. Finally, the solution got built successfully with Visual Studio 2017. You also need to manually set the SWIG_EXECUTABLE path in CMake before it successfully configures.
As indicated in the Antognini link, for me the build took about half an hour on a 16GB RAM, Core i7 machine. Once done, you might want to validate your build by attempting to run the tf_tutorials_example_trainer.exe file.
Hope this helps!
For our latest work on building TensorFlow C++ API on Windows, please look at this github page. This works on Windows 10, currently without CUDA support (only CPU).
PS:
Only the bazel build method works, because CMake is not supported and not maintained anymore, resulting in CMake configuration errors.
I had to use a downgraded version of my Visual Studio 2017 (from 15.7.5 to 15.4) by adding "VC++ 2017 version 15.4 v14.11 toolset" through the installer (Individual Components tab).
The cmake command which worked for me was:
cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^
-T "v141,version=14.11" ^
-DSWIG_EXECUTABLE="C:/Program Files/swigwin-3.0.12/swig.exe" ^
-DPYTHON_EXECUTABLE="C:/Program Files/Python/python.exe" ^
-DPYTHON_LIBRARIES="C:/Program Files/Python/libs/python27.lib" ^
-Dtensorflow_ENABLE_GPU=ON ^
-DCUDNN_HOME="C:/Program Files/cudnn-9.2-windows10-x64-v7.1/cuda" ^
-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0"
After the build, open tensorflow.sln in Visual Studio and build ALL_BUILD.
If you want to enable GPU computation, do check your Graphics Card here (Compute Capability > 3.5). Do remember to install all the packages (Cuda Toolkit 9.0, cuDNN, Python 3.7, SWIG, Git, CMake...) and add the paths to the environment variable in the beginning.
I made a README detailing how to I built the Tensorflow dll and .lib file for the C++ API on Windows with GPU support building from source with Bazel. Tensorflow version 1.14
The tutorial is step by step and starts at the very beginning, so you may have to scroll down past steps you have already done, like checking your hardware, installing Bazel etc.
Here is the url: https://github.com/sitting-duck/stuff/tree/master/ai/tensorflow/build_tensorflow_1.14_source_for_Windows
Probably you will want to scroll all the way down to this part:
https://github.com/sitting-duck/stuff/tree/master/ai/tensorflow/build_tensorflow_1.14_source_for_Windows#step-7-build-the-dll
It shows how to pass command to create .lib and .dll.
Then to test your .lib you should link it into your c++ project,
Then it will show you how to identify and fix the missing symbols using the TF_EXPORT macro
I am actively working on making this tutorial better so feel free to leave comments on this answer if you are having problems.

Deploying F# exe

I have an F# program I built in VS2013. I am intending to deploy this on a windows 2008 R2 server with .NET framework 4.5 installed. Now, when I build the program in visual studio, it creates an exe in the debug/bin directory (MyProgram.exe). Do I need to include a copy of fharp.core.dll with the exe? Or, will the build process automatically compile the necessary dependancy DLLs (fsharp.core, fsharp.data, fsharp.data.TypeProviders)? Most of the research I can search online for seems to look at VS2010 and I am not using fsc,exe currently.
Thanks for any insight provided.
You can use the compiler option --standalone to statically links the FSharp.Core.dll (F# runtime) and any reference assemblies that depend on it (i.e. any other F# assemblies).
You may or may not need to copy FSharp.Core.dll together with the .exe.
If F# is already installed on the server, you may not need it, but it has to be the correct version of F#.
Otherwise, the F# license allows you to deploy FSharp.Core.dll together with your own binaries.
There's also the 'official' FSharp.Core NuGet package, if that's more to your liking.

Building DEB package for fsharp compiler

I would like to install the fsharp compiler from Github on my Debian system, and the usual way would be to create a deb package first and then install it (so it is possible to uninstall it later, etc.). What is the easiest way to achieve this? All the examples of how to use dh_make assume you have a source tar.gz appropriately named, whereas I don't. Also I need to use some prefix for the autogen script:
./autogen.sh --prefix=/usr
I am not sure it this makes the task any more difficult.
This should actually be fairly simple to achieve with a binary package - which will also be cross-platform because the F# compiler itself is written in F#. The compiler itself is fairly standalone and depends only on a few BCL libraries. There are versions that run on Mono.
More important than installing the compiler is the integration with your platform's build system(s). Microsoft ships a Microsoft.FSharp.targets file for MSBuild, I don't know whether that will work with Mono's xBuild.
I have put together a blog post that explains where to find the various bits that make up the F# compiler and how to package them to compile on a platform that has only .NET and MSBuild (AppHarbor in my case), which you may find helpful.

Creating OpenCV installer with NSIS

I am compiling OpenCV for our project with specific build options (such as 64bit, QT and OpenNI). I was able to follow the instruction as given here: http://opencv.itseez.com/doc/tutorials/introduction/windows_install/windows_install.html
At the end of 2-3 hours of build process, I ended up with \install\build\ with collected bins, dlls and libs in their respective folder. I would like to distribute an .exe installer to other members in research group. But I could not because _CPack_Packages/win32/NSIS is nowhere to be found.
Note: To create an installer you need to install NSIS. Then just build the
Package project to build the installer into the
Build/_CPack_Packages/win32/NSIS folder. You can then use this to
distribute OpenCV with your build settings on other systems.
In the cmake-gui screen, I ticked "Build Package" which I hoped would enable me to see Build/_CPack_Packages/win32/NSIS folder. After build process, this is not found.
Could someone give a suggestion as why I don't see this _CPack_Packages/win32/NSIS folder as described? Could I use
Inno setup instead? If so, do I simply pack all \build\install folder and set path in system to include \build\install\bin?
Thank you.
Sticking with the KISS principle (Keep it simple, Stupid!):
Did you install NSIS prior to building the Package project?
INSTRUCTIONS TO BUILD WIN32 PACKAGES WITH CMAKE+CPACK
------------------------------------------------------
- Install NSIS.
- Generate OpenCV solutions for MSVC using CMake as usual.
- In cmake-gui:
- Mark BUILD_PACKAGE
- Mark BUILD_EXAMPLES (If examples are desired to be shipped as binaries...)
- Unmark ENABLE_OPENMP, since this feature seems to have some issues yet...
- Mark INSTALL_*_EXAMPLES
- Open the OpenCV solution and build ALL in Debug and Release.
- Build PACKAGE, from the Release configuration. An NSIS installer package will be
created with both release and debug LIBs and DLLs.
Jose Luis Blanco, 2009/JUL/29
I suggest instead of using Visual Studio to build, you should try using CMake.
http://www.cmake.org/
Let me know if this helps at all.

Resources