酷!學園
技術討論區 => 程式討論版 => C/C++程式設計討論區 => 主題作者是: Anonymous 於 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?
但是如何建立呢?
-
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.
-
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!