얼랭 (Erlang) 드라이버의 작동 방식을 더 잘 이해하기 위해 책에서 간단한 예제로 시작했지만 원시 얼랭 (Erlang) 드라이버 코드가 포함 된 C 파일을 컴파일하려고하면 다음과 같은 컴파일 오류 메시지가 나타납니다.Erlang 드라이버를 컴파일하는 방법은 무엇입니까?
/tmp/ccQ0GroH.o:example1_lid.c:(.text+0xe)
driver_alloc' /tmp/ccQ0GroH.o:example1_lid.c:(.text+0x2f): undefined reference to
driver_free ' /tmp/ccQ0GroH.o:example1_lid.c:(.text+0xb0)에 정의되지 않은 참조 :'로 정의 참조 driver_output '
왜 이런 일이 벌어지고 어떻게 해결할 수 있는지 아는 사람이 있습니까? 참조 용으로 C 파일이 아래에 게시됩니다.
감사합니다.
/* example1_lid.c */
#include <stdio.h>
#include "erl_driver.h"
typedef struct {
ErlDrvPort port;
} example_data;
static ErlDrvData example_drv_start(ErlDrvPort port, char *buff)
{
example_data* d = (example_data*)driver_alloc(sizeof(example_data));
d->port = port;
return (ErlDrvData)d;
}
static void example_drv_stop(ErlDrvData handle)
{
driver_free((char*)handle);
}
static void example_drv_output(ErlDrvData handle, char *buff, int bufflen)
{
example_data* d = (example_data*)handle;
char fn = buff[0], arg = buff[1], res;
if (fn == 1) {
res = twice(arg);
} else if (fn == 2) {
res = sum(buff[1], buff[2]);
}
driver_output(d->port, &res, 1);
}
ErlDrvEntry example_driver_entry = {
NULL, /* F_PTR init, N/A */
example_drv_start, /* L_PTR start, called when port is opened */
example_drv_stop, /* F_PTR stop, called when port is closed */
example_drv_output, /* F_PTR output, called when erlang has sent
data to the port */
NULL, /* F_PTR ready_input,
called when input descriptor ready to read*/
NULL, /* F_PTR ready_output,
called when output descriptor ready to write */
"example1_drv", /* char *driver_name, the argument to open_port */
NULL, /* F_PTR finish, called when unloaded */
NULL, /* F_PTR control, port_command callback */
NULL, /* F_PTR timeout, reserved */
NULL /* F_PTR outputv, reserved */
};
DRIVER_INIT(example_drv) /* must match name in driver_entry */
{
return &example_driver_entry;
}
컴파일 플래그를 제공 할 수 있습니까? – user