Undefined ref to 'function<void ()()>::operator()() const' when called from free function defined in cc file.

Paolo Carlini paolo.carlini@oracle.com
Fri Aug 29 19:57:00 GMT 2008


Hi Chris,
> I was working on call_once and got this odd error:
>
> bin/ld: lib64/libstdc++.so: undefined reference to 'std::function<void
> ()()>::operator()() const'
> bin/ld: lib64/libstdc++.so: undefined reference to 'std::function<void
> ()()>::function(std::function<void ()()> const&)'
> collect2: ld returned 1 exit status
>   
This is happening *inside* the library.
> Disregarding the actual run-time context here, semantically what could
> be causing this? extern "C" has nothing to do with it it seems. After
> commenting out the construction of __f and the call __f(), the errors
> disappear. I've also added:
>
> _ZSt17__once_proxy_lock;
> _ZSt18__once_proxy_mutex;
> _ZSt19__once_proxy_object;
> __once_proxy;
>   
So, this is not really relevant, I think.
> to gnu.ver as per usual.
>
> "nm mutex.o" shows:
> U _ZNKSt8functionIFvvEEclEv
> U _ZNSt8functionIFvvEEC1ERKS1_
> W _ZNSt8functionIFvvEED1Ev
>   
I suspect this has to do with the fact that the *.cc files are built 
with -fno-implicit-templates. Try to make sure the required 
instantiation actually happens, be explicit?!?

Paolo.



More information about the Libstdc++ mailing list