#include "rice.h"
void rice_func()
{
printf("rice func\n");
}
#ifndef __RICE_H
#define __RICE_H
#include <stdio.h>
void rice_func();
#endif
SET(LIBRICE_SRC rice.c)
ADD_LIBRARY(rice STATIC ${LIBRICE_SRC})
#include <rice.h>
int main(int argc, char *argv[])
{
printf("test sample\n");
rice_func();
}
$ gcc main.c -I ./ -L./ -lrice
$ ./a.out
test sample
rice func
#include <stdio.h>
void rice_func()
{
printf("rice yes\n");
}
$ gcc main.c -I ./ -L./ -lrice test.c
/tmp/ccLygTKk.o: In function `rice_func':
test.c:(.text+0x0): multiple definition of `rice_func'
.//librice.a(rice.c.o):rice.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ objcopy -W rice_func librice.a
$
$ gcc main.c -I ./ -L./ -lrice test.c
$ ./a.out
test sample
rice yes