c_program added support-files are not recognized

c_program added support-files are not recognized

de către Christian Gasde-
Număr de răspunsuri: 2

Hi,

my question is about a  new c_program and additional support-files which are not recognized correctly somehow.

New c_program:Creating a new c_program

Adding support files:Adding support files

ERROR while trying to access a function which is included  within  the support file:

“ … undefined reference to ‘GetInt’  … “

ERROR

When I copy the code from the “ip_input.c” file directly into the c_program  file then it works fine!:

When I copy the code from the “ip_input.c” file directly into the c_program  file then it works fine!

So what’s the problem?

Thank you very much for any kind of help!

Best Regards from Coburg

Chris

(We are using the latest moodle- and coderunnerversions.)





Ca răspuns la Christian Gasde

Re: c_program added support-files are not recognized

de către Richard Lobb-
All the base question types in CodeRunner simply run the code that the template constructs from the template plus the answerbox. Support Files are loaded into the working directory on Jobe when the job runs, but they are most commonly data files and, at least by default, don't have any role in building the program to be run.

Here are some solutions to your problem:
  1. A quick and dirty hack: #include the source file rather than the .h file (which you no longer need). Ugly but workable.
  2. Customise the question by clicking the Customise checkbox, open Advanced Customisaton and in the Sandbox Parameters field, set a compileargs value to pass the extra code file(s) into the C compiler. For example: 
    {"compileargs": ["-std=c99", "-w", "ip_input.c"]}
    The gcc command will then be something like
      gcc studentanswer.c -std=c99 -w ip_input.c -o executablefile
  3. Switch to using a question type scripted in Python for running your C programs, following the pattern explained in Supporting or implementing new languages in the documentation. This gives you total control over the whole compile/build/execute process and allows you to insert extra steps, such as running lint or other style checkers.
If you're feeling very brave, you could try using our University of Canterbury question type for C programming which includes lots of extra features such as constraints on style, restrictions on what constructs can be used, checks on layout, etc. You can import the question and read the Question type details section to see them all. This comes with no guarantees or support and needs the astyle program to be installed on the Jobe server (and perhaps others). It's a very complex question type, so you probably should avoid it until you have considerable experience with CodeRunner. But ... it does offer you lots of functionality.
Ca răspuns la Richard Lobb

Re: c_program added support-files are not recognized

de către Christian Gasde-

Hi Richard,

thank you very much for your tips!!

In my case the error was produced because of:

Testcase 1: main();

After I removed the explizit function call: main(); within the Testcase 1 window everything works perfect.

Best Regards from Coburg
Chris