求助:he program does not have an entry point or

prettyicy 2009-10-26 09:41:35
求助各位高手:
写了个makefile,make后成功,但运行程序时,提示
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.

网上搜了搜,有人遇到相同问题,说是编译的时候少加了一个参数 -brtl
但不知道加在哪里%>_<%

请大家帮帮忙%>_<%
...全文
566 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
fleim 2012-07-05
  • 打赏
  • 举报
回复
AIX 下通常用xlC来编译c++代码,例如我写了一个string的类,包含俩文件 string.h 和 string.cpp ,现在我想将其编译成动态链接库(.so文件),方法为:

xlC -G -o libstring.so string.cpp

AIX下.so文件最好用 libxxxxx.so的方式来命名,因为在后面与其他文件一起编译链接成可执行文件时会好办些

我又写了一个test.cpp 包含main方法 用来测试string.so中的类是不是可以正常使用,现在我们假设libstring.so文件的path为:/home/hello/lib 那么编译链接成可执行文件时,命令为:

xlC -brtl -L/home/hello/lib -lstring -o test test.cpp
(如果找不到,用xlC -brtl /home/hello/lib/libstring.so -o test test.cpp)
xlC 中: -brtl表示: Enables run-time linking for the output file. DCE thread libraries and heap debug libraries are not compatible with run-time linking. Do not specify the -brtl compiler option if you are invoking the compiler with xlc_r4 or xlC_r4, or if the -qheapdebug compiler option is specified.
就是对于输出的可执行文件,启动运行时动态链接,根据公司头的解释,在加入这项时,连接器会在可执行文件和.so文件之间建立一个签名(signature),用来说明他们俩的接口,而.so文件的搜寻和载入则是由OS来负责的。

-L说明.so文件或者.a文件(静态链接库)所在的path,-l说明链接库的名称,比如 我们写 -lxxx ,连接器会去搜寻 libxxx.so 或者 libxxx.a 文件来进行处理。




fleim 2012-07-05
  • 打赏
  • 举报
回复
xlc对应-g;

xlC对应-g或-G。

否则编译后,运行时报如下错误:

exec(): 0509-036 Cannot load program ./t 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.


xue98 2009-10-26
  • 打赏
  • 举报
回复
If the linker command (ld) was used instead of the compiler driver (cc) as follows:
$ cc -c main.c
$ ld main.o func1.so func2.so func3.so -brtl
then the program would print the following error message, since the generated
executable would not contain the necessary start up routine:
$ LIBPATH=$PWD ./a.out
exec(): 0509-036 Cannot load program ./a.out 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.
xue98 2009-10-26
  • 打赏
  • 举报
回复
using the wrong AIX linker. It should be using the executable linker, not the library linker.

好像是连接器的问题

your gcc is using AIX's ld, I'm afraid the fix we have will only work if gcc
is using GNU's ld.

is this gcc the "standard" gcc from AIX?, could you get another one that is
configured to use GNU ld instead?; you could find by running :

$ gcc -print-prog-name=ld
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
好像没有/usr/vacpp/bin/xlC_r、

删除再make,执行依然报相同的错
xue98 2009-10-26
  • 打赏
  • 举报
回复
你把 icytest icytest.o 这两个文件删除了, 然后再 make 一下

你机器上面有 /usr/vacpp/bin/xlC_r 吗?
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
是AIX

make完以后,运行可执行程序
提示
exec(): 0509-036 Cannot load program icytest 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.
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
是AIX

make完以后,运行可执行程序
提示
exec(): 0509-036 Cannot load program icytest 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.
xue98 2009-10-26
  • 打赏
  • 举报
回复
结帖

你用的AIX 系统?
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
谢谢你。
可是运行时还是报错
0509-036 Cannot load program icytest 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.

顺便问下怎么给分。。。
xue98 2009-10-26
  • 打赏
  • 举报
回复
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.

报错的前面是什么?
xue98 2009-10-26
  • 打赏
  • 举报
回复
你用的AIX 系统?/
xue98 2009-10-26
  • 打赏
  • 举报
回复
CC = cc $(Q64) -g -brtl
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
是sybase
想写个程序,往表里插记录
xue98 2009-10-26
  • 打赏
  • 举报
回复
你这是连接sybase 数据库的程序吧。
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
在makefile里加上吗?
谢谢你了。
我菜鸟一只还是不懂
xue98 2009-10-26
  • 打赏
  • 举报
回复
[Quote=引用楼主 prettyicy 的回复:]
求助各位高手:
写了个makefile,make后成功,但运行程序时,提示
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.

网上搜了搜,有人遇到相同问题,说是编译的时候少加了一个参数  -brtl
但不知道加在哪里%>_ <%

请大家帮帮忙%>_ <%

[/Quote]gcc 的时候
gcc -brtl
但 gcc -b 参数的意思是
-b <machine> Run gcc for target <machine>, if installed
prettyicy 2009-10-26
  • 打赏
  • 举报
回复
Makefile内容如下:

SHELL = sh
CC = cc $(Q64) -g
RM = @rm -f
MV = @mv
CP = @cp
ECHO = @echo

