12.12. Threading libraries
前一頁 | 章 12. Dos and Don'ts | 下一頁

## 12.12. Threading libraries

The threading library must be linked to the binaries using a special linker flag `-pthread` on FreeBSD. If a port insists on linking `-lpthread` or `-lc_r` directly, patch it to use `PTHREAD_LIBS` variable provided by the ports framework. This variable usually has the value of `-pthread`, but on certain architectures and FreeBSD versions it can have different values, so do not just hardcode `-pthread` into patches and always use `PTHREAD_LIBS`.

### 注意:

If building the port errors out with `unrecognized option '-pthread'` when setting `PTHREAD_LIBS`, it may be desirable to use `gcc` as linker by setting `CONFIGURE_ENV` to `LD=${CC}`. The `-pthread` option is not supported by `ld` directly.

前一頁 | 上一層 | 下一頁
12.11. Respect `CFLAGS` | 起始頁 | 12.13. Feedback

本文及其他文件，可由此下載： ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。

若有 FreeBSD 方面疑問，請先閱讀 FreeBSD 相關文件，如不能解決的話，再洽詢 <questions@FreeBSD.org>。
關於本文件的問題，請洽詢 <doc@FreeBSD.org>。