views:

96

answers:

1

Okay so I have the following makefile

CC = g++
#CFLAGS = -g -Wall
CFLAGS = -g
LDFLAGS = -lm

#client : shared.lib

#server : shared.lib

shared : src/shared/opcode.h
$(CC) $(CFLAGS) -I./src/ -I./lib/boost/ -L./lib/boost/stage/lib/ -L./lib/win_sdk/ \
    -D_WIN32_WINNT=0x0501 \
    -lWS2_32 \
    -lboost_system-mgw34-mt-1_43 \
    -lboost_thread-mgw34-mt-1_43 \
    -lboost_date_time-mgw34-mt-1_43 \
    -o shared.lib \
        src/shared/AsyncSocket.cpp \
        src/shared/Log.cpp \
        src/shared/ObjectAccessor.cpp \
        src/shared/packet.cpp

And get the following errors when running make

C:\Users\Stein\AppData\Local\Temp\cckqwik5.o: In function `_static_initialization_and_destruction_0':
F:\Developing\Alpine\Source/./lib/boost/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()'
F:\Developing\Alpine\Source/./lib/boost/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_generic_category()'
F:\Developing\Alpine\Source/./lib/boost/boost/system/error_code.hpp:214: undefined reference to `boost::system::get_generic_category()'
F:\Developing\Alpine\Source/./lib/boost/boost/system/error_code.hpp:215: undefined reference to `boost::system::get_generic_category()'
F:\Developing\Alpine\Source/./lib/boost/boost/system/error_code.hpp:216: undefined reference to `boost::system::get_system_category()'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o: In function `error_code':
F:\Developing\Alpine\Source/./lib/boost/boost/system/error_code.hpp:315: undefined reference to `boost::system::get_system_category()'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/error.hpp:218: undefined reference to `boost
::system::get_system_category()'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:53: undefined referenc
e to `WSASetLastError@4'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:775: undefined referen
ce to `WSAAddressToStringA@20'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:1889: undefined refere
nce to `ntohl@4'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:1894: undefined refere
nce to `htonl@4'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:65: undefined referenc
e to `WSAGetLastError@0'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:473: undefined referen
ce to `getsockopt@20'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/socket_ops.hpp:562: undefined referen
ce to `getpeername@12'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o: In function `do_init':
F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/winsock_init.hpp:51: undefined reference to `WSAStartup@8'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o: In function `~do_init':
F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/winsock_init.hpp:56: undefined reference to `WSACleanup@0'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/win_iocp_socket_service.hpp:1707: und
efined reference to `WSASend@28'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/win_iocp_socket_service.hpp:1708: und
efined reference to `WSAGetLastError@0'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/win_iocp_socket_service.hpp:1761: und
efined reference to `WSARecv@28'
C:\Users\Stein\AppData\Local\Temp\cckqwik5.o:F:\Developing\Alpine\Source/./lib/boost/boost/asio/detail/win_iocp_socket_service.hpp:1762: und
efined reference to `WSAGetLastError@0'
d:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.5.0/../../../libmingw32.a(main.o):main.c:(.text+0xa3): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
make: *** [shared] Error 1

What am I doing wrong, I'm quite new when it comes to using makefiles but it doesn't make sense, I have boost_system included and ws2_32 so it should not have problems with those.

+1  A: 

Check that the capitals used in ws2_32 is ok.

Peter Jansson
The file I included was spelled WS2_32.Lib but I have the suspicion it might be the wrong winsock file. Where would I find the correct one normally ?
Xeross
You could also check that the library search paths (-L) really are found by g++, e.g. change ./ into $(CURDIR)/
Peter Jansson
The libraries are in your MinGW hiearchy.
Peter Jansson
I'll try again, I guess.
Xeross