#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
本文分享自 Rice 嵌入式开发技术分享 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!