欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

linux 交叉编译 静态库,从Linux为Windows开发交叉编译静态库

发布时间:2025/3/15 26 豆豆
生活随笔 收集整理的这篇文章主要介绍了 linux 交叉编译 静态库,从Linux为Windows开发交叉编译静态库 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

我想在Linux中为Windows编译静态库。以下是我跟着编译从Linux为Windows开发交叉编译静态库

使用i586-mingw32msvc-cc -c static_lib.c -o static_lib.o

创建静态库在linux ar rv static_lib.a static_lib.o和ranlib static_lib.a

编译的Linux静态库的源代码的程序我在Eclipse中创建了一个示例程序在Windows和链接这个静态库,它是在linux中为Windows交叉编译的。在windows上使用的编译器是mingw。

在windows eclipse中编译程序的时候,编译器给了我下面的错误。

static_test\static_lib.a: file format not recognized; treating as linker script

\static_test\static_lib.a:1: syntax error

collect2: ld returned 1 exit status

Build error occurred, build is stopped

的代码如下:

static_lib.c

#include

void func(void)

{

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

printf("Hello\n");

}

sample_static.c

#include

extern void func(void);

int main()

{

printf ("Main function\n");

func();

}

请给我点建议编译并得到它的工作。

问候 杜琪峰艾伦

2011-01-07

Johnnie

总结

以上是生活随笔为你收集整理的linux 交叉编译 静态库,从Linux为Windows开发交叉编译静态库的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。