From: JonY <10...@gm...> - 2008-03-13 12:23:59
|
fei huang wrote: > hi all: > I have already added -lws2_32 to my LDFLAGS and libws2_32.a is right > at the MinGW lib directory, but > gcc still complains about undefined referneces like "send connect > htons etc..." I printed out the command line > and saw it was correct, any advise please? I get completely > frustrated, even worse than my first experience on Linux. > > below is part of the message: > ... > Socket.o: In function `ZN2ZQ6common6SocketC2Eiii': > E:/ZQProjs/common/Socket.cpp:141: undefined reference to `socket@12' > Socket.o: In function `ZN2ZQ6common6SocketC1Eiii': > E:/ZQProjs/common/Socket.cpp:141: undefined reference to `socket@12' > Socket.o: In function `ZN2ZQ6common6Socket8readLineEPcjm': > E:/ZQProjs/common/Socket.cpp:214: undefined reference to `recv@16' > E:/ZQProjs/common/Socket.cpp:237: undefined reference to `recv@16' > Socket.o: In function `ZN2ZQ6common6Socket9endSocketEv': > E:/ZQProjs/common/Socket.cpp:306: undefined reference to `setsockopt@20' > E:/ZQProjs/common/Socket.cpp:311: undefined reference to `closesocket@4' > Socket.o: In function `ZN2ZQ6common6Socket12connectErrorEv': > E:/ZQProjs/common/Socket.cpp:321: undefined reference to `WSAGetLastError@0' > Socket.o: In function `ZN2ZQ6common6Socket12setBroadcastEb': > E:/ZQProjs/common/Socket.cpp:400: undefined reference to `setsockopt@20' > Socket.o: In function `ZN2ZQ6common6Socket12setKeepAliveEb': > E:/ZQProjs/common/Socket.cpp:411: undefined reference to `setsockopt@20' > Socket.o: In function `ZN2ZQ6common6Socket10setRoutingEb': > E:/ZQProjs/common/Socket.cpp:434: undefined reference to `setsockopt@20' > Socket.o: In function `ZN2ZQ6common6Socket10setNoDelayEb': > E:/ZQProjs/common/Socket.cpp:446: undefined reference to `setsockopt@20' > Socket.o: In function `ZN2ZQ6common6Socket13setTimeToLiveEh': > E:/ZQProjs/common/Socket.cpp:497: undefined reference to `setsockopt@20' > Socket.o:E:/ZQProjs/common/Socket.cpp:517: more undefined references > to `setsockopt@20' follow > Socket.o: In function `ZN2ZQ6common6Socket9isPendingENS1_7PendingEm': > E:/ZQProjs/common/Socket.cpp:544: undefined reference to `select@20' > E:/ZQProjs/common/Socket.cpp:547: undefined reference to `select@20' > E:/ZQProjs/common/Socket.cpp:550: undefined reference to `select@20' > E:/ZQProjs/common/Socket.cpp:555: undefined reference to `__WSAFDIsSet@8' > > and main part of my command line > g++ -fPIC -shared -fvisibility=hidden -L. -LE:\projs\lib > -LE:\Expat2.0.1\Bin -LE:\projs/bin -lexpat -lws2_32 -lrpcrt4 -lversion > -o libCommon.so Exception.o Log.o expatxx.o InetAddr.o Socket.o > Scheduler.o > > my env: > > MinGW5.1.3 > WindowsXP > > tks a lot > > fei > Hi, Add the -llib stuff behind your object files. eg: g++ -fPIC -shared -fvisibility=hidden -L. -LE:\projs\lib -LE:\Expat2.0.1\Bin -LE:\projs/bin -o libCommon.so Exception.o Log.o expatxx.o InetAddr.o Socket.o Scheduler.o -lexpat -lws2_32 -lrpcrt4 -lversion |