system management
1752603 メンバー
4756 オンライン
108788 解決策
新規ポスト

関数 getprpwnam(), getspnam()

 
エムキュ
時折のアドバイザー

関数 getprpwnam(), getspnam()

●C言語から使用する関数 getprpwnam() について

/etc/passwd 管理下で以下のソースコンパイルを行なうとエラーとなります。

【ソースコード】

#include

#include

#include

main(argc, argv)

int argc;

char * argv[];

{

struct pr_passwd *prpwdata;

prpwdata = (struct pr_passwd *)getprpwnam(uname);

exit(0);

}

【エラー】

/usr/ccs/bin/ld: Unsatisfied symbols:

getprpwnam (code)

1.高信頼性システムでないとコンパイル出来ないのでしょうか?

2.また、関数 getspnam() も同様のエラーでコンパイル不可でした。

  /etc/shadow 管理の状態でないとコンパイル出来ないでしょうか?

3件の返信3
テレコム担当者
尊敬されているコントリビューター

関数 getprpwnam(), getspnam()

私も問題が起きましたが、ld のバグのような現象ですね。

$cc -v aaa.c

cc: informational note 404: NLSPATH is /opt/ansic/lib/nls/msg/%L/%N.cat:/opt/ans

ic/lib/nls/msg/C/%N.cat:

cc: informational note 404: INCLUDIR is INCLUDIR=/usr/include

cc: informational note 404: CCOPTS is not set.

/opt/langtools/lbin/cpp.ansi aaa.c /var/tmp/ctmAAAa19840 -$ -D__hp9000s800 -D__h

ppa -D__hpux -D__unix -D_ILP32 -e -D_PA_RISC2_0 -D_HPUX_SOURCE -D__STDC_EXT__ -D

__HP_cc=111108

cc: informational note 411: Entering Preprocessor.

/opt/ansic/lbin/ccom /var/tmp/ctmAAAa19840 aaa.o -Faaa.c -Oq00,al,ag,cn,Lm,sz,Ic

,vo,lc,mf,Po,es,rs,sp,in,vc,pi,fa,pe,Rr,Fl,pv,pa,nf,cp,lx,st,ap,Pg,ug,lu,lb,uj,d

p,fs,bp,wp,cl,mo,xn,Ex,mp,rp,ap,dn,Sg,pt,kt,Em,pc,np! -ESconstlit -Ae

cc: informational note 404: LPATH is /usr/lib:/opt/langtools/lib:

cc: informational note 411: Entering Preprocessor.

/opt/ansic/lbin/ccom /var/tmp/ctmAAAa19840 aaa.o -Faaa.c -Oq00,al,ag,cn,Lm,sz,Ic

,vo,lc,mf,Po,es,rs,sp,in,vc,pi,fa,pe,Rr,Fl,pv,pa,nf,cp,lx,st,ap,Pg,ug,lu,lb,uj,d

p,fs,bp,wp,cl,mo,xn,Ex,mp,rp,ap,dn,Sg,pt,kt,Em,pc,np! -ESconstlit -Ae

cc: informational note 404: LPATH is /usr/lib:/opt/langtools/lib:

/usr/ccs/bin/ld /opt/langtools/lib/crt0.o aaa.o -u main -lc

cc: informational note 413: Entering Link editor.

/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (aaa.o) was detected.

The linked output may not run on a PA 1.x system.

/usr/ccs/bin/ld: Unsatisfied symbols:

getprpwnam (code)

--> 同じ現象!!!

$cc -v aaa.c /usr/lib/libsec.sl

cc: informational note 404: NLSPATH is /opt/ansic/lib/nls/msg/%L/%N.cat:/opt/ans

ic/lib/nls/msg/C/%N.cat:

cc: informational note 404: INCLUDIR is INCLUDIR=/usr/include

cc: informational note 404: CCOPTS is not set.

/opt/langtools/lbin/cpp.ansi aaa.c /var/tmp/ctmAAAa19885 -$ -D__hp9000s800 -D__h

ppa -D__hpux -D__unix -D_ILP32 -e -D_PA_RISC2_0 -D_HPUX_SOURCE -D__STDC_EXT__ -D

__HP_cc=111108

cc: informational note 411: Entering Preprocessor.

/opt/ansic/lbin/ccom /var/tmp/ctmAAAa19885 aaa.o -Faaa.c -Oq00,al,ag,cn,Lm,sz,Ic

,vo,lc,mf,Po,es,rs,sp,in,vc,pi,fa,pe,Rr,Fl,pv,pa,nf,cp,lx,st,ap,Pg,ug,lu,lb,uj,d

p,fs,bp,wp,cl,mo,xn,Ex,mp,rp,ap,dn,Sg,pt,kt,Em,pc,np! -ESconstlit -Ae

cc: informational note 404: LPATH is /usr/lib:/opt/langtools/lib:

/usr/ccs/bin/ld /opt/langtools/lib/crt0.o aaa.o /usr/lib/libsec.sl -u main -lc

cc: informational note 413: Entering Link editor.

/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (aaa.o) was detected.

The linked output may not run on a PA 1.x system.

--> /usr/lib/libsec.sl を指定リンクするとOK。

エムキュ
時折のアドバイザー

関数 getprpwnam(), getspnam()

テレコム担当者 様

/usr/lib/libsec.sl 指定でコンパイルできました。

ありがとうございました。

uhyo
貴重なコントリビューター

関数 getprpwnam(), getspnam()

すでにテレコム担当者さんから回答がでているので

あえて書き込むことではないかもしれませんが、

getprpwnam()をmanで調べると、

"これらのルーチンを使用したプログラムは必ず、 -lsec を使用してコンパイルしてください。"

と記載されています。関数などがおかしな振る舞いを

したり、リンクできないときはmanを参照すると

けっこういい情報がでてきたりしますよ。