compiling F# on linux with TPL - f#

I am pretty feeling pretty stumped with this issue... i am trying to compiling an F# prog that uses the TPL. I am using an up to data verson of mono which compiles C# and TPL.
The F# project is for a uni, which need to be run on there machines, so i have limited access i.e. no sudo rights. it is also commandline driven
These are errors generated:
Microsoft (R) F# 2.0 Compiler build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
/home/msc/sg315/fs/MapSkel.fs(12,23): error FS0039: The namespace 'Tasks' is not defined
/home/msc/sg315/fs/MapSkel.fs(23,5): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(31,3): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(44,5): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(52,12): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(55,12): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(61,12): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(68,12): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/MapSkel.fs(77,13): error FS0039: The namespace or module 'Parallel' is not defined
/home/msc/sg315/fs/BHList.fs(60,14): error FS0039: The field, constructor or member 'ReadLines' is not defined
-bash-4.1$
It obviously needs library references but have no idea which ones...
Thanks

As in your previous question Compiling issues with mono and multi-threaded application, the problem is that you are targeting a version of .NET which is too old.
You can download the new compiler source here http://github.com/fsharp/fsharp. Newer versions of the compiler automatically target a more moder .NET. This can be compiled and installed into a home directory (no root required).

Related

Fsharpc cannot generate fsi files

I am trying to generate the fsi file for a particular fs file.
Config.fs:
namespace Web2
open FSharp.Data
module Config =
type JsonConfig =
JsonProvider<Sample="./config.json">
let config =
JsonConfig.Load("./config.json")
Generating the signature file:
fsharpc --sig:Config.fsi Config.fs
Error:
Microsoft (R) F# Compiler version 10.2.3 for F# 4.5
Copyright (c) Microsoft Corporation. All Rights Reserved.
Config.fs(8,5): error FS0039: The type 'JsonProvider' is not defined.
Config.fs(8,5): error FS0039: The type 'JsonProvider' is not defined.
Config.fs(11,16): error FS0039: The field, constructor or member 'Load' is not defined.
Not sure what I am doing wrong.
The issue is that the code in Config.fs depends on JsonProvider which comes from the FSharp.Data.dll library - but when you invoke the compiler, you are not specifying the dependency.
You can do that by using the -r command line option:
fsharpc -r:whatever/folder/FSharp.Data.dll --sig:Config.fsi Config.fs
In general, if you are compiling a project, the references are specified in the project file and so you do not need to specify them elsewhere. But when you're invoking the compiler directly, you need to do that.

clang version 6.0.0 : clang++ "no member named 'make_optional' in namespace 'std' "

Till now I've been using gcc for compiling my C++ code in Ubuntu 16.04 server edition. But since the latest features of C++17 (mainly concurrency and parallelism) are not convered by the latest gcc, while in clang many of them are, I've been starting to use clang. What surprised me is that for one of previously gcc-debugged C++ files, while compiling with gcc : gcc version 7.3.0 (Ubuntu 7.3.0-21ubuntu1~16.04) the execution goes fine, if compiling clang : clang version 6.0.0 (tags/RELEASE_600/final), the compilation says error: no member named 'make_optional' in namespace 'std' :
`marco#PC:~/marcoTensor$ g++ -std=c++17 bigMatricesDiv01.cpp
-obigMatricesDiv01
marco#PC:~/marcoTensor$ ./bigMatricesDiv01
Timer MTensor::Tensor2D A = randU2<double>(20,400,2.7,4.6) : 154 ms
Timer MTensor::Tensor2D B = randN2<double>(20,400,3,2.6) :111 ms
Timer MTensor::Tensor2D ApB = A/B :0 ms
marco#PC:~/marcoTensor$ clang++ -std=c++17 -stdlib=libc++ -w -fcolor-
diagnostics bigMatricesDiv01.cpp -obigMatricesDiv01 -lc++experimental
In file included from bigMatricesDiv01.cpp:1:
In file included from ./tensorTypes.h:1:
In file included from ./MTensorUtils.h:1:
In file included from ./MTensor.h:5:
In file included from ./GeneralUtils.h:16:
./FunctionalApproach.h:953:27: error: no template named 'optional' in
namespace 'std'
auto transform(const std::optional<T1>& opt, F f) ->
decltype(std::make_optional(f(opt.value()))){
~~~~~^
./FunctionalApproach.h:953:68: error: no member named 'make_optional' in
namespace 'std'
auto transform(const std::optional<T1>& opt, F f) ->
decltype(std::make_optional(f(opt.value()))){
~~~~~^
./FunctionalApproach.h:955:17: error: no member named 'make_optional' in
namespace 'std'
return std::make_optional(f(opt.value()));
~~~~~^
3 errors generated.
`
But: In FunctionalApproach.h:
#include <experimental/propagate_const>
#include <experimental/optional>
Any idea why clang says " no member named 'make_optional' in namespace 'std' "?
<experimental/optional> puts things in the std::experimental namespace. So that's where make_optional lives. The use of -lc++experimental does not mean that the contents of std::experimental are dumped into the std namespace.

