-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcompiling_vcfR.Rmd
93 lines (67 loc) · 1.89 KB
/
compiling_vcfR.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: "Compiling vcfR"
output:
html_document:
toc: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(fig.align = 'center')
knitr::opts_chunk$set(fig.width = 12)
```
The package vcfR includes compiled code to increase it's performance.
For Windows and OSX precompiled binaries are available at CRAN and should always be your first choice.
If you do want to compile vcfR yourself you need to make sure you have cupport for C++11.
C++11 is an extension of C++, similar to how R packages extend the functionality of R.
If you're having problems compiling it may be good to validate your system has this functionality.
We can test for this functionality by creating a small C++ function (this is entirely independent of R).
Copy the below code into a text file named `myTest.cpp`.
```{r, eval=FALSE}
#include <iostream>
// Originally based on:
// http://stackoverflow.com/a/34681870
int main()
{
// Query OS info
if (system( NULL )){
system("cat /etc/*release");
} else {
std::cout << "Couldn't queru OS" << std::endl;
}
std::cout << std::endl;
// Introduction.
std::cout << "Querying for g++: ";
std::cout << __cplusplus;
std::cout << std::endl;
// Determine support.
if(__cplusplus==201402L){
std::cout << "C++14" << std::endl;
} else if(__cplusplus==201103L){
std::cout << "C++11" << std::endl;
} else if(__cplusplus == 199711L){
std::cout << "C++" << std::endl;
} else {
std::cout << "Unexpected result." << std::endl;
}
return 0;
}
```
First, let's compile our program without C++11 support.
```{r, eval=FALSE}
g++ myTest.cpp
```
And execute.
```{r, eval=FALSE}
./a.out
C++
```
Now we can compile with C++11 support.
```{r, eval=FALSE}
g++ -std=c++11 myTest.cpp
```
```{r, eval=FALSE}
./a.out
C++11
```
Your results should be the same as above.
If not, you may not have C++ support on your system.