Giter VIP home page Giter VIP logo

Comments (17)

will avatar will commented on May 19, 2024

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.

8398a7 avatar 8398a7 commented on May 19, 2024

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.

will avatar will commented on May 19, 2024

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.

8398a7 avatar 8398a7 commented on May 19, 2024

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.

will avatar will commented on May 19, 2024

Did/do you have the libpq-dev package installed from apt?

from crystal-pg.

8398a7 avatar 8398a7 commented on May 19, 2024

Yes, I have.

from crystal-pg.

ysbaddaden avatar ysbaddaden commented on May 19, 2024

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.

ysbaddaden avatar ysbaddaden commented on May 19, 2024

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.

ysbaddaden avatar ysbaddaden commented on May 19, 2024

Related (unsolved): http://stackoverflow.com/questions/13328144/end-symbol-disappears-when-linking-to-libcurl

from crystal-pg.

will avatar will commented on May 19, 2024

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 -Ipg_config --includedir-Lpg_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.

ysbaddaden avatar ysbaddaden commented on May 19, 2024

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.

will avatar will commented on May 19, 2024

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.

fdr avatar fdr commented on May 19, 2024

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.

fdr avatar fdr commented on May 19, 2024

I use the PGDG packages.

from crystal-pg.

will avatar will commented on May 19, 2024

@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.

will avatar will commented on May 19, 2024

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.

will avatar will commented on May 19, 2024

The driver is now native, so this problem is no longer relevant.

from crystal-pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.