xbuild dafny on Linux CS0518 error

I followed the instructions in the documentation to install Dafny on Linux, but when I use xbuild dafny/Source/Dafny.sln I get the following trace:
reference:/usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll /warn:4
CSC: error CS0518: The predefined type `System.Object' is not defined or imported
CSC: error CS0518: The predefined type `System.ValueType' is not defined or imported
CSC: error CS0518: The predefined type `System.Attribute' is not defined or imported
CSC: error CS0518: The predefined type `System.Int32' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt32' is not defined or imported
I used the 64-bit version of Linux Mint 18.1. I get the same error in other Linux distributions as well (Fedora and Ubuntu).
The previous step (xbuild Source/Boogie.sln works fine)
Any help would be appreciated.
Thanks.
I added the following statement /p:TargetFrameworkVersion="v4.5" after xbuild dafny/Source/Dafny.sln and it was built successfully.

Can't build OpenCV 3.1 on Windows (using MinGW)

I need to build OpenCV from source, because I want to make modifications to it. So using pre-built binaries is not an option for me. I'm doing this on Windows 8. I do not have MS Visual Studio, and I don't want to use it.
Here is how I reproduce the build error:
I git clone https://github.com/opencv/opencv
I use CMake 3.7.1, press Configure, then press Generate. It seems to work (no errors). I named the output folder opencv/release.
I go to the opencv/release folder, and type mingw32-make.
Eventually, after compiling for a while, it displays the following error message:
Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj
modules\core\src\parallel.cpp:135:43: error: operator '&&' has no right operand
modules\core\src\parallel.cpp: In function 'void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)':
modules\core\src\parallel.cpp:311:52: error: 'parallel_for_pthreads' was not declared in this scope parallel_for_pthreads(range, body, nstripes);
^
modules\core\src\parallel.cpp: In function 'int cv::getNumThreads()':
modules\core\src\parallel.cpp:370:50: error: 'parallel_pthreads_get_threads_num' was not declared in this scope return parallel_pthreads_get_threads_num();
^
modules\core\src\parallel.cpp: In function 'void cv::setNumThreads(int)':
modules\core\src\parallel.cpp:431:46: error: 'parallel_pthreads_set_threads_num' was not declared in this scope parallel_pthreads_set_threads_num(threads);
^
modules\core\CMakeFiles\opencv_core.dir\build.make:990: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj' failed mingw32-make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj] Error 1
Note: I tried to compile both with and without TPP (in the CMake config), and I get the same error message.
Also, I read the other similar questions on StackOverflow and the answers do not help.

Precompile an ASP.NET application - i am getting Errors

When i build my project targeting .NET 4.0 in visual Studio 2010, i get the following Warning but with no any other error or warning, so the projects runs.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
AssemblyFoldersEx location: "{Registry:Software\Microsoft.NETFramework,v4.0,AssemblyFoldersEx}"
However, i cannot recompile the project with aspnet_compiler
***Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.18408
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
(0): warning : The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: myProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. The dependencies are: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. You should either ensure that the dependent assembly is correct for the target framework, or ensure that the target framework you are addressing is that of the dependent assembly.
d:\Projects\Release\SourceCode\web.config(55): warning CS0108: 'ProfileCommon.GetProfile(string)' hides inherited member 'myProjectName.Core.ProfileCommon.GetProfile(string)'. Use the new keyword if hiding was intended.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ec305f94\ca5ad86b\App_Web_i51pzwht.0.cs(28): error CS0234: The type or namespace name 'myModel' does not exist in the namespace 'MedicalService.ViewModel' (are you missing an assembly reference?)*
This post Resolving MSB3247 - Found conflicts between different versions of the same dependent assembly lead me to the utility below which helped me solve the issue.
http://mikehadlow.blogspot.co.uk/2011/02/asmspy-little-tool-to-help-fix-assembly.html

Resources