How do you know you are linking with -lpthread? I can't tell from the information you posted.
Unfortunately this thread boils down to a configuration problem with Code::blocks, something that you could probably have figured out on your own if only you had chosen to learn how to build an application without using an IDE.
If you want to build your application from the command-line (ie from a terminal), go to where your source code resides, and enter the following commands:
P.S. If you have header files for matrix.c and newmalloc.c which are not in the same directory as their corresponding .c files, then use the -I compiler option to specify where they are located at. For example:
gcc -c main.c
gcc -c matrix.c
gcc -c newmalloc.c
gcc main.o matrix.o newmalloc.o -lpthread -lm
P.S. #2 Typically libraries (ie pthread and m) are added to LDFLAGS in a Makefile. Perhaps you can correlate this with whatever Code::Blocks is offering you.
gcc -I../include -c main.c