##### sybase used #####
RELDIR = $(SYBASE)/$(SYBASE_OCS)
INCDIR = $(RELDIR)/include
LIBDIR1 = $(RELDIR)/lib
INCLUDE = -I. -I$(INCDIR)
LIBPATH = -L$(LIBDIR1)
PRECOMP = cpre
SYBLIBS = -lct -ltcl -lcs -lcomn -lintl
SYSLIBS = -lm
##### sybase used #####

# paths and flags
BIN = $(HOME)/bin
LIBDIR = $(HOME)/lib

LIBAPL = -lnhapinh -lacct -lln -lbase -lpubdb -lcomm -lbaltcp\
-lpubdb_m -lcom -lde -lcif -lcard\
-lrpt -lrept -lpthreads -lnhlink \
-lct -ltcl -lcs -lcomn -lintl -lnh
INC = -I$(HOME)/src/incl_c -I$(HOME)/src/incl_ec -I$(HOME)/src/incl_pub $(INCLUDE)
CLIB = -L$(HOME)/lib -L. $(LIBPATH)
CFLAGS = $(INC) $(CLIB)
APPINCLUDE= -I$(HOME)/src/incl_c -I$(HOME)/src/incl_ec -I$(HOME)/src/incl_pub
PROCINCLUDE= include=$(HOME)/src/incl_c include=$(HOME)/src/incl_ec include=$(HOME)/src/incl_pub
EFLAGS = $(CFLAGS)

TARGET1 = icytest
OBJS1 = icytest.o \


all: $(TARGET1)

$(TARGET1): $(OBJS1)
$(CC) -G $(LIBPATH) $(SYBLIBS) $(SYSLIBS) $(CFLAGS) -o $@ $(OBJS1)
#$(RM) $(HOME)/lib/$@
#$(MV) $@ $(HOME)/lib

# implicit

.SUFFIXES: .cp .c .o
.cp.o:
$(PRECOMP) $(APPINCLUDE) $*.cp
$(CC) $(INC) -O -g -s -c $*.c
@mv $*.c $*.b
.c.o:
$(CC) $(CFLAGS) $(APPINCLUDE) -g -O -s -c $*.c

# clearing object codes

clean: cleanup
$(RM) $(TARGET)

cleanup:
$(RM) $(OBJS)
cleanall:
$(RM) *.b
$(RM) *.o
$(RM) $(TARGET1)


prettyicy 2009-10-26
  • 打赏
  • 举报
回复
谢谢关注。
程序:
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <varargs.h>
#include <errno.h>
#include "public.h"
#include "sybhesql.h"
#define EXTERN
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>

EXEC SQL INCLUDE SQLCA;



int main(int argc, char *argv[])
{
/*变量定义*/
struct timeval t1,t2;
long long timeoff;
int i=0; /*为了循环插入记录*/
/*宿主变量声明*/
EXEC SQL BEGIN DECLARE SECTION;
char username[30];
char password[30];
char a[21];
double b=0.00;
double c=0.00;
int d=0;
char comm[500];
EXEC SQL END DECLARE SECTION;
/*变量初始化*/
strcpy(username, "dhctran1");
strcpy(password, "dhctran1");
memset(a, 0, sizeof(a));
memset(comm, 0, sizeof(comm));

/*连接数据库*/
EXEC SQL CONNECT :username IDENTIFIED BY :password;
if(sqlca.sqlcode)
{
printf("exec err[%d],[%s]\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
return -1;
}

/*写SQL语句*/
strcpy(comm, "insert into icytest values('苹果苹果', 1.2, 0.9, 6)");
strcpy(comm, " insert into icytest values('香蕉香蕉',1.5,1.2,10)");
strcpy(comm, " insert into icytest values('西瓜西瓜', 0.3, 0.2 , 2)");

EXEC SQL set string_rtruncation off; /* 避免9502错误?? */
if(sqlca.sqlcode)
{
/*printf("set err[%d][%s]\n",sqlca.sqlcode, sqlca.sqlerrm.sqlerrm.c);*/
return -1;
}

/*循环插入*/
while(i++<100)
{
get_cur_time(&t1);
/*准备*/
EXEC SQL PREPARE insert_com FROM :comm; /*icytest_insert是语句名*/
/*if(sqlca.sqlcode)
(
printf("prepare err[%d],[%s]\n",sqlca.sqlcode, sqlca.sqlerrm.sqlerrm.c);
return -1;
)*/
/*执行*/
EXEC SQL exec icytest_insert;
if(sqlca.sqlcode)
{
/*printf("exec err[%d][%s]",sqlca.sqlcode, sqlca.sqlerrm.sqlerrm.c);*/
return -1;
}
get_cur_time(&t2);
get_l_time_val(&t1, &t2, &timeoff);
printf("use time=[%lld]\n", timeoff);
}

EXEC SQL COMMIT WORK; /*提交*/
EXEC SQL DISCONNECT ALL; /*断开与服务器的连接*/
printf(";) icytest success!\n");

return 1; /*又返回值的函数一定要有返回值*/
}

xue98 2009-10-26
  • 打赏
  • 举报
回复
程序在哪里?

18,825

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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