SORU
19 EKİM 2013, CUMARTESİ


Derleme g ile kod çoklu

Kolay bir kod daha var:

#include <iostream>
#include <thread>

void worker()
{
    std::cout << "another thread";
}

int main()
{
    std::thread t(worker);
    std::cout << "main thread" << std::endl;
    t.join();
    return 0;
}

ben hala g ile çalıştırmak için derleme yapamazsınız ama.

Daha fazla bilgi için:

$ g   --version
g   (Ubuntu/Linaro 4.8.1-10ubuntu8) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Komut derlemek için:

$ g   main.cpp -o main.out -pthread -std=c  11

Çalışan:

$ ./main.out 
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)

Ve şimdi sıkışıp kaldım. İnternet üzerinden ilgili her konuya tavsiye yakalamışken -pthread ekleme zaten.

Neyi yanlış yapıyorum?

PS: yeni ubuntu 13.10 bir montaj. Sadece g paket chromium vb gibi yüklü ve küçük şeyler

PPS:

$ ldd ./a.out 
linux-vdso.so.1 => (0x00007fff29fc1000) 
libstdc  .so.6 => /usr/lib/x86_64-linux-gnu/libstdc  .so.6 (0x00007fb85397d000) 
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb853767000) 
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb85339e000) 
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb85309a000) 
/lib64/ld-linux-x86-64.so.2 (0x00007fb853c96000)

PPP: clang (v3.2) ve gayet iyi çalışır derler

PPPPS: çocuklar, bir değil What is wrong with this use of std::thread? . kopyası

PPPPPS:

$ dpkg --get-selections | grep 'libc.*dev'
libc-dev-bin                    install
libc6-dev:amd64                 install
libclang-common-dev             install
linux-libc-dev:amd64                install

CEVAP
19 EKİM 2013, CUMARTESİ


Cevap SO C chat gibi bir üyesi tarafından sağlanmıştır.

Bu davranış gcc bug bir neden gibi görünüyor.

Çözüm bu hata ile tartışma son yorum sağladıyokçalışma ve sorunu çözdü:

-Wl,--no-as-needed

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 3DS Max Tutorials

    3DS Max Tuto

    4 AĞUSTOS 2013
  • Sali Kaceli

    Sali Kaceli

    24 ŞUBAT 2009
  • Videojug

    Videojug

    25 EKİM 2006