-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined refences when compiling example from the documentation #828
Comments
@ldpl what compile options did you use for compiling libpqxx? |
I tried compiling with no options, tried with |
Thanks @ldpl, that tells us a few things about what the problem isn't. Unfortunately at this point we're left with a mystery, so we'll have to go through the possibilities. Here's a very basic one: What happens if, on the command line where you compile & link your own application, you put the So: |
No idea why but that compiles just fine. UPD. And so does |
This may be due to gcc's behavior. |
Exactly. Thanks @tt4g for looking that up. The surprising part is that AFAIR the linking of libraries with |
Well, then I think we know why this happens. I'll close this ticket, and add the note to the earlier instances of the same problem. (Unfortunately I don't think I can prevent recurrences of this problem in the future, since the documentation already shows the correct order pretty clearly. Or did I miss a spot?) |
What I don't understand here is why -l defaults to static linking for pqxx that depends on -l order. Or, at least, that's what I see happening here. |
It puzzles me too, @ldpl. AFAIK the convention has always been to write the linking command line with the object file(s) before the libraries, and perhaps the compiler's behaviour has changed for usage that does not follow that convention. An optimisation perhaps... At least in libpqxx a lot of the build time is spent linking. And to make it worse it's a single-process step where it can be hard for build systems to find other useful work to do. |
I've build and installed version 7.9.0 and trying to compile "quick example" from https://pqxx.org/libpqxx/ with
g++ -lpq -lpqxx example.cpp
gives a bunch of errors. Adding -std flags to the example or libpqxx compile doesn't help.The text was updated successfully, but these errors were encountered: