05/06/21 00:37:02
共有ライブラリを作りたいのですが、うまくいきません、問題点がわかりましたら教えて下さい。
・共有ファイル側makefile(ソースファイル2つあります):
tws.so:tws_envvalue.o tws_time.o
g++ -shared tws_envvalue.o tws_time.o -o tws.so
tws_envvalue.o:tws_envvalue.cpp
g++ -fPIC -c tws_envvalue.cpp -o tws_envvalue.o
tws_time.o:tws_time.cpp
g++ -fPIC -c tws_time.cpp -o tws_time.o
install:
cp -f *.h /usr/include/tws/
cp -f tws.so /usr/lib/
(makeでコンパイルした後make install でsoファイルを移動しています。)
・利用ファイル側
cgi_env.cgi:cgi_env.o
g++ -l /usr/lib/tws.so cgi_env.o -O3 -o cgi_env.cgi
cgi_env.o:cgi_env.cpp
g++ -c cgi_env.cpp -D LINUX -o cgi_env.o
install:
cp cgi_env.cgi ../../public_html/
このようにすると。利用ファイル側コンパイル中
g++ -l /usr/lib/tws.so cgi_env.o -O3 -o cgi_env.cgi
/usr/bin/ld: cannot find -l/usr/lib/tws.so
と出力され、あるはずのtws.soが認識されません。一体何が悪いのでしょうか。
gcc バージョンは 3.2.2 20030222 (Red Hat Linux 3.2.2-5)と出ました。