Comments (17)
This looks similar to #8 which is some sort of linking problem that we weren't able to get to the bottom of, unfortunately.
Just to make sure when you run pg_config
all the values there are correct?
from crystal-pg.
I tried some pg_config
value, but there were not correct.
It ran correctly after to 9.4 the postgres.
Despite pass the test with postgres 9.3 in travis, I wonder.
from crystal-pg.
The version of the server doesn't matter much as long as it's > 7.3 or so, the last time the protocol changed.
What I think happened is there was something not quite right with your local postgres setup, if pg_config
was giving the wrong information, and when you updated to 9.4 you fixed that as a side-effect.
This project uses pg_config
to find the appropriate directories to link against.
from crystal-pg.
I investigated the pg_config, there was a difference such as follows.
# postgres 9.3.9
INCLUDEDIR = /usr/include/postgresql
LIBDIR = /usr/lib
# postgres 9.4.4
INCLUDEDIR = /usr/include/postgresql
LIBDIR = /usr/lib/x86_64-linux-gnu
Therefore, I tried to rewrite the libpq.cr in this way with postgres 9.3.9, it was successful.
module PG
@[Link(ldflags: "-lpq -I`pg_config --includedir` -L /usr/lib/x86_64-linux-gnu")]
lib LibPQ
My postgres was installed by apt, therefore what is better to take action as good think.
What do you think?
from crystal-pg.
Did/do you have the libpq-dev
package installed from apt?
from crystal-pg.
Yes, I have.
from crystal-pg.
I'm having this bug too, on a "clean" ubuntu trusty install. I never upgraded from another release and I only ever installed PostgreSQL 9.3 (but am up to date on updates and security).
The minimum snippet to reproduce is:
require "pg"
PG.connect("postgres://postgres:@localhost/")
- it fails to compile with the official crystal DEB packages, which uses some embedded static libs (eg: libpcl.a, libgc.a, ...)
- it passes if I compiled crystal myself, which uses shared libraries (so static libs may be a hint)
- it passes with
crystal test_pg.cr --link-flags "-L/usr/lib/x86_64-linux-gnu"
(something seems required in that directory)
BTW: the -I includedir
is unnecessary in the @Link
definition since crystal doesn't care about headers files. Actually @[Link("pq")]
is enough on Linux, except that we need the -L/usr/lib/x86_64-linux-gnu
, even though libpq is installed in /usr/lib
. Maybe libpq merely highlights a linking issue that is unrelated?
from crystal-pg.
Errata: it passes with -L/usr/lib/x86_64-linux-gnu
because the linker no longer uses the embedded static libs from /opt/crystal/embedded/lib
and instead uses shared libs from /usr/lib/x86_64-linux-gnu
to compile the binary.
from crystal-pg.
Related (unsolved): http://stackoverflow.com/questions/13328144/end-symbol-disappears-when-linking-to-libcurl
from crystal-pg.
Is /usr/lib/x86_64-linux-gnu
not the result of pg_config --libdir
for you?
If it is the same, then I don't understand why the @[Link(ldflags: "-lpq -I
pg_config --includedir-L
pg_config --libdir")]
line doesn't work (even if -I isn't necessary).
If it isn't the same, then I don't understand why your pg_config
is returning incorrect data.
from crystal-pg.
No, pg_config --libdir
states /usr/lib
which is where libpq.{a,so}
is indeed installed.
This seems to be a common linker bug, triggered by linking against libgc.a
and libpq.so
or libcom_err.so
but doesn't happen when using libgc.so
(or something like that).
from crystal-pg.
I checked with my Ubuntu-using colleges, and they have pg_config binaires that give the correct results
~$ pg_config --libdir
/usr/lib/x86_64-linux-gnu
Can you try something like
export PATH=/opt/PostgreSQL/9.3/bin/:$PATH
(or wherever the binaries are) to get a proper pg_config?
from crystal-pg.
Hi,
@will asked me to have a look at how pg_config
presents --libdir
on Ubuntu. It looks like it has a useful value on my system:
$ pg_config --libdir
/usr/lib/x86_64-linux-gnu
$ cat /etc/issue.net
Ubuntu 15.04
from crystal-pg.
I use the PGDG packages.
from crystal-pg.
@fdr I've been able to reproduce this on an aws instance, and it also happens on the image b&p uses for slugc. I added your pubkey to the aws instance, can you help me track this down?
from crystal-pg.
So, @fdr and I tracked this down more, crystal-lang/crystal#1269
It explains why when the libdir isn't /usr/lib things work
from crystal-pg.
The driver is now native, so this problem is no longer relevant.
from crystal-pg.
Related Issues (20)
- shards update/install/build failing at the crystal-pg step HOT 2
- What versions are supported? HOT 2
- Unhandled exception: cannot insert multiple commands into a prepared statement (PQ::PQError) HOT 3
- getting OverflowError:Arithmetic overflow HOT 6
- Error: no overload matches 'PG::Decoders.array_decoder' with type UUID.class HOT 1
- Connecting to unix socket with url HOT 3
- Shards update broken on Crystal 1.0 HOT 2
- Too many successive queries result in DB::ConnectionLost HOT 4
- Unable to connect to Cockroachdb HOT 2
- New Release 0.23.3? HOT 2
- cockroach db HOT 2
- Proper implementation of `sslmode=verify-full` HOT 2
- Unhandled exception: column "foo" does not exist (PQ::PQError) - How to insert into table without specifying all the columns HOT 1
- Time seems to drop precision when passed in as an arg using at_end_of_day HOT 5
- Tables with upcase symbols not readed HOT 2
- Error: can't cast to JSON::Any
- Add ability to automatically return `TIMESTAMPTZ`->`Time` in the Postgres session's time zone
- Exception sending query with bytea[] binary array type? HOT 2
- Support inserting `PG::Interval` instances HOT 3
- Support for fetching results in the text format
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal-pg.