2014-12-02 85 views
1

我試圖將編譯分解爲這四個步驟,但最後一個對我來說似乎有問題。ld:無法找到-lstdC++

cpp hello.cpp > hello.i 
g++ -S hello.i 
as -o hello.o hello.s 
ld -o hello hello.o -lstdc++ 

我搜索了herehere這個問題,但沒有幫助。

在詳細模式下運行給我

attempt to open hello.o succeeded 
hello.o 
attempt to open /usr/i686-linux-gnu/lib32/libstdc++.so failed 
attempt to open /usr/i686-linux-gnu/lib32/libstdc++.a failed 
attempt to open //usr/local/lib32/libstdc++.so failed 
attempt to open //usr/local/lib32/libstdc++.a failed 
attempt to open //lib32/libstdc++.so failed 
attempt to open //lib32/libstdc++.a failed 
attempt to open //usr/lib32/libstdc++.so failed 
attempt to open //usr/lib32/libstdc++.a failed 
attempt to open //usr/local/lib/i386-linux-gnu/libstdc++.so failed 
attempt to open //usr/local/lib/i386-linux-gnu/libstdc++.a failed 
attempt to open //usr/local/lib/libstdc++.so failed 
attempt to open //usr/local/lib/libstdc++.a failed 
attempt to open //lib/i386-linux-gnu/libstdc++.so failed 
attempt to open //lib/i386-linux-gnu/libstdc++.a failed 
attempt to open //lib/libstdc++.so failed 
attempt to open //lib/libstdc++.a failed 
attempt to open //usr/lib/i386-linux-gnu/libstdc++.so failed 
attempt to open //usr/lib/i386-linux-gnu/libstdc++.a failed 
attempt to open //usr/lib/libstdc++.so failed 
attempt to open //usr/lib/libstdc++.a failed 
ld: cannot find -lstdc++ 

有什麼建議?提前致謝。

+0

'G ++ HELLO.CPP輪候冊, - verbose'將得到GCC告訴你在哪裏它的發現'的libstdC++' 。這應該讓你開始弄清楚如何讓'ld'找到它。 – 2014-12-02 07:02:21

回答

4

而不是直接調用鏈接器,嘗試調用它間接通過gccg++

cpp hello.cpp > hello.i 
g++ -S hello.i 
as -o hello.o hello.s 
g++ -o hello hello.o 
+0

我認爲這可能不是間接的......如果我正確記得,'ld'現在是一個不同的工具,爲此目的而棄用。 – Potatoswatter 2014-12-02 04:53:22

+0

其實我的主要目標是學習/學習/處理鏈接器,而不是創建一個可執行文件和'ld'命令讓我爲之哭泣。 – sinister 2014-12-02 05:04:27