我想在linux中为windows编译静态库.以下是我编写的程序
i586-mingw32msvc-cc -c static_lib.c -o static_lib.oar rv static_lib.a static_lib.o和.中创建了静态库ranlib static_lib.a在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
Run Code Online (Sandbox Code Playgroud)
守则如下:
static_lib.c
#include <stdio.h>
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");
}
Run Code Online (Sandbox Code Playgroud)
sample_static.c
#include <stdio.h>
extern void func(void);
int main ()
{
printf ("Main function\n");
func();
}
Run Code Online (Sandbox Code Playgroud)
请给我建议编译并使其工作.
关于约翰尼艾伦
尝试使用交叉编译器归档器而不是本机归档器,即使用i586-mingw32msvc-arandi586-mingw32msvc-ranlib而不是arand ranlib。
或者这只是问题上的错字?