Hi,
I'm running Code::Blocks on Ubuntu. I've been having some problems getting threads to work with C++, so I thought I'd try the example code I have for C. The code compiles and runs fine if I use the command line. However, when I try to compile the same file in Code::Blocks, the linker complains about an undefined reference to pthread_create. I've tried adding in various defines, but I've not got anywhere with it - can someone tell me where I'm going wrong?
The output is:
Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : /home/tika/Projects/Test/
--------------------------------------------------------------------------------
Switching to target: default
Linking console executable: /home/tika/Projects/Test/test
.objs/main.o: In function `main':
main.c:(.text+0x2d): undefined reference to `pthread_create'
main.c:(.text+0x73): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
It makes sense to ask about the problem I was having with the C++ version too. The code compiled, but the pthread_create function didn't start the thread. Again, can someone tell me where I'm going wrong?
Thanks,
Rachel.