# Compiling world stops with "/usr/bin/ld: cannot find -lpthread"?"



## HL1234 (Nov 23, 2017)

```
CodeGenInstruction.o CodeGenMapTable.o CodeGenRegisters.o CodeGenSchedule.o 
CodeGenTarget.o DAGISelEmitter.o DAGISelMatcher.o DAGISelMatcherEmitter.o 
DAGISelMatcherGen.o DAGISelMatcherOpt.o DFAPacketizerEmitter.o DisassemblerEmitter.o 
FastISelEmitter.o FixedLenDecoderEmitter.o GlobalISelEmitter.o InstrInfoEmitter.o 
IntrinsicEmitter.o OptParserEmitter.o PseudoLoweringEmitter.o RegisterInfoEmitter.o 
SearchableTableEmitter.o SubtargetEmitter.o SubtargetFeatureInfo.o TableGen.o Types.o 
X86DisassemblerTables.o X86ModRMFilters.o X86RecognizableInstr.o /usr/obj/usr/src/tmp/usr
/src/lib/clang/libllvmminimal/libllvmminimal.a  -lncursesw  -lpthread -legacy
*** Error code 1
/usr/bin/ld: cannot find -lpthread
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

`clang++ -v`

```
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: i386-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin
```


```
ls -l /usr/bin/clang++
-r-xr-xr-x  6 root  wheel  43048720 16 Nov. 19:28 /usr/bin/clang++
```
Can anyone me explain what that means if "-lpthread" is not found? What is missing?


----------



## SirDice (Nov 24, 2017)

Note that FreeBSD 11.0 will be End-of-Life at the end of this month. Make sure you upgrade to 11.1 some time soon.

What's in /etc/make.conf and/or /etc/src.conf?


----------



## HL1234 (Nov 25, 2017)

Thanks You for your answer,
but it didn't depend on /etc/make.conf and on this machine there is no /etc/src.conf.
I could fix the other problem https://forums.freebsd.org/threads/63356/#post-366492 by coping xlocale from an other installation into /usr/include/xlocale on this computer and then the compiler goes further, but it stops at the error I mentioned here.
Because that xlocate was missing I inspect the log file more closer. I see that the last compiler command
	
	



```
clang++
   -O2
   -pipe
   -I/usr/obj/usr/src/tmp/usr/src/lib/clang/libllvm
   -I/usr/src/lib/clang/include
   -I/usr/src/contrib/llvm/include
   -DLLVM_ON_UNIX
   -DLLVM_ON_FREEBSD
   -D__STDC_LIMIT_MACROS
   -D__STDC_CONSTANT_MACROS
   -DNDEBUG
   -DLLVM_DEFAULT_TARGET_TRIPLE=\"i386-unknown-freebsd11.1\"
   -DLLVM_HOST_TRIPLE=\"i386-unknown-freebsd11.1\"
   -DDEFAULT_SYSROOT=\"/usr/obj/usr/src/tmp\"
   -ffunction-sections
   -fdata-sections
   -g
   -Qunused-arguments
   -I/usr/obj/usr/src/tmp/legacy/usr/include
   -std=c++11
   -fno-exceptions
   -fno-rtti
   -stdlib=libc++
   -Wno-c++11-extensions  
   -Wl,--gc-sections
   -static
   -L/usr/obj/usr/src/tmp/legacy/usr/lib
   -o llvm-tblgen.full  AsmMatcherEmitter.o AsmWriterEmitter.o .........
   -lncursesw  
   -lpthread
   -legacy
```
 using "-lpthread".
I found out that this stand for a library what is been linked here. I'm searching for a library with that name and found them in /usr/lib/
/usr/lib/libthr_p.a
/usr/lib/libthr.a
/usr/lib/libthr.so
but why can the linker not find them? I compare this directory with the directory from my FreeBSD virtual server and found out that at my virtual server there are a lot links been set and on my old home machine not. I do not know why. So I setting the links by myself:
libpthread_p.a -> libthr_p.a
libpthread.a -> libthr.a
libpthread.so -> libthr.so
That's was it. Running `make buildworld` goes now further but stops on an another position. I set then all missing links I match with the virtual server machine and the home computer and now it is compiling since Thursday night (an old Pentium III  ).

I thing between the years some is going corrupt with the installation files on this machine.

There is one question I have yet: If I run further in this trouble, could I delete the complete installation without deleting all files downstairs of /usr/local and install the system new (maybe from DVD) without deleting anything in /usr/local/...?


----------

