[Linker Error] Unresolved external

Discussion in 'C Programming' started by Laszlo, Dec 6, 2004.

  1. Laszlo

    Laszlo Guest

    Hi all,

    As a novice I installed PostgreSQL 7.2.1 on Win32 and works,
    Borland C++Builder Enterprise Suite 5.0 (build 12.34) what works too.

    I decided to combine these two programs and develop a simple GUI app
    to display datas queried from PostgreSQL. I did make the following
    changes in the project's settings:

    Project->Properties->Directories->Include path += C:\Program
    Files\PostgreSQL\7\include
    Project->Properties->Directories->Librariy path += C:\Program
    Files\PostgreSQL\7\lib

    (I aded these lines to the project paths).

    Within a brand new BCB project I typed in the simpliest code:


    #include <libpq-fe.h>
    char *pghost, *pgport, *pgoptions, *pgtty;
    char *dbName;
    int nFields, i, j;
    PGconn *conn;
    PGresult *res;

    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 = "template1";

    /* make a connection to the database */
    conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);

    res = PQexec(conn, "BEGIN");
    PQclear(res);

    res = PQexec(conn, "DECLARE mycursor CURSOR FOR SELECT * FROM
    pg_database");
    PQclear(res);
    res = PQexec(conn, "FETCH ALL in mycursor");
    nFields = PQnfields(res);
    for (i = 0; i < nFields; i++)
    printf("%-15s", PQfname(res, i));
    printf("\n\n");

    /* next, print out the rows */
    for (i = 0; i < PQntuples(res); i++)
    {
    for (j = 0; j < nFields; j++)
    printf("%-15s", PQgetvalue(res, i, j));
    printf("\n");
    }
    PQclear(res);

    res = PQexec(conn, "CLOSE mycursor");
    PQclear(res);

    /* commit the transaction */
    res = PQexec(conn, "COMMIT");
    PQclear(res);

    /* close the connection to the database and cleanup */
    PQfinish(conn);

    When I run the app I got these errors:

    [Linker Error] Unresolved external '_PQconnectdb'
    referenced from C:\PROGRAM
    FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    [Linker Error] Unresolved external '_PQnfields'
    referenced from C:\PROGRAM
    FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    [Linker Error] Unresolved external '_PQexec'
    referenced from C:\PROGRAM
    FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    [Linker Error] Unresolved external '_PQclear'
    referenced from C:\PROGRAM
    FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    [Linker Error] Unresolved external '_PQfinish'
    referenced from C:\PROGRAM
    FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ

    What is wrong? I supose that I miss something to configure.

    Laszlo Graf
    Laszlo, Dec 6, 2004
    #1
    1. Advertising

  2. Laszlo

    -berlin.de Guest

    Laszlo <> wrote:
    > As a novice I installed PostgreSQL 7.2.1 on Win32 and works,
    > Borland C++Builder Enterprise Suite 5.0 (build 12.34) what works too.


    > I decided to combine these two programs and develop a simple GUI app
    > to display datas queried from PostgreSQL. I did make the following
    > changes in the project's settings:


    > Project->Properties->Directories->Include path += C:\Program
    > Files\PostgreSQL\7\include
    > Project->Properties->Directories->Librariy path += C:\Program


    <OT>
    Shouldn't that be "Library" instead of "Librariy"?
    </OT>

    > Files\PostgreSQL\7\lib


    > (I aded these lines to the project paths).


    > Within a brand new BCB project I typed in the simpliest code:


    > #include <libpq-fe.h>
    > char *pghost, *pgport, *pgoptions, *pgtty;
    > char *dbName;
    > int nFields, i, j;
    > PGconn *conn;
    > PGresult *res;


    > 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 = "template1";


    > /* make a connection to the database */
    > conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);


    > res = PQexec(conn, "BEGIN");
    > PQclear(res);


    > res = PQexec(conn, "DECLARE mycursor CURSOR FOR SELECT * FROM
    > pg_database");
    > PQclear(res);
    > res = PQexec(conn, "FETCH ALL in mycursor");
    > nFields = PQnfields(res);
    > for (i = 0; i < nFields; i++)
    > printf("%-15s", PQfname(res, i));
    > printf("\n\n");


    > /* next, print out the rows */
    > for (i = 0; i < PQntuples(res); i++)
    > {
    > for (j = 0; j < nFields; j++)
    > printf("%-15s", PQgetvalue(res, i, j));
    > printf("\n");
    > }
    > PQclear(res);


    > res = PQexec(conn, "CLOSE mycursor");
    > PQclear(res);


    > /* commit the transaction */
    > res = PQexec(conn, "COMMIT");
    > PQclear(res);


    > /* close the connection to the database and cleanup */
    > PQfinish(conn);


    > When I run the app I got these errors:


    > [Linker Error] Unresolved external '_PQconnectdb'
    > referenced from C:\PROGRAM


    <OT>
    PQconnectdb() is never called in your program, but instead
    PQsetdb(), so it looks as if you're not posting the error
    messages you got when you tried to link the above program.
    </OT>

    > FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    > [Linker Error] Unresolved external '_PQnfields'
    > referenced from C:\PROGRAM
    > FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    > [Linker Error] Unresolved external '_PQexec'
    > referenced from C:\PROGRAM
    > FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    > [Linker Error] Unresolved external '_PQclear'
    > referenced from C:\PROGRAM
    > FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ
    > [Linker Error] Unresolved external '_PQfinish'
    > referenced from C:\PROGRAM
    > FILES\POSTGRESQL\7\CLIENT\BCB_01\MAIN.OBJ


    > What is wrong? I supose that I miss something to configure.


    Sorry, but that's not a question about C at all but about a) why the
    linker doesn't do what you want it to do and b) how to use your IDE.
    And that's both off-topic here. You will get better replies from a
    group or forum that deals with your IDE (BCP) and linker.

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ -berlin.de
    \__________________________ http://www.toerring.de
    -berlin.de, Dec 6, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    8
    Views:
    10,928
    Scott Allen
    May 2, 2004
  2. Serge
    Replies:
    4
    Views:
    8,691
    Paavo Helde
    Dec 19, 2004
  3. Jim
    Replies:
    0
    Views:
    331
  4. iwl
    Replies:
    2
    Views:
    608
  5. Replies:
    3
    Views:
    240
Loading...

Share This Page