• ベストアンサー

make中に起こられた、tbbに関するエラーの対応方法が分からないでいます。

皆さん、こんにちは。 C++で書いたソースをmakeしているときに 自分では解決できなかった問題に出会いました。 内容としては makeしているときに、 次に書かれているような「tbb」に関するエラーが出て、 コンパイルが進まないという件なのですが、 どうしたら問題点を解消できるのかが分からないでいます。 エラー内容は以下のとおりです。 ------------------------------------------------------- sim-main.o: In function `tbb::spin_rw_mutex_v3::scoped_lock::upgrade_to_writer()': /usr/include/tbb/spin_rw_mutex.h:118: undefined reference to `tbb::spin_rw_mutex_v3::internal_upgrade()' sim-main.o: In function `tbb::spin_rw_mutex_v3::scoped_lock::acquire(tbb::spin_rw_mutex_v3&, bool)': /usr/include/tbb/spin_rw_mutex.h:108: undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_writer()' /usr/include/tbb/spin_rw_mutex.h:109: undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_reader()' ------------------------------------------------------- 「tbb::spin_rw_mutex_v3」が参照できないよ!と 怒られているのは分かるのですが、 「spin_rw_mutex_v3」は、 同ファイル内の「spin_rw_mutex_v3」クラスで、 しっかり記述されているし、 この先、 どう自分が対応してあげればいいか? 分からないでいます。 何かアドバイスいただけると、 大変ありがたいです。 宜しくお願い致します。 開発環境はFedora9を利用しております。 42 class spin_rw_mutex_v3 {     ・     ・     ・ 72 public: 73 //! Construct unacquired mutex. 74 spin_rw_mutex_v3() : state(0) {} 75 76 #if TBB_DO_ASSERT 77 //! Destructor asserts if the mutex is acquired, i.e. state is zero. 78 ~spin_rw_mutex_v3() { 79 __TBB_ASSERT( !state, "destruction of an acquired mutex"); 80 }; 81 #endif /* TBB_DO_ASSERT */ 82 83 //! The scoped locking pattern 84 /** It helps to avoid the common problem of forgetting to release lock. 85 It also nicely provides the "node" for queuing locks. */ 86 class scoped_lock : private internal::no_copy { 87 public: 88 //! Construct lock that has not acquired a mutex. 89 /** Equivalent to zero-initialization of *this. */ 90 scoped_lock() : mutex(NULL) {} 91 92 //! Acquire lock on given mutex. 93 /** Upon entry, *this should not be in the "have acquired a mutex" state. */ 94 scoped_lock( spin_rw_mutex& m, bool write = true ) : mutex(NULL) { 95 acquire(m, write); 96 } 97 98 //! Release lock (if lock is held). 99 ~scoped_lock() { 100 if( mutex ) release(); 101 } 102 103 //! Acquire lock on given mutex. 104 void acquire( spin_rw_mutex& m, bool write = true ) { 105 __TBB_ASSERT( !mutex, "holding mutex already" ); 106 is_writer = write; 107 mutex = &m; 108 if( write ) mutex->internal_acquire_writer(); 109 else mutex->internal_acquire_reader(); 110 } 111 112 //! Upgrade reader to become a writer. 113 /** Returns true if the upgrade happened without re-acquiring the lock and false if opposite */ 114 bool upgrade_to_writer() { 115 __TBB_ASSERT( mutex, "lock is not acquired" ); 116 __TBB_ASSERT( !is_writer, "not a reader" ); 117 is_writer = true; 118 return mutex->internal_upgrade(); 119 }

質問者が選んだベストアンサー

  • ベストアンサー
  • php504
  • ベストアンサー率42% (926/2160)
回答No.7

g++ -DNDEBUG -O4 -D_PTHREADS -g -O0 -Wall -DDEBUG -L/usr/local/lib この-L/usr/local/libで/usr/local/lib/libtbb.soをリンクしてそうですね 同じ名前ですがまったく別のライブラリかもしれません ↓ http://sourceforge.net/projects/teambb (TeamBlibbityBlabbity)

c_iamok
質問者

お礼

php504さん! どんぴしゃでした! ありがとうございました! 「/usr/lib/libtbb.so」をコンパイルより除外したら、 見事に成功しました! どうもありがとうございます!

その他の回答 (6)

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.6

「どのようなコマンドでリンクしているか」を make が表示しているはずなので, それをあげてもらえますか? あと, (リンクしているライブラリが /usr/lib/libtbb.so だとして) nm /usr/lib/libtbb.so | c++filt | grep tbb::spin_rw_mutex_v3::internal_upgrade の結果はどうなっていますか?

c_iamok
質問者

お礼

適切な方策を検討するうえでの参考になりました。 アドバイスありがとうございました!

  • php504
  • ベストアンサー率42% (926/2160)
回答No.5

あ、でも/usr/libは標準でパス通ってますよね /usr/libにlibtbb.soはありますか libtbb.so.2 とかじゃだめですよ

c_iamok
質問者

補足

ご説明ありがとうございました! 「libtbb.so」を探してみまたら、 こんな感じになっていました! -------------------------- # find / -name libtbb.so /lib/libtbb-0.2/.libs/libtbb.so /usr/local/lib/libtbb.so /usr/lib/libtbb.so --------------------------

  • php504
  • ベストアンサー率42% (926/2160)
回答No.4

ライブラリはincludeじゃなくてlibディレクトリです -L/usr/include/tbb/ ↓ -L/usr/lib

  • chie65535
  • ベストアンサー率43% (8514/19356)
回答No.3

>Makefile内の中で、以下の行に記述がある状態ではあります。 tbbライブラリは「正しいライブラリパス」に置いてありますか? 「リンカやldやmakeが探してくれない場所」に置いてしまうと「無いのと一緒」ですから、makefileに何が書いてあっても意味がありません。

c_iamok
質問者

補足

親切な解説、大変感謝しております。 ありがとうございます。 Makefileの中で、 以下のように、 LIBSの部分で、 必要となるライブラリを指定してはいるのですが、 -------------------------------------------------- LIBS = -lpthread -lgmpxx -lcrypto -ltbb -L/usr/include/tbb/ -------------------------------------------------- やはり、同様のエラーが出てきてしまう状態ではあります。 tbbの位置を確認したところでは、 Makefileで指定したとおり、以下のディレクトリには、 あるみたいではあるようです。 #find / -name tbb # cd /usr/include/tbb/ 確かに、tbb下に、色々とtbbのファイルが存在はする。 g++ -DNDEBUG -O4 -D_PTHREADS -g -O0 -Wall -DDEBUG -L/usr/local/lib -o sim-main.o ../../ctl/lib/libctl.a -lpthread -lgmpxx -lcrypto -ltbb -L/usr/include/tbb/ sim-main.o: In function `tbb::spin_rw_mutex_v3::scoped_lock::upgrade_to_writer()': /usr/include/tbb/spin_rw_mutex.h:118: undefined reference to `tbb::spin_rw_mutex_v3::internal_upgrade()' sim-main.o: In function `tbb::spin_rw_mutex_v3::scoped_lock::acquire(tbb::spin_rw_mutex_v3&, bool)': /usr/include/tbb/spin_rw_mutex.h:108: undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_writer()' /usr/include/tbb/spin_rw_mutex.h:109: undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_reader()'

  • chie65535
  • ベストアンサー率43% (8514/19356)
回答No.2

>「tbb::spin_rw_mutex_v3」が参照できないよ!と >怒られているのは分かるのですが、 違います。 sim-main.o: In function `tbb::spin_rw_mutex_v3::scoped_lock::upgrade_to_writer()': /usr/include/tbb/spin_rw_mutex.h:118: undefined reference to `tbb::spin_rw_mutex_v3::internal_upgrade()' は 「tbb::spin_rw_mutex_v3::scoped_lock::upgrade_to_writer()の中、ソースの118行目でtbb::spin_rw_mutex_v3::internal_upgrade()を呼んでいるが、tbbのspin_rw_mutex_v3にはinternal_upgrade()関数は存在せず、関数の実体が無いから呼び出せない」 って意味。 同様に sim-main.o: In function `tbb::spin_rw_mutex_v3::scoped_lock::acquire(tbb::spin_rw_mutex_v3&, bool)': /usr/include/tbb/spin_rw_mutex.h:108: undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_writer()' /usr/include/tbb/spin_rw_mutex.h:109: undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_reader()' は 「tbb::spin_rw_mutex_v3::scoped_lock::acquire(tbb::spin_rw_mutex_v3&, bool)の中、ソースの108行目、109行目でtbb::spin_rw_mutex_v3::internal_acquire_writer()とtbb::spin_rw_mutex_v3::internal_acquire_reader()を呼んでいるが、tbbのspin_rw_mutex_v3にはinternal_acquire_writer()とinternal_acquire_reader()の関数は存在せず、関数の実体が無いから呼び出せない」 って意味。 「リンク時に関数の実体が見付からない」って事だから、ヘッダとかでちゃんと定義はされてて、ライブラリを呼ぶ外部参照になっているので、コンパイルは通ってる。 で、コンパイル後のオブジェクトバイナリをリンクして実行ファイルを作成する際に、外部参照(ライブラリ呼び出し)されてる internal_upgrade() internal_acquire_writer() internal_acquire_reader() の関数の実体が無いって言ってエラーになっている。 「ヘッダには定義されてるけど、リンク時に関数の実体が見付からない」って事は「makefileのライブラリ指定で、必要なライブラリファイルを指定し忘れてる」って事。 makefileのリンクコマンドを再確認しましょう。 あと、エラーメッセージは「適当に斜め読み」しないで「何が書いてあるのか、じっくりちゃんと読む」ようにしましょう。 「sim-main.o:」って部分からだけでも「エラーはsim-main.cのコンパイル段階ではなく、sim-main.oをリンクして実行ファイル(a.out)を作る時に起きている」って事が判ります。 「.o」の2文字だけで、これだけの事が判るんですから、エラーメッセージは「穴があくほど良く見る」ようにしましょう。

  • php504
  • ベストアンサー率42% (926/2160)
回答No.1

Makefileでtbbライブラリをリンクしてますか(-ltbbの記述がありますか)

c_iamok
質問者

補足

アドバイスありがとうございます。 とてもありがたいです。 Makefile内の中で、以下の行に記述がある状態ではあります。 --------------------- LDFLAGS=-ltbb LIBS=-ltbb ---------------------

関連するQ&A

  • 焼く時に毎回エラーがでるんです

    このような内容でDeviceIoContro(FSCTL_LOCK_VOLUME)Failed! Device:[1:0:0]PBDS DVD+-RW DH-16W1S 2D14 (F:) (ATA) Unable to lock volume for exclusive access. Reason: アクセスが拒否されました。 解決方法教えてください。

  • 【DVD Decrypter】エラー

    【DVD Decrypter】エラー 読み込んだDVDのMDSファイルをDVD-Rに書き込もうとすると、 DeviceIoControl(FSCTL_LOCK_VOLUME) Failed! Device: [0:0:0] PIONEER DVD-RW DVR-K16M 1.00 (G:) (ATA) Unable to lock volume for exclusive access. Reason: アクセスが拒否されました。 中止 再試行 無視 というエラーっぽいものが出てきます。 無視して書き込んでDVD内容を確認すると問題ないようですが、これはどういう意味でしょうか教えてください。

  • 条件変数を用いた有限バッファ問題を考えています。

    皆さんこんにちは。 当方、プログラミングを勉強中の学生です。 条件変数を用いた有限バッファ問題を考えております。 以下に示すソースにおいて、関数produce()は1から1000までの整数を順に生成し、関数consume()はバッファから取り出した値の合計(1から1000までの和、500500となる)を求めるようプログラミングしているつもりなのですが、コンパイルして実行すると思ったような結果となりません。 どこが間違っているかご教授いただければ幸いです。 よろしくお願い致します。 以下、ソースとなります。 #include <stdio.h> #include <pthread.h> #define N 5 int buffer[N]; int inptr = 0, outptr = 0; int count = 0; int i = 0; int j = 0; int sum = 0; pthread_cond_t full = PTHREAD_COND_INITIALIZER; pthread_cond_t empty = PTHREAD_COND_INITIALIZER; pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; int produce (void) { i += 1; return i; } void consume (int x) { j += 1; sum += x; } void *producer(void *arg) { int data; for (;;) { if (i >= 1000) break; data = produce(); pthread_mutex_lock(&lock); while (count > N) pthread_cond_wait(&full, &lock); count = count + 1; buffer[inptr] = data; inptr = (inptr + 1) % N; pthread_mutex_unlock(&lock); pthread_cond_signal(&empty); } } void *consumer(void *arg) { int data; for (;;) { if (j >= 1000) break; pthread_mutex_lock(&lock); while (count == 0) pthread_cond_wait(&empty, &lock); count = count - 1; data = buffer[outptr]; outptr = (outptr + 1) % N; pthread_mutex_unlock(&lock); pthread_cond_signal(&full); consume(data); } } int main() { pthread_t a, b; pthread_create(&a, NULL, producer, NULL); pthread_create(&b, NULL, consumer, NULL); pthread_join(a, NULL); pthread_join(b, NULL); printf("sum = %d\n", sum); return 0; }

  • Internal Server Error が出る

    Internal Server Error が出てしまいます. エラーログをみると [Fri Nov 27 12:34:03 2009] [notice] Apache configured -- resuming normal operations [Fri Nov 27 12:34:03 2009] [notice] Server built: Jan 17 2008 22:58:29 [Fri Nov 27 12:34:03 2009] [notice] Parent: Created child process 2496 [Fri Nov 27 12:34:03 2009] [notice] Child 2496: Child process is running [Fri Nov 27 12:34:03 2009] [notice] Child 2496: Acquired the start mutex. [Fri Nov 27 12:34:03 2009] [notice] Child 2496: Starting 250 worker threads. [Fri Nov 27 12:34:17 2009] [error] [client 127.0.0.1] Premature end of script headers: index.rb [Fri Nov 27 12:34:17 2009] [error] [client 127.0.0.1] C:/var/www/cgi-bin/computer/index.rb:7:in `require': no such file to load -- lib/constant (LoadError)\r [Fri Nov 27 12:34:17 2009] [error] [client 127.0.0.1] \tfrom C:/var/www/cgi-bin/computer/index.rb:7\r となっていますが原因がわかりません・・・

  • phpのファイル操作について

    ファイル操作について、上手く作動しなくて困っています。 PHPは今勉強している最中で、ほとんど初心者です。 ページを開いたときに、テキストファイルに書き込む操作をしたいのですが、うまくいきません。 ローカルホストで試したときには、きちんと書き込むことができるのですが、 借りているサーバーで試すと、”ファイル書き込み失敗”と出てしまいます。 http://ribbon.to/ こちらのサーバーを借りています。 原因がわからないので、少しでもいいのでお力をいただきたいです。 よろしくお願いします。 ここからPHPです $folder = "hoge"; if (!file_exists($folder)) { mkdir($folder,0733); } $filename = "$folder/".date("m").".txt"; $fh = @fopen($filename, "a"); if ($fh == FALSE) { exit("ファイル書き込み失敗"); }else { // 排他ロック flock($fh, LOCK_EX); // メッセージ作成 $msg = date("Y/m/d H:i:s"); // 書き出し fputs($fh, $msg); // ロックを解除 flock($fh, LOCK_UN); // ファイルを閉じる fclose($fh); }

    • 締切済み
    • PHP
  • eclipseのworkspaseの削除ができない理由

    Fedora5にEclipseをインストールして、運用をしようとすると、 起動する度に以前作ったworkspaceが「workspaceが使用中であるか作成できません。」 と表示されます。 そこで、既存のworkspaceを削除しようと思うのですが、どうしてもできません。モードの変更もできません。 .lockをどうしても消せないのですが、何かいい方法ありましたら、お願いします。 [maiko100@computer ~]$ ls Desktop MyJava pasname workspace GNUstep rpm workspace2 Microsoft Xrootenv.0 mbox upgrade-log workspace3 [maiko100@computer ~]$ ls -al workspace 合計 2 drwxrwxrwx 2 maiko100 gsky 64 12月 19 13:10 . drwx------ 2 maiko100 gsky 64 12月 19 16:29 .. drwxrwxrwx 2 maiko100 gsky 64 12月 19 14:18 .metadata [maiko100@computer ~]$ ls -al workspace/.metadata 合計 1 drwxrwxrwx 2 maiko100 gsky 64 12月 19 14:18 . drwxrwxrwx 2 maiko100 gsky 64 12月 19 13:10 .. -rw-r--r-- 1 maiko100 gsky 0 12月 19 13:42 .lock [maiko100@computer ~]$ chmod 777 workspace/.metadata/.lock chmod: cannot access `workspace/.metadata/.lock': 許可がありません [maiko100@computer ~]$ rm -f workspace/.metadata/.lock rm: cannot remove `workspace/.metadata/.lock': 許可がありません [maiko100@computer ~]$

  • 500 Internal Server Error

    先ほど YouTubeでSuzuの「You can do it!」のPVを見ようと思ったら 500 Internal Server Errorというエラーが発生しました。下のメッセージ欄には「Sorry, something went wrong. A team of highly trained monkeys has been dispatched to deal with this situation. If you see them, show them this information:」と表示されていていました。メッセージの下には文字化けした文字がたくさん並んでいました。 これはウイルスによる原因ではないでしょうか? システムやネットワークに詳しい技術者もしくはSEの方教えてください。今すぐにその情報を手に入れたいです。 問題になった URLはこちら↓ http://www.youtube.com/watch?v=OrIxP5LGIfI

  • VBA マクロ処理時間の短縮について

    下記のコードを作りましたが、マクロを実行すると砂時計マークが表示されて、処理が終了するまでに30秒くらいかかります。 コードを変更して、マクロ処理時間を短縮する事はできないでしょうか? Sub A列のコピー() Dim rw2 As Long Dim rw1 As Long Dim newdate As Date With Worksheets("sheet1") rw2 = .cells(.Rows.Count, "c").End(xlUp).Row newdate = .Range("c" & rw2).value For rw1 = rw2 - 1 To 1 Step -1 If .Range("c" & rw1).value <> newdate Then Exit For Next rw1 .Range(.cells(rw1 + 1, 1), .cells(rw2, 1)).Copy Worksheets("sheet2").Range("v6").PasteSpecial xlValue If rw1 + 26 <= rw2 Then .Range(.cells(rw1 + 26, 1), .cells(rw2, 1)).Copy Worksheets("sheet2").Range("v40").PasteSpecial xlValue Application.CutCopyMode = False End If Application.CutCopyMode = False End With End Sub 各セルは、6000行くらいまで表示されています。  よろしくお願いします。

  • 和訳をお願いします。

    和訳をお願いします。 ロックバンドのザ・カーズについて下記のように聞かれているのですが分かりません。 「thank you take care and looking foreward to them hey if you ever come across live CARS at SUN PLAZA HALL OR OSAKA in 1980 let me know I have tapes from JAPAN that year but always looking to upgrade and if THE CARS were on JAPAN TV that year too anything video wise take care.」 よろしくお願いします。

  • こどもネットタイマー2の機器一覧500エラー

    WRC-からはじまり-Sの型番ルーターWiFi、ソフトウェアバージョンv1.06を使用してます。 突然、管理画面のこどもネットタイマー、機器一覧から下記エラーが出てます。再起動やファームウェア更新にも解決できず、対処方法を教えて頂けると幸いです。 宜しくお願いします。 Status: 500 Internal Server Error /usr/lib/lua/luci/dispatcher.lua:503: Failed to execute template dispatcher target for entry '/admin/ghbk/details/timer/01'. The called action terminated with an exception: /usr/lib/lua/luci/template.lua:104: Failed to execute template 'ghbk/timer01'. A runtime error occured: /usr/bin/kidstimerlist.lua:46: table index is nil stack traceback: [C]: in function 'assert' /usr/lib/lua/luci/dispatcher.lua:503: in function 'dispatch' /usr/lib/lua/luci/dispatcher.lua:250: in function ※OKWAVEより補足:「エレコム株式会社の製品」についての質問です。

専門家に質問してみよう