0
votes

I'm programming c++ in Borland c++ 5.02. I'm trying to run this code:

#include <stdio.h>
#include <pthread.h>

#define NUM 5

main()
{
  pthread_t t1, t2; /* two threads */

  void *print_msg(void *);

  pthread_create(&t1, NULL, print_msg, (void *)"hello");
  pthread_create(&t2, NULL, print_msg, (void *)"world\n");
  pthread_join(t1, NULL);
  pthread_join(t2, NULL);
}

But I get this error:

Info :Compiling C:\BC5\BIN\noname00.cpp

Error: noname00.cpp(2,2):Unable to open include file 'PTHREAD.H'

Error: noname00.cpp(8,15):Undefined symbol 'pthread_t'

Error: noname00.cpp(8,15):Statement missing ;

Error: noname00.cpp(12,18):Call to undefined function 'pthread_create'

I highlighted the main error which is caused by 'PTHREAD.H'. I checked the include folder for this file. It doesn't exist. How can I fix this problem?

2
Are you maintaining a product that requires the use of Borland C++ 5? Why else would one care to build anything using a product that has been released 17 years ago, a full year before C++98 standard? - Sergey Kalinichenko
Schools should really stop using Turbo and Borland C++. - Michael Burr

2 Answers

2
votes

Borland's C++ toolchain doesn't include a pthreads library, nor does the Windows SDK. You'll either need to use native Win32 thread APIs or get a 3rd party pthreads implementation for Windows.

Some options include:

I have no idea how well those things work with Borland C++ 5.x.

Another alternative is to use a toolchain that includes a pthreads implementation, such as TDM's MinGW toolchain:

0
votes

your problem is #include <pthread.h>

  • you need either copy all the pthread related files (.h,.c,.cpp,.hpp,.lib,.obj)
  • into compiler include folder
  • or add include path to it in your project/compiler settings
  • or copy it locally to your project and change #include <pthread.h> to #include "pthread.h"

So compiler did not find the pthread.h header

  • so no datatype from it is known from compiler side (like pthread_t)
  • therefore the rest of the errors...