请教个gcc 链接.a的问题

hktl 2010-09-20 03:26:13
我有一个别人的.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


请问这个问题要怎么解决
...全文
1633 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
heisall 2013-02-04
  • 打赏
  • 举报
回复
遇到同样的问题学习了
上山老人 2011-03-07
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 bluejays 的回复:]

关于`__isoc99_sscanf'的错误
[/Quote]

想知道这个错误是什么原因??谢谢
hktl 2010-09-21
  • 打赏
  • 举报
回复
justkk
是的
用-m32就可以了
测试已经通过,
我刚想上来告诉大家

谢谢大家
马上给分
justkk 2010-09-21
  • 打赏
  • 举报
回复
那你也用32位编译试试呢
gcc -m32 ...
hktl 2010-09-21
  • 打赏
  • 举报
回复
bluejays
你说的都对
.a是对方合作的公司编译,是32位系统
我的服务器是64位

按目前我们测试的情况来看
我一调用他的虑数就出错
因为对方在虑数的入口处的打印并没有出错
估计是链接有问题
hktl 2010-09-21
  • 打赏
  • 举报
回复
`__isoc99_sscanf'的问题对方已经解决了

目前编译出现如下的警告

[root@L2950-A tt]# 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(aes.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


编译虽然可以成功
但我一调用a.a的函数就出错
对方的a.a是在32位编译的
我的系统用getconf LONG_BIT 显示64位
bluejays 2010-09-20
  • 打赏
  • 举报
回复
关于`__isoc99_sscanf'的错误,我怀疑是别人编译.a的系统和你现在用的系统不一样
bluejays 2010-09-20
  • 打赏
  • 举报
回复
显然是.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的配置
manytao 2010-09-20
  • 打赏
  • 举报
回复
楼上的有道理。 楼主可以考虑换一下32位的i586了。。
justkk 2010-09-20
  • 打赏
  • 举报
回复
把你的程序编译为64位试试呢
gcc -m64 ..
快乐田伯光 2010-09-20
  • 打赏
  • 举报
回复
基本上是没办法做到,看上去是你的程序是32位的但是你想用的库是64位的。

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