[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#763369: marked as done (g++-4.9: Linker failure when using str::thread)



Your message dated Wed, 05 Nov 2014 14:53:07 +0100
with message-id <545A2BC3.6040908@debian.org>
and subject line Re: Bug#763369: g++-4.9: Linker failure when using str::thread
has caused the Debian Bug report #763369,
regarding g++-4.9: Linker failure when using str::thread
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
763369: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763369
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: g++-4.9
Version: 4.9.1-15
Severity: normal

Dear Maintainer,

when compiling a C++11 program that uses std::thread, I get the following
linker failure:

$ g++ -std=c++11 threadtest.cpp -o threadtest
/tmp/cc2mc1l4.o: In function `std::thread::thread<void (*)()>(void (*&&)())':
threadtest.cpp:(.text._ZNSt6threadC2IPFvvEIEEEOT_DpOT0_[_ZNSt6threadC5IPFvvEIEEEOT_DpOT0_]+0x1e): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status

The program used to compile and run just fine around a month ago.
The problem also affects clang++. I will attach a small example program.

The program compiles and runs fine when I add "-pthread" to the flags
(this work-around applies to both g++ and clang++). However, it was
my understanding (and expectation) that this flag is no longer needed
with C++11 - in fact, I shouldn't even know that it's pthreads
implementing the std::thread class.

Kind regards
Ralf

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (100, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.15.10 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages g++-4.9 depends on:
ii  gcc-4.9            4.9.1-15
ii  gcc-4.9-base       4.9.1-15
ii  libc6              2.19-11
ii  libcloog-isl4      0.18.2-1
ii  libgmp10           2:6.0.0+dfsg-6
ii  libisl10           0.12.2-2
ii  libmpc3            1.0.2-1
ii  libmpfr4           3.1.2-1
ii  libstdc++-4.9-dev  4.9.1-15
ii  zlib1g             1:1.2.8.dfsg-2

g++-4.9 recommends no packages.

Versions of packages g++-4.9 suggests:
pn  g++-4.9-multilib    <none>
ii  gcc-4.9-doc         4.9.1-2
pn  libstdc++6-4.9-dbg  <none>

-- no debconf information
#include <thread>
#include <iostream>

void thread_fun(void)
{
    std::cout << "In Thread" << std::endl;
}

int main(void)
{
    std::thread(&thread_fun).join();
    return 0;
}

--- End Message ---
--- Begin Message ---
Am 29.09.2014 um 20:28 schrieb Ralf Jung:
> Package: g++-4.9
> Version: 4.9.1-15
> Severity: normal
> 
> Dear Maintainer,
> 
> when compiling a C++11 program that uses std::thread, I get the following
> linker failure:
> 
> $ g++ -std=c++11 threadtest.cpp -o threadtest
> /tmp/cc2mc1l4.o: In function `std::thread::thread<void (*)()>(void (*&&)())':
> threadtest.cpp:(.text._ZNSt6threadC2IPFvvEIEEEOT_DpOT0_[_ZNSt6threadC5IPFvvEIEEEOT_DpOT0_]+0x1e): undefined reference to `pthread_create'
> collect2: error: ld returned 1 exit status
> 
> The program used to compile and run just fine around a month ago.
> The problem also affects clang++. I will attach a small example program.
> 
> The program compiles and runs fine when I add "-pthread" to the flags
> (this work-around applies to both g++ and clang++). However, it was
> my understanding (and expectation) that this flag is no longer needed
> with C++11 - in fact, I shouldn't even know that it's pthreads
> implementing the std::thread class.

this is expected behaviour now. You have to link with -pthread.

--- End Message ---

Reply to: