作者 主題: 請問如何static link stdc++  (閱讀 9277 次)

0 會員 與 1 訪客 正在閱讀本文。

Anonymous

  • 訪客
請問如何static link stdc++
« 於: 2002-01-04 20:48 »
請問各位大哥如何 static link stdc++ library.

I did :
%g++ my_program.cpp -o my_execution_file -static -LmyLibPatn -lmylib
但是出現
/usr/i386-linux/bin/ld: cannot open -lstdc++: No such file or directory  

似乎失g++找不到stdc++ library.
我找遍我的系統也找不到stdc++ library
是否我必須先建立一個 stdc++ static library?
但是如何建立呢?

Anonymous

  • 訪客
請問如何static link stdc++
« 回覆 #1 於: 2002-01-08 17:39 »
please try those comand

g++ -static -c program.cpp -o program.o
g++ -static program.o /usr/lib/libstdc++.so.2.9  -o program
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
please reference your /usr/lib.

Anonymous

  • 訪客
請問如何static link stdc++
« 回覆 #2 於: 2002-01-11 20:54 »
I tried those command but it still complained can not open -lstdc++ when I
executed the second command.  Then I tried the following commands and they
worked:

1. g++ -static -c program.c -o program.o ( Actually, my program is a c program
not  a c++ program).

2. gcc -static program.o -L$(MY_LIB_PATH) -lmylib -o program
(Here I use gcc instead of g++ and I did not specify the stdc++ library path at all).

Anyway, your hints did help me a lot. Thank you!