日期:2014-05-16  浏览次数:20609 次

请教个gcc 链接.a的问题
我有一个别人的.a文件
要用到这个文件的下面函数
int FileEntrypt("642B194C7FBF4e09849A9FD2265A57FE","21.txt","22.txt","helloc");

于是我写了个b.c

#include <stdio.h>
#include "a.h"


int main(int argc,char **argv)
{
FileEntrypt("i","k","k","ik");
}

然后我gcc -o b b.c a.a


/usr/bin/ld: warning: i386 architecture of input file `a.a(ccdrm.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: i386 architecture of input file `a.a(Entrypt.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: i386 architecture of input file `a.a(crypt.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: i386 architecture of input file `a.a(sha256.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: i386 architecture of input file `a.a(aes.o)' is incompatible with i386:x86-64 output
a.a(Entrypt.o): In function `nSetSerialNum':
Entrypt.c:(.text+0x9d): undefined reference to `__isoc99_sscanf'
collect2: ld returned 1 exit status


请问这个问题要怎么解决

------解决方案--------------------
基本上是没办法做到,看上去是你的程序是32位的但是你想用的库是64位的。
------解决方案--------------------
把你的程序编译为64位试试呢
gcc -m64 ..
------解决方案--------------------
   楼上的有道理。  楼主可以考虑换一下32位的i586了。。
------解决方案--------------------
显然是.a和gcc的配置不符,一个是32位,另一个是64位。

从这个提示来看,i386 architecture of input file `a.a(ccdrm.o)' 
我感觉.a是32位的,而gcc是64位的。
LZ可以用gcc -v看看,比如我的输出里有一行“Target: x86_64-redhat-linux”

解决的办法就是让这两个一致。
最好把.a的源代码拿来再编译一次。如果没有源码,那就只好修改gcc的配置,让他去配合.a的配置

------解决方案--------------------
那你也用32位编译试试呢
gcc -m32 ...