Thread: compile error in libpq program
I use this command to compile the libpq.c.
cc -I /opt/PostgreSQL/8.4/include -o libpq libpq.c -L /opt/PostgreSQL/8.4/lib -lpq
but I get these error:
/usr/bin/ld: warning: libssl.so.4, needed by /opt/PostgreSQL/8.4/lib/libpq.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcrypto.so.4, needed by /opt/PostgreSQL/8.4/lib/libpq.so, not found (try using -rpath or -rpath-link)
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `TLSv1_method'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_set_ex_data'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_connect'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `X509_STORE_load_locations'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `BIO_free'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `BIO_ctrl'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `CRYPTO_set_locking_callback'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `X509_NAME_oneline'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_CTX_set_verify'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `PEM_read_bio_PrivateKey'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `CRYPTO_num_locks'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `ENGINE_finish'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_CTX_load_verify_locations'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `ERR_get_error'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `ERR_reason_error_string'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_library_init'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `CRYPTO_set_id_callback'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_get_ex_data'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_new'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_write'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `OPENSSL_config'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_CTX_get_cert_store'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `X509_check_private_key'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `X509_free'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_shutdown'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `BIO_new_file'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `ENGINE_free'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `SSL_get_error'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `ENGINE_by_id'
/opt/PostgreSQL/8.4/lib/libpq.so: undefined reference to `ENGINE_init'
collect2: ld 返回 1
I use postgresql 8.4 and use ssl to connect the server.
On 10/21/10 5:24 PM, zab08 wrote: > I use this command to compile the libpq.c. > *cc -I /opt/PostgreSQL/8.4/include -o libpq libpq.c -L > /opt/PostgreSQL/8.4/lib -lpq* > * > * > but I get these error: > /usr/bin/ld: warning: libssl.so.4, needed by > /opt/PostgreSQL/8.4/lib/libpq.so, not found (try using -rpath or > -rpath-link) > /usr/bin/ld: warning: libcrypto.so.4, needed by > /opt/PostgreSQL/8.4/lib/libpq.so, not found (try using -rpath or > -rpath-link) > if you don't want SSL support, you need to run ./configure --without-openssl if you DO want SSL support, you'll need those libraries in a standard place, or specify --with-openssl=/path/to/ssl you should use make and the Makefile generated by ./configure to get all the settings correct.... I believe you can use make libpq.so to just build the runtime rather than the full system.
On 10/21/10 9:14 PM, zab08 wrote: > > more detail? I don't understand. please send responses to the mail list so others can contribute. libpq is only one piece of postgres, and building it has to be done in the context of the rest of the postgres build environment, you can't just manually compile it standalone and expect sane results. before you compile any of the postgres components, you run the ./configure script in the top level postgres directory with the appropriate options for your envinronment, this sets up the proper build environment, including various libraries such as libssl and libcrypto. Your compile failed because it didn't know where these libraries are. if you want to just compile libpq, and not the rest of postgres, I would first run './configure' with proper options in the top directory, then 'cd src/interfaces/libpq ' and run 'make' there.