3

I am trying to add a new system call at: /usr/src/servers/pm/exec.c

I write a very simple method in exec.c:

void parseBlack(char * value){
    char * ptr = strtok(values, ";");

    }

However, when I try to compile it there is an error:

In function parseBlac, undefined reference to "strtok".

And I have added #include <string.h>

It is weird. I checked minix api. It has this method:

/minix/include/string.h(http://code.metager.de/source/xref/minix/include/string.h)

Here is a screen shot:

enter image description here

fhlkm
  • 333
  • 1
  • 6
  • 14
  • It's a linker error. Do you need to explicitly link with `libc` (or whatever)? Or just forgo the use of `strtok`. – ooga Nov 15 '14 at 15:27
  • strtok is in"/minix/include/string.h", I am not famailiar with "explicity link", can you give me more information about it? How should I "link explicit libc" here? Thanks – fhlkm Nov 16 '14 at 14:45
  • Please don't post screenshots of error messages; copy-and-paste the text so we can read it more easily. You should use `#include `, not `#include "string.h"`, but that's not likely to be the cause of the problem. There's a big difference between the ordinary user space environment and the kernel environment; some of the standard library isn't going to be available in the kernel (since the standard library is implemented partially *on top of* the kernel). I'm not familiar with Minux, so I don't know the details. – Keith Thompson Nov 16 '14 at 15:04

1 Answers1

4

Servers in MINIX do not link with the full, bloated and verbose libc.a, rather with a limited version of the C library (probably libminc in your case). Clearly strtok was not considered to be part of that limited library in the release you are using. Either move strtok.c to that library (edit libminc/Makefile then clean and rebuild), or link explicitly with strtok.o.

AntoineL
  • 888
  • 4
  • 25