Minix: undefined reference to 'strtok'?

荒凉一梦 提交于 2021-02-10 07:54:09

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/26947282/minix-undefined-reference-to-strtok

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!