交叉编译1

来源:互联网 发布:linux matlab 13b 编辑:程序博客网 时间:2024/06/05 02:22
交叉编译:
arm-linux-gcc包解压至/usr/local
gedit etc/profile,添加pathnum 路径 arm-linux-gcc
对源代码进行宿主机编译验证:gcc main.c -o main
file main
改变指令:arm-linux-gcc main.c -o main
建立源代码包和存放结果的文件夹,一般建立在usr下
hello.c
int main()
{
     mysay("hello");
}

helle.h
#ifdefine _hello_h
#defne _hello_h
#ifdefine _cplusplus
extern "C"
{
#endif
void mysay(const char *s);
#ifdefine _cplusplus
}
#endif

arm-linux-gcc hello.c -shared -o libhello.so /生产动态库文件
file lib.so

main.c
#include<hello.h>
int main()
{
 mysay("1");
}

arm-linux-gcc main.c -o main  -l/usr/arm/include -/usr/arm/lib -lsay ;链接动态库.so,
file main
arm-linux-readelf main -d(引用多少库,还可以-s,表示引用多少个符号)
0 0
原创粉丝点击