Question Authors' Forum

Using libraries like math etc. for C / C++

 
Picture of Richard Lobb
Re: Using libraries like math etc. for C / C++
by Richard Lobb - Sunday, 6 August 2017, 10:44 AM
 

The most direct way to set link arguments is via the CodeRunner question authoring form. If you click the 'customise' checkbox, then expand 'Advanced Customisation', you'll find there's a Sandbox Parameters field available.

Screenshot showing parameter field

One of the parameters for Jobe is a linkargs parameters, so for example if you set the Parameters field to

{"linkargs":["-lm"]}

you'd include the math library. That and other Jobe sandbox parameters are documented in the section Run-spec Parameters at https://github.com/trampgeek/jobe/blob/master/README.md.

You could make different C/C++ question types that used different libraries by setting different values for this parameter in new question prototypes.

However, increasingly authors prefer to deal with more difficult question types using Python scripting. I've just documented a simple example of a Python script for running C/C++ programs in a section called Supporting or Implementing New Languages in the CodeRunner Readme.md file. This approach gives you much more flexibility, such as the ability to supply compile or link arguments through the question's template parameters field.

Richard