Error compiling Master Server on free ubuntu EC2 instance

I’m trying to make my own Master Server, so I make a free Ubuntu EC2 instance and scp’d the zip file across. Then I unzipped it into a new directory. I then installed make using sudo apt-get install make and finally ran it. But I get this error message:

g++ -ggdb -I. -IRakNet/Sources -ICommon -Wall -lpthread -DUNITY_MASTERSERVER Common/Log.o Common/Utility.o RakNet/Sources/RakNetworkFactory.o RakNet/Sources/BitStream.o RakNet/Sources/GetTime.o RakNet/Sources/RakPeer.o RakNet/Sources/BitStream_NoTemplate.o RakNet/Sources/RakSleep.o RakNet/Sources/CheckSum.o RakNet/Sources/Rand.o RakNet/Sources/ReliabilityLayer.o RakNet/Sources/LinuxStrings.o RakNet/Sources/ConsoleServer.o RakNet/Sources/Router.o RakNet/Sources/DS_BytePool.o RakNet/Sources/MessageFilter.o RakNet/Sources/SHA1.o RakNet/Sources/DS_ByteQueue.o RakNet/Sources/SimpleMutex.o RakNet/Sources/DS_HuffmanEncodingTree.o RakNet/Sources/NetworkIDManager.o RakNet/Sources/SocketLayer.o RakNet/Sources/DS_Table.o RakNet/Sources/NetworkIDObject.o RakNet/Sources/StringCompressor.o RakNet/Sources/DataBlockEncryptor.o RakNet/Sources/StringTable.o RakNet/Sources/DataCompressor.o RakNet/Sources/PacketFileLogger.o RakNet/Sources/SystemAddressList.o RakNet/Sources/DirectoryDeltaTransfer.o RakNet/Sources/PacketLogger.o RakNet/Sources/TCPInterface.o RakNet/Sources/EmailSender.o RakNet/Sources/TableSerializer.o RakNet/Sources/EncodeClassName.o RakNet/Sources/RPCMap.o RakNet/Sources/TelnetTransport.o RakNet/Sources/ExtendedOverlappedPool.o RakNet/Sources/RakNetCommandParser.o RakNet/Sources/ThreadsafePacketLogger.o RakNet/Sources/FileList.o RakNet/Sources/RakNetStatistics.o RakNet/Sources/_FindFirst.o RakNet/Sources/FileListTransfer.o RakNet/Sources/RakNetTransport.o RakNet/Sources/rijndael.o RakNet/Sources/FileOperations.o RakNet/Sources/RakNetTypes.o RakNet/Sources/BigInt.o RakNet/Sources/CCRakNetUDT.o RakNet/Sources/RakNetSocket.o RakNet/Sources/RakString.o RakNet/Sources/RSACrypt.o RakNet/Sources/RakMemoryOverride.o RakNet/Sources/SignaledEvent.o RakNet/Sources/SuperFastHash.o RakNet/Sources/PluginInterface2.o RakNet/Sources/Itoa.o RakNet/Sources/RakThread.o RakNet/Sources/LightweightDatabaseCommon.o RakNet/Sources/LightweightDatabaseServer.o MasterServer.cpp -o MasterServer
MasterServer.cpp:28:17: warning: deprecated conversion from string constant to âchar*â [-Wwrite-strings]
MasterServer.cpp: In function âint main(int, char**)â:
MasterServer.cpp:259:13: warning: the address of âpidFileâ will always evaluate as âtrueâ [-Waddress]
RakNet/Sources/SignaledEvent.o: In function `SignaledEvent::InitEvent()':
SignaledEvent.cpp:(.text+0x81): undefined reference to `pthread_mutexattr_init'
RakNet/Sources/SignaledEvent.o: In function `SignaledEvent::CloseEvent()':
SignaledEvent.cpp:(.text+0xf0): undefined reference to `pthread_mutexattr_destroy'
RakNet/Sources/RakThread.o: In function `RakNet::RakThread::Create(void* (*)(void*), void*, int)':
RakThread.cpp:(.text+0x54): undefined reference to `pthread_attr_setstacksize'
RakThread.cpp:(.text+0x7d): undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make: *** [MasterServer] Error 1

Why has this happened, do I need to install any other software in order to make it compile?

I have tried to install libpthread-workqueue-dev and libpthread-stubs0-dev and neither fixed the problem.

I found the fix. This happens because the Makefile does not link the pthreads while compiling. To fix add -lpthreads to the line

$(PROGRAMNAME): $(COMMON_OBJECTS) $(RAKNET_OBJECTS)
        $(CC) $(DEBUG) -I$(INCLUDE) -I$(RAKNET_INCLUDE) -I$(COMMON_INCLUDE) $(CF               LAGS) $(COMMON_OBJECTS) $(RAKNET_OBJECTS) $(PROGRAMSOURCES) -o $(PROGRAMNAME)

I have manged to compile it making the following changes:

Diff file