Giter Site home page Giter Site logo

Comments (9)

KayEss avatar KayEss commented on July 17, 2024

This looks likely to be caused by your build options. Where are you getting the cmake configuration from?

from libpqxx.

jtv avatar jtv commented on July 17, 2024

(Inserted some backticks into your text to stop Github from interpreting bits of the error message as Wiki markup...)

from libpqxx.

jtv avatar jtv commented on July 17, 2024

AFAICS the function in question is clear_result. But that's not a weak symbol — it's declared in result.hxx and defined in result.cxx. There could be a bug in the CMake setup, but perhaps also the pg_result declaration needs to be explicitly exported.

As an experiment, in include/pqxx/forward.hxx, could you replace the struct pg_result; with struct PQXX_LIBEXPORT pg_result; and see if that fixes the warning?

from libpqxx.

sergey-kurenkov avatar sergey-kurenkov commented on July 17, 2024

I have created a test program that reproduce a linker warning on mac:

$ cat mytest/pqxx_test.cpp 
#include <pqxx/pqxx>

int main() {
	pqxx::result r;
}

I cloned the lipqxx repo and built it:
./configure --prefix=$PWD/dist && make && make install

Then I compiled my test program:

$ clang++ --std=c++11 -I $PWD/dist/include -L $PWD/dist/lib mytest/pqxx_test.cpp -lpqxx -lpq
ld: warning: direct access in function 'std::__1::__shared_ptr_pointer<pg_result const*, void ()(pg_result const), std::__1::allocator<pg_result const> >::__get_deleter(std::type_info const&) const' from file '/Users/sergey.kurenkov/src/test_libpqxx/dist/lib/libpqxx.a(result.o)' to global weak symbol 'typeinfo name for void ()(pg_result const)' from file '/var/folders/8k/wmd646w54nb94_rfs6l1rn312bkjmr/T/pqxx_test-a62599.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

In my opinion the warning is caused by using in result.hxx shared_ptr:
using data_pointer = std::shared_ptr<const internal::pq::PGresult>;

from libpqxx.

KayEss avatar KayEss commented on July 17, 2024

You should use the same compile configuration for the configure script as you do for your build (although I believe Jeroen defaults to c++11, it'd still be important if you wanted 14 or even 17).

./configure CXXFLAGS=-std=c++11  --prefix=$PWD/dist

I have often noticed that older versions of clang have some bugs with regard to shared_ptr code generation, but this error doesn't look like one of them.

I've just switched my projects to the latest pqxx and need to fix up some headers, but I'll report back on whether or not I see any warnings when I get a working build again.

from libpqxx.

KayEss avatar KayEss commented on July 17, 2024

I've done some builds (C++14) with the latest code for libpqxx and don't get any warnings on the Mac. However, when I do what you've done I do get the warning.

I'm not using the supplied make files though. I build the libpqxx sources using the same build that I then build the application with, and this ensures that the compile options are exactly alike. Can you try to include the libpqxx sources into your build rather than using make separately?

from libpqxx.

sergey-kurenkov avatar sergey-kurenkov commented on July 17, 2024

Can you try to include the libpqxx sources into your build rather than using make separately?

Look if I add -fvisibility=hidden -fvisibility-inlines-hidden to clang I get no warning:

$ clang++ -fvisibility=hidden -fvisibility-inlines-hidden -g  --std=c++11 -I $PWD/dist/include -L $PWD/dist/lib mytest/pqxx_test.cpp -o mytest/pqxx_test -lpqxx -lpq 
➜  18-02-26 15:07:10 /Users/sergey.kurenkov/src/test_libpqxx git:(master) ✗ 

-fvisibility=hidden -fvisibility-inlines-hidden are options from libpqxx's Makefile.

from libpqxx.

jtv avatar jtv commented on July 17, 2024

It doesn't help that I can't reproduce this on an Ubuntu system. :( @skwllsp, have you tried adding PQXX_LIBEXPORT to that using declaration, to see whether that would convince the compiler to keep the type completely visible for linking?

from libpqxx.

jtv avatar jtv commented on July 17, 2024

Annoying situation: we can't reproduce it, and a warning isn't quite serious enough to warrant a lot of effort. I don't think we're going to get around to it, so I'll just close the issue.

If it comes up again, we can take that as a sign that it deserves more attention.

from libpqxx.

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.