Learn R Programming

maketools (version 1.3.1)

make: Make

Description

Compile C / C++ / Fortran source files using the compiler configured by your R Makeconf file.

Usage

make(target = "all", makefile = r_makeconf_path())

make_call(cmd = "$(CC)", args = "--version")

make_echo(cmd = "$(CC)")

make_info()

Arguments

target

name of output file that you want to make

makefile

path to the Makefile. Defaults to the Makeconf which R uses when building R packages.

cmd

command to invoke (may be a variable)

args

additional arguments for cmd

Details

The make function literally calls make yourfile.o -f /path/to/R/Makeconf. This is exactly what R does when building packages and hence the best way to test if the compiler is working.

See Also

Other maketools: diagnostics, pkgconfig, r_config, sysdeps

Examples

Run this code
# Test the CXX compiler
if(cxx_info()$available){
testprog <- '#include \nint main() {std::cout << "Hello World!";}'
writeLines(testprog, con = 'testprog.cc')
make('testprog')

# Test and cleanup
system('./testprog')
unlink('testprog*', recursive = TRUE)
}

# Run a program from a make variable
make_call('$(CXX)', '--version')

# Where your makeconf is stored:
make_info()

Run the code above in your browser using DataLab