database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 2330 게시물 읽기
No. 2330
Re: 컴파일시의 에러....
작성자
정재익
작성일
2001-02-20 14:06
조회수
3,909

아마도 소스 컴파일해서 설치하기 보다는 rpm 으로 설치한듯 한 느낌이 드는군요. 컴파일시 옵션을 어떻게 주셨는지요. gcc 컴파일시 사용한 명령어를 옵션과 합쳐서 보여 주시기 바랍니다.

 

>>이태웅 님께서 쓰시길<<

 

:: 안녕하세요~

::

:: 소스는...

:: #include <stdio.h>

:: #include "/usr/include/pgsql/libpq/fe.h"

:: // 이상한데 깔려있어서리.. //;

::

:: void exit_nicely(PGconn *conn)

:: {

:: PQfinish(conn);

:: exit(1);

:: }

::

:: int main()

:: {

:: char *pghost,

:: *pgport,

:: *pgoptions,

:: *pgtty;

:: char *dbName, *login, *pwd;

:: int nFields;

:: int i, j;

::

:: /* FILE *debug; */

::

:: PGconn *conn;

:: PGresult *res;

::

:: /*

:: * begin, by setting the parameters for a backend connection if the

:: * parameters are null, then the system will try to use reasonable

:: * defaults by looking up environment variables or, failing that,

:: * using hardwired constants

:: */

:: pghost = NULL; /* host name of the backend server */

:: pgport = NULL; /* port of the backend server */

:: pgoptions = NULL; /* special options to start up the backend

:: * server */

:: pgtty = NULL; /* debugging tty for the backend server */

:: dbName = "imsi";

:: login = "imsi";

:: pwd = NULL;

::

:: /* make a connection to the database */

:: conn = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, login, pwd);

::

:: /*

:: * check to see that the backend connection was successfully made

:: */

:: if (PQstatus(conn) == CONNECTION_BAD)

:: {

:: fprintf(stderr, "Connection to database '%s' failed.\n", dbName);

:: fprintf(stderr, "%s", PQerrorMessage(conn));

:: exit_nicely(conn);

:: }

::

:: /* debug = fopen("/tmp/trace.out","w"); */

:: /* PQtrace(conn, debug); */

::

:: /* start a transaction block */

:: res = PQexec(conn, "select * from imsi;");

:: if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)

:: {

:: fprintf(stderr, "select command failed\n");

:: PQclear(res);

:: exit_nicely(conn);

:: }

:: /*

:: * should PQclear PGresult whenever it is no longer needed to avoid

:: * memory leaks

:: */

:: PQclear(res);

::

:: /* first, print out the attribute names */

:: nFields = PQnfields(res);

:: for (i = 0; i < nFields; i++)

:: printf("%/15s", PQfname(res, i));

:: printf("\n\n");

::

:: /* next, print out the instances */

:: for (i = 0; i < PQntuples(res); i++)

:: {

:: for (j = 0; j < nFields; j++)

:: printf("%/15s", PQgetvalue(res, i, j));

:: printf("\n");

:: }

:: PQclear(res);

::

:: /* close the connection to the database and cleanup */

:: PQfinish(conn);

::

:: /* fclose(debug); */

:: return 0;

::

:: }

::

:: 에러메시지는..

:: cc imsi.c

:: /tmp/ccbd6W2N.o: In function `exit_nicely':

:: /tmp/ccbd6W2N.o(.text+0x8): undefined reference to `PQfinish'

:: /tmp/ccbd6W2N.o: In function `main':

:: /tmp/ccbd6W2N.o(.text+0x78): undefined reference to `PQsetdbLogin'

:: /tmp/ccbd6W2N.o(.text+0x89): undefined reference to `PQstatus'

:: /tmp/ccbd6W2N.o(.text+0xb3): undefined reference to `PQerrorMessage'

:: /tmp/ccbd6W2N.o(.text+0xe6): undefined reference to `PQexec'

:: /tmp/ccbd6W2N.o(.text+0xfd): undefined reference to `PQresultStatus'

:: /tmp/ccbd6W2N.o(.text+0x128): undefined reference to `PQclear'

:: /tmp/ccbd6W2N.o(.text+0x140): undefined reference to `PQclear'

:: /tmp/ccbd6W2N.o(.text+0x14c): undefined reference to `PQnfields'

:: /tmp/ccbd6W2N.o(.text+0x179): undefined reference to `PQfname'

:: /tmp/ccbd6W2N.o(.text+0x1b5): undefined reference to `PQntuples'

:: /tmp/ccbd6W2N.o(.text+0x1ed): undefined reference to `PQgetvalue'

:: /tmp/ccbd6W2N.o(.text+0x227): undefined reference to `PQclear'

:: /tmp/ccbd6W2N.o(.text+0x233): undefined reference to `PQfinish'

:: collect2: ld returned 1 exit status

:: 이렇게 나와요.

:: libpq.so 이 파일은 /usr/lib에 깔려있답니다. 기본으로 /etc/ld.so.conf에 있는 폴더.. 예전엔 이렇

:: 지 않았던것 같은데.. 역시 다른 사람의 컴퓨터는 정말.....

[Top]
No.
제목
작성자
작성일
조회
2333posrgresql에서의 패스워드
사이버
2001-02-20
3275
2334┕>Re: posrgresql에서의 패스워드
정재익
2001-02-20 20:28:38
3849
2332Windows 2000 에서 postmaster 가 작동 안함~!
초보
2001-02-20
3580
2329조회수가 높은 글의 특징...
이태웅
2001-02-20
3388
2331┕>Re: 조회수가 높은 글의 특징...
정재익
2001-02-20 14:07:56
3245
2328컴파일시의 에러....
이태웅
2001-02-20
3578
2330┕>Re: 컴파일시의 에러....
정재익
2001-02-20 14:06:42
3909
2335 ┕>Re: Re: 컴파일시의 에러....
이태웅
2001-02-21 09:51:25
3649
2339  ┕>Re: Re: Re: 컴파일시의 에러....
정재익
2001-02-21 17:16:57
3548
2325oid 란 data type?
이주형
2001-02-20
4460
2326┕>Re: oid 란 data type?
신현호
2001-02-20 04:49:05
3946
2324IPV6 인가?
신현호
2001-02-20
3192
2327┕>Re: IPV6 인가?
정재익
2001-02-20 09:59:53
3771
2323Sequence 의 최대 값은 얼마일까요?
정재익
2001-02-20
3515
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.022초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다