2

I have a C code which contains #include<synch.h> The code compiles successfully in solaris but in Linux I find that the header is missing. As suggested in a few links, can "sync.h" be used instead? Or is there any other equivalent header for synch.h in Linux?

Blackforest
  • 1,009
  • 2
  • 11
  • 18

2 Answers2

4

The synch.h header in Solaris is for Solaris threads. Among other things, it provides declarations for semaphores and mutexes. You can either this library (http://sctl.sourceforge.net/sctl_v1.1_rn.html) to give you Solaris compatible threading on Linux or, a much better idea, rework your code to use POSIX threading.

Spaceghost
  • 6,835
  • 3
  • 28
  • 42
  • Added '#include ' and removed '#include ' – Mona Wade Jun 17 '20 at 22:28
  • May get "undefined reference to symbol 'pthread_create@@GLIBC_XXX", solve by including '-lpthread' as a compiler flag. --> https://stackoverflow.com/q/34143265/8960744 – Mona Wade Feb 08 '21 at 16:50
1

We can't be sure, but one likely possibility is that this is the synch.h that's part of NACHOS, which is often used in educational environments. Head over to the NACHOS project page and read up on it, and decide whether you think that's probably the right thing; if so, you can download and install it for free.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186