免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1613 | 回复: 0
打印 上一主题 下一主题

[故障求助] 动态库问题 在aix上编译过去就时执行不了 请大家帮忙 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-05-17 13:29 |只看该作者 |倒序浏览
环境: AIX 5L
主函数 ren.c
使用 test.c temp.c 这两个api生成动态库 libtest.so 供主函数调用
编译通过但执行可执行文件时报如下错:
exec(): 0509-036 Cannot load program ren because of the following errors:
       0509-151 The program does not have an entry point or
                  the o_snentry field in the auxiliary header is invalid.
       0509-194 Examine file headers with the 'dump -ohv' command.

小弟不知所措  但在命令行中使用 cc 编译 却至少能够执行主函数中开始的printf语句
忘各位老师高手 多多帮忙!!!  小弟不胜感激

原码如下:
ren.c

#include <stdio.h>;
#include <dlfcn.h>;
#define  MAXLEN 8192

int
main()
{
  int   ilRc;
  char  name[MAXLEN];
  char  para[MAXLEN];
  FILE  *fp;
  int   (*func)();
  void  *Handle;

  printf("input funcname!!\n";
  scanf("%s",name);
  printf("funcname is [%s]\n",name);

  printf("input funcpara!!\n";
  scanf("%s",para);
  printf("funcpara is [%s]\n",para);

  if((fp = fopen("/home/switch/ramon/debug/main.debug","w") == NULL)
  {
      printf("create debug file failed!!\n";
      exit(-1);
  }

  Handle = dlopen("/home/switch/ramon/lib/libtest.so",RTLD_LAZY);
  if(Handle == NULL)   
  {
      fprintf(fp,"dlopen libtest.so failed!!\n";
      exit(-1);
  }

  func = (int(*)())dlsym(Handle,name);
  if(func == NULL){
       fprintf(fp,"dlsym [%s] failed!!\n",name);
       exit(-1);
  }

  ilRc = func(para);
  if(ilRc != 0){
       fprintf(fp,"func [%s] failed!!\n",para);
       exit(-1);
   }
  dlclose(Handle);

  fprintf(fp,"opretion success!!\n";
  fclose(fp);
}

temp.c:

#include <stdio.h>;
int
temp(char *temp)
{
  printf("this is function temp!!\n";
  printf("the string is [%s]!!\n",temp);

}

test.c :

#include <stdio.h>;

int
test(char *test)
{
  printf("this is function test!!\n";
  printf("the string is [%s]!!\n",test);
}

makefile:

INCLUDE= -I$(HOME)/ramon/include
LIBSO= -L$(HOME)/ramon/lib -ltest
BIN= $(HOME)/ramon/bin
LIB= $(HOME)/ramon/lib

CC=cc

CCFLAG= -g -c

.SUFFIXES:  .c .o

all: libtest ren clean

.c.o:
$(CC) $(CCFLAG) -o $*.o  $*.c

ren:ren.o
@echo Building "ren..."
$(CC) -G -o $(BIN)/ren ren.o $(LIBSO) -lc -lm

libtest:test.o temp.o
@echo ----Making dllLibraries-------
$(CC) -G -o libtest.so test.o temp.o -bE:libtest.exp -bM:SRE -bnoentry -lc
mv libtest.so $(LIB)/libtest.so

clean:
rm -f *.o


libtest.exp:
*
*******************************************
*    local service functions
*******************************************
*
#!libtest.o
test
temp
*
*******************************************
*     end define
*******************************************
*

多谢多谢了   高人解决   小弟跪地叩首!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP