will / crystal-pg

a postgres driver for crystal
BSD 3-Clause "New" or "Revised" License
462 stars 77 forks source link

Error on database read #147

Closed pcoenen closed 6 years ago

pcoenen commented 6 years ago

Hello,

I got two questions:

1) how to add a password and username ?

2) When I run the folowing piece of code, I get the following error

require "db"
require "pg"

DB.open "postgress://localhost:5432/mydatabase" do |db|
    puts db.exec "SELECT * FROM public.table ORDER BY id ASC LIMIT 100"
end
crystal src/test.cr 
_main.o: In function `__crystal_main':
/usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `SSL_library_init'
/usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `SSL_load_error_strings'
/usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `ERR_load_crypto_strings'
O-penS-S-L-5858S-S-L-5858C-ontext.o: In function `default_method':
/usr/share/crystal/src/openssl/ssl/context.cr:4: undefined reference to `SSLv23_method'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/user/.cache/crystal/crystal-run-test.tmp'  -rdynamic  `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre -lm -lgc -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`
pcoenen commented 6 years ago

Error was fixes by running sudo apt-get install libssl1.0-dev