Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:03:45+00:00 2026-06-10T23:03:45+00:00

The (R) program I’m writing is at one point able to write C source

  • 0

The (R) program I’m writing is at one point able to write C source code files containing OpenMP instructions in order to speed up the resulting program (these files mainly contain a set of differential equations whose results are written to an array – as these steps can be executed independently, I thought it to be a good idea to parallelize them using omp sections). As the files generated this way are supposed to be used in another part of my program I also use R to compile them using system(R CMD SHLIB...) at runtime, as this approach seemed to have the advantage that, using R CMD SHLIB, no specific compiler would need to be imposed on the user.

The problem I’m now facing is that I can’t pass the -fopenmp (or -openmp) compiler directive to R CMD SHLIB and it is not possible to use a Makevars file providing additional compiler flags (or ideally $SHLIB_OPENMP_CFLAGS) when not building an R package – which I’m not doing in this case, so R CMD SHLIB compiles the file I give it. Without OpenMP paralellization, however, as I see no way how to pass the according flags to SHLIB in this situation.

Is there any possibility to use R CMD SHLIB for this task anyway or will I have to sacrifice portability by internally specifying a compiler for OpenMP compilation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:03:47+00:00Added an answer on June 10, 2026 at 11:03 pm

    If you must use R CMD SHLIB as opposed to a Makefile or package, I think you want to modify an environment variable such as PKG_CPPFLAGS or PKG_CXXFLAGS, which you can from inside R via Sys.setenv().

    R itself now uses OpenMP and the compiler option you desire is available on recent R systems:

    edd@max:~$ grep OPENMP /etc/R/Makeconf 
    SHLIB_OPENMP_CFLAGS = -fopenmp
    SHLIB_OPENMP_CXXFLAGS = -fopenmp
    SHLIB_OPENMP_FCFLAGS = -fopenmp
    SHLIB_OPENMP_FFLAGS = -fopenmp
    edd@max:~$ 
    

    That’s from a standard R 2.15.1 on a Debian / Ubuntu system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Program has more than one entry point defined: 'Class.Main()'. Compile with /main to specify
This program so far has one purpose, take in two integers(the size of the
Program : List all C files in the current folder using execlp() system call:
/*Program to merge to arrays using pointers in descending order, when the first array
My program uses a UISplitViewController as the root view controller. In order to get
My program processes PDF files and reads some streams out of them. There are
My Program overrides public void paint(Graphics g, int x, int y); in order to
Program Details: I am writing a program for python that will need to look
First program i'm writing while reading various Haskell tutorials gives me a Kind mis-match
Program that calculates and shows the value of (2 to the 10th power) This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.