Skip to content

Commit 7591446

Browse files
committed
Migrate to use VS2019 level toolchain - update readme.
1 parent 24b1eb0 commit 7591446

File tree

4 files changed

+117
-39
lines changed

4 files changed

+117
-39
lines changed

R/zzz.R

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ startupMsg <- ''
2222
monoexepath <- Sys.which('mono')
2323
ext <- .Platform$dynlib.ext
2424
nativeLibsNames <- paste(c('rClrMono', 'rClrMs'), ext, sep='')
25-
msDll <- nativeLibsNames[2]
2625
monoDll <- nativeLibsNames[1]
26+
msDll <- nativeLibsNames[2]
2727
getFnameNoExt <- function(x) {strsplit(x, '\\.')[[1]][1]}
2828
rClrPkgDir <- file.path(libname, pkgname)
2929
archLibPath <- file.path(rClrPkgDir, 'libs', Sys.getenv('R_ARCH'))
@@ -43,20 +43,25 @@ startupMsg <- ''
4343
}
4444
dlls <- list.files(archLibPath, pattern=ext)
4545
if ( Sys.info()[['sysname']] == 'Windows') {
46-
if ( msDll %in% dlls && rclr_env!='Mono') {
47-
if( Sys.which('msvcr120.dll') == '') {
48-
stop(paste("'msvcr120.dll' was not found on this Windows system.",
49-
"You are probably missing the Visual C++ Redistributable for Visual Studio 2013.",
50-
"Check instructions at https://r2clr.codeplex.com/wikipage?title=Installing%20R%20packages&referringTitle=Documentation",
46+
if ( rclr_env!='Mono') {
47+
msvcrFileName <- 'msvcp140.dll'
48+
if( Sys.which(msvcrFileName) == '') {
49+
stop(paste(msvcrFileName, "was not found on this Windows system.",
50+
"You are probably missing the Visual C++ Redistributable for Visual Studio 2019.",
51+
"Go to https://visualstudio.microsoft.com/downloads/ and dowload 'Microsoft Visual C++ Redistributable for Visual Studio 2019'",
5152
sep="\n"))
5253
}
54+
if(!(msDll %in% dlls)) {
55+
stop(paste('rClr library .NET framework not found - looked under', archLibPath, 'but not found in', paste(dlls, collapse=',')))
56+
}
5357
appendStartupMsg('Loading the dynamic library for Microsoft .NET runtime...')
5458
chname <- getFnameNoExt(msDll)
5559
loadAndInit(chname, pkgname, libname, srcPkgLibPath)
56-
} else { # on Windows, but we are requesting to load Mono.
60+
} else if ( rclr_env=='Mono') {
61+
# on Windows, but we are requesting to load Mono.
5762
appendStartupMsg('Loading the dynamic library for Mono runtime...')
5863
if(!(monoDll %in% dlls)) {
59-
stop(paste('rClr library for Mono not found - looked under', archLibPath))
64+
stop(paste('rClr library for Mono not found - looked under', archLibPath, 'but not found in', paste(dlls, collapse=',')))
6065
} else if (monoexepath=='') {
6166
stop("mono.exe was not found by 'Sys.which'. You must add the mono bin directory (e.g. c:\\Program Files\\Mono-3.0.6\\bin) to your PATH environment variable")
6267
} else {

README.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,64 @@
22

33
## R package for accessing .NET
44

5-
The latest is on the [testing branch](https://github.com/jmp75/rClr/tree/testing). As of March 2019 testing support for R 3.5.
6-
75
Accessing the Common Language Runtime (.NET or Mono) from the R statistical software, in-process.
86

97
## Installing
108

11-
As of September 2015, the source code snapshot of tagged releases can be found via the [release tab of the rClr GitHub repository](https://github.com/jmp75/rClr/releases). Binary R packages for Windows cannot be released via github, and you can get them from [https://rclr.codeplex.com](https://rclr.codeplex.com).
9+
As of 2019-04, releases can be found via the [release tab of the rClr GitHub repository](https://github.com/jmp75/rClr/releases).
1210

1311
### Pre-compiled binaries
1412

1513
You can install pre-compiled rClr for Windows via [https://rclr.codeplex.com](https://rclr.codeplex.com). You can use from the command line `R CMD INSTALL rclr_0.8.zip` where `R` points to one of the R.exe installed on your machine, or from R itself `install.packages('c:/path/to/rclr_0.8.zip')`
1614

1715
### From source
1816

17+
If you want to compile from source note that you may be interested in using the [testing branch](https://github.com/jmp75/rClr/tree/testing).
18+
19+
rClr is not your average R package and requires a few more tools than is typical for most R packages.
20+
1921
#### Windows
2022

23+
On Windows you will need a C# and C and/or Visual C++ compiler. Using the Visual Studio 2019 toolchain is recommended as of April 2019. Check the [visual studio download page](https://visualstudio.microsoft.com/downloads/) for options.
24+
2125
Under construction as of 2019-04:
2226

2327
```bat
24-
REM important to not have nuget.exe under c:\bin
28+
REM IMPORTANT to not have nuget.exe or other commands under c:\bin; RTools mingw cannot find these commands
2529
set PATH=C:\cmd_bin;%PATH%
26-
REM and make sure we use a recent msbuild, otherwise issues with netstandard2 formats.
27-
set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\;%PATH%
2830
cd c:\src\github_jm
31+
```
32+
33+
Make sure we use a recent msbuild, otherwise there may be issues with targetting .NET netstandard2.0. `.\rClr\src\setup_vcpp.cmd` may help detect the most recent `msbuild.exe` you have if you have installed visual studio (unsure it works for Build Tools for Visual Studio). You can start a development prompt as a fallback if setup_vcpp fails to work on your machine.
34+
35+
```bat
36+
REM https://github.com/jmp75/rClr/issues/42 may need to use VS2019
37+
.\rClr\src\setup_vcpp.cmd
38+
```
39+
40+
```bat
2941
set R_EXE="c:\Program Files\R\R-3.5.2\bin\x64\R.exe"
3042
set R_VANILLA=%R_EXE% --no-save --no-restore-data
3143
%R_VANILLA% CMD build rClr
32-
%R_VANILLA% CMD INSTALL --build rClr_0.8.x.tar.gz
33-
```
44+
%R_VANILLA% CMD INSTALL --build rClr_0.8.2.tar.gz
3445
35-
#### Windows
46+
set R_EXE="c:\Program Files\R\R-3.4.4\bin\x64\R.exe"
47+
set R_VANILLA=%R_EXE% --no-save --no-restore-data
48+
REM %R_VANILLA% CMD build rClr
49+
%R_VANILLA% CMD INSTALL --build rClr_0.8.2.tar.gz
50+
```
3651

37-
Installing on Linux is always installing from source anyway, be it from a tarball, cloning the repo, or using `devtools`.
52+
Note that as of September 2015 using Mono on Windows is not maintained.
3853

39-
rClr is not your average R package and requires a few more tools than is typical for most R packages.
54+
#### Linux
4055

41-
On Windows you will need a C# and C and/or Visual C++ compiler. Using the Visual Studio 2013 toolchain is recommended. Read [the current build instructions](https://r2clr.codeplex.com/wikipage?title=Build%20instructions&referringTitle=Documentation). Note that as of September 2015 using Mono on Windows is not maintained.
56+
Installing on Linux is always installing from source anyway, be it from a tarball, cloning the repo, or using `devtools`.
4257

4358
A Linux distribution with R, g++ and the Mono toolchain (including xbuild) should work. Note that while a range of Mono versions in the 3.X series may work, I recommend you use versions 3.8 or above. This may require you to look for adequate versions (for instance Debian is lagging behind currently). You may want to have a look at the instructions at the [mono download page for Linux](http://www.mono-project.com/download/#download-lin) and use the Xamarin packages.
4459

45-
You should be able to install the package using the `install_github` function of the package `devtools`. The following commands have been tested successfully on Windows with VS2013 and Linux with Mono 3.10, on 2014-12-19.
60+
#### Using devtools
61+
62+
You should be able to install the package using the `install_github` function of the package `devtools`. The following commands have been tested successfully on Windows with VS2013 and Linux with Mono 3.10, on 2014-12-19.
4663

4764
```R
4865
## Optionally you may remove a prior package
@@ -64,7 +81,7 @@ library(rClr)
6481
browseVignettes('rClr')
6582
```
6683

67-
You will otherwise find some documentation at [https://r2clr.codeplex.com/documentation](https://r2clr.codeplex.com/documentation)
84+
OBSOLETE: You will otherwise find some documentation at [https://r2clr.codeplex.com/documentation](https://r2clr.codeplex.com/documentation)
6885

6986
## Feedback and contributions
7087

src/rClr.vcxproj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
55
<Configuration>Debug</Configuration>
@@ -49,70 +49,71 @@
4949
<PropertyGroup Label="Globals">
5050
<ProjectGuid>{1EE5689F-F71E-49E1-874A-0DF63E174635}</ProjectGuid>
5151
<RootNamespace>rClr</RootNamespace>
52+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
5253
<!--VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and $(VisualStudioVersion) == ''">$(VCTargetsPath11)</VCTargetsPath-->
5354
</PropertyGroup>
5455
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
5556
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
5657
<ConfigurationType>DynamicLibrary</ConfigurationType>
5758
<UseDebugLibraries>true</UseDebugLibraries>
5859
<CharacterSet>Unicode</CharacterSet>
59-
<PlatformToolset>v120</PlatformToolset>
60+
<PlatformToolset>v142</PlatformToolset>
6061
</PropertyGroup>
6162
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MonoDebug|Win32'" Label="Configuration">
6263
<ConfigurationType>DynamicLibrary</ConfigurationType>
6364
<UseDebugLibraries>true</UseDebugLibraries>
6465
<CharacterSet>Unicode</CharacterSet>
65-
<PlatformToolset>v120</PlatformToolset>
66+
<PlatformToolset>v142</PlatformToolset>
6667
</PropertyGroup>
6768
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MonoInstallDebug|Win32'" Label="Configuration">
6869
<ConfigurationType>DynamicLibrary</ConfigurationType>
6970
<UseDebugLibraries>true</UseDebugLibraries>
7071
<CharacterSet>Unicode</CharacterSet>
71-
<PlatformToolset>v120</PlatformToolset>
72+
<PlatformToolset>v142</PlatformToolset>
7273
</PropertyGroup>
7374
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MonoInstall|Win32'" Label="Configuration">
7475
<ConfigurationType>DynamicLibrary</ConfigurationType>
7576
<UseDebugLibraries>true</UseDebugLibraries>
7677
<CharacterSet>Unicode</CharacterSet>
77-
<PlatformToolset>v120</PlatformToolset>
78+
<PlatformToolset>v142</PlatformToolset>
7879
</PropertyGroup>
7980
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
8081
<ConfigurationType>DynamicLibrary</ConfigurationType>
8182
<UseDebugLibraries>true</UseDebugLibraries>
8283
<CharacterSet>Unicode</CharacterSet>
83-
<PlatformToolset>v120</PlatformToolset>
84+
<PlatformToolset>v142</PlatformToolset>
8485
</PropertyGroup>
8586
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MonoDebug|x64'" Label="Configuration">
8687
<ConfigurationType>DynamicLibrary</ConfigurationType>
8788
<UseDebugLibraries>true</UseDebugLibraries>
8889
<CharacterSet>Unicode</CharacterSet>
89-
<PlatformToolset>v120</PlatformToolset>
90+
<PlatformToolset>v142</PlatformToolset>
9091
</PropertyGroup>
9192
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MonoInstallDebug|x64'" Label="Configuration">
9293
<ConfigurationType>DynamicLibrary</ConfigurationType>
9394
<UseDebugLibraries>true</UseDebugLibraries>
9495
<CharacterSet>Unicode</CharacterSet>
95-
<PlatformToolset>v120</PlatformToolset>
96+
<PlatformToolset>v142</PlatformToolset>
9697
</PropertyGroup>
9798
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MonoInstall|x64'" Label="Configuration">
9899
<ConfigurationType>DynamicLibrary</ConfigurationType>
99100
<UseDebugLibraries>true</UseDebugLibraries>
100101
<CharacterSet>Unicode</CharacterSet>
101-
<PlatformToolset>v120</PlatformToolset>
102+
<PlatformToolset>v142</PlatformToolset>
102103
</PropertyGroup>
103104
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
104105
<ConfigurationType>DynamicLibrary</ConfigurationType>
105106
<UseDebugLibraries>false</UseDebugLibraries>
106107
<WholeProgramOptimization>true</WholeProgramOptimization>
107108
<CharacterSet>Unicode</CharacterSet>
108-
<PlatformToolset>v120</PlatformToolset>
109+
<PlatformToolset>v142</PlatformToolset>
109110
</PropertyGroup>
110111
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
111112
<ConfigurationType>DynamicLibrary</ConfigurationType>
112113
<UseDebugLibraries>false</UseDebugLibraries>
113114
<WholeProgramOptimization>true</WholeProgramOptimization>
114115
<CharacterSet>Unicode</CharacterSet>
115-
<PlatformToolset>v120</PlatformToolset>
116+
<PlatformToolset>v142</PlatformToolset>
116117
</PropertyGroup>
117118
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
118119
<ImportGroup Label="ExtensionSettings">

src/setup_vcpp.cmd

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,76 @@
1+
@echo off
2+
3+
REM -------------------------------------
4+
REM NOTE: This file is a copy of
5+
REM https://github.com/jmp75/config-utils/blob/master/R/packages/msvs/exec/setup_vcpp.cmd
6+
REM -------------------------------------
7+
8+
@set exit_code=0
9+
10+
11+
REM load Visual Studio 2017 developer command prompt setup has changed compared to previous versions.
12+
REM Inspired from: https://github.com/ctaggart via https://github.com/Microsoft/visualfsharp/pull/2690/commits/bf52776167fe6a9f2354ea96094a025191dbd3e7
13+
14+
set VsDevCmdFile=\Common7\Tools\VsDevCmd.bat
15+
16+
set progf=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\
17+
if exist "%progf%" (
18+
goto foundVsDevCmdFile
19+
)
20+
21+
set progf=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\
22+
23+
:foundVsDevCmdFile
24+
25+
if exist "%progf%Enterprise%VsDevCmdFile%" (
26+
call "%progf%Enterprise%VsDevCmdFile%"
27+
goto end
28+
)
29+
if exist "%progf%Professional%VsDevCmdFile%" (
30+
call "%progf%Professional%VsDevCmdFile%"
31+
goto end
32+
)
33+
if exist "%progf%Community%VsDevCmdFile%" (
34+
call "%progf%Community%VsDevCmdFile%"
35+
goto end
36+
)
37+
if exist "%progf%BuildTools%VsDevCmdFile%" (
38+
call "%progf%BuildTools%VsDevCmdFile%"
39+
goto end
40+
)
141

2-
set VSCOMNTOOLS=%VS120COMNTOOLS%
3-
@if "%VSCOMNTOOLS%"=="" VSCOMNTOOLS=%VS110COMNTOOLS%
4-
@if "%VSCOMNTOOLS%"=="" goto error_no_VS110COMNTOOLSDIR
542
REM for instance C:\bin\VS2012\Common7\Tools\
43+
if defined VSCOMNTOOLS (
44+
goto found
45+
)
46+
47+
if defined VS140COMNTOOLS set VSCOMNTOOLS=%VS140COMNTOOLS%
48+
if defined VS140COMNTOOLS goto found
49+
if defined VS120COMNTOOLS set VSCOMNTOOLS=%VS140COMNTOOLS%
50+
if defined VS120COMNTOOLS goto found
51+
if defined VS110COMNTOOLS set VSCOMNTOOLS=%VS140COMNTOOLS%
52+
if defined VS110COMNTOOLS goto found
53+
54+
@echo ERROR: Could not locate command prompt devenv setup for anything between VS2012 and VS2017
55+
@set exit_code=127
56+
@goto end
657

7-
set VSDEVENV="%VSCOMNTOOLS%..\..\VC\vcvarsall.bat"
8-
@if not exist %VSDEVENV% goto error_no_vcvarsall
9-
@call %VSDEVENV%
58+
:found
59+
set VSDEVENV=%VSCOMNTOOLS%..\..\VC\vcvarsall.bat
60+
@if not exist "%VSDEVENV%" goto error_no_vcvarsall
61+
@call "%VSDEVENV%"
1062
@goto end
1163

1264
:error_no_VS110COMNTOOLSDIR
1365
@echo ERROR: setup_vcpp cannot determine the location of the VS Common Tools folder.
66+
@set exit_code=1
1467
@goto end
1568

1669
:error_no_vcvarsall
1770
@echo ERROR: Cannot find file %VSDEVENV%.
71+
@set exit_code=1
1872
@goto end
1973

2074
:end
75+
exit /b %exit_code%
2176

0 commit comments

Comments
 (0)