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