13
我嘗試建立在使用G ++一個窗口的cygwin平臺的共享庫,後來與另一個CPP文件鏈接它: 我用下面的命令:建設和鏈接共享庫
// generate object file
g++ -g -c -Wall -fPIC beat11.cpp -o beat11.o
// to generate library from the object file
g++ -shared -Wl,-soname,libbeat.so.1 -o libbeat.so.1.0.1 beat11.o -lc
// to link it with another cpp file; -I option to refer to the library header file
g++ -L. -lbeat -I . -o checkbeat checkbeat.cpp
同時連接,下面的錯誤影響了:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld:
cannot find -llibbeat.so.1.0.1
collect2: ld returned 1 exit status
圖書館獲取創建就好了,但我只能找到libbeat.so.1.0.1,不libbeat.so或libbeat.so.1(或者他們不應該在那裏?)
的其他問題一個建議創建一個符號鏈接libbeat.so.1.0.1,但同樣沒有工作
我有同樣的問題和你的評論使用-l:libname.so工作。但是,我不太明白爲什麼它不能與-L -lname一起工作,因爲您說鏈接器應該搜索lib .so。這也是我的理解,它應該工作,但至少與cygwin似乎並非如此。還沒有嘗試與其他編譯器。 –
Devolus
答案在這裏幫助我:http://stackoverflow.com/questions/16154130/cygwin-g-linker-doesnt-find-shared-library – solstice333