Undefined reference when using pthread
Created by: njlr
Compiling a small pthread example results in an undefined reference
. It seems that Buck is not handling the linker_flags
correctly.
Repo for this issue: https://github.com/njlr/buck-pthread-example
Here is the BUCK
file:
cxx_binary(
name = 'main',
srcs = [
'main.cpp',
],
linker_flags = [
'-lpthread',
],
)
Here is the error:
$ buck build :main
buck-out/gen/main#compile-main.cpp.oa5b6a1ba,default/main.cpp.o: In function `main':
main.cpp:(.text+0x98): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
BUILD FAILED: //:main#binary failed with exit code 1:
c++ link
stderr: buck-out/gen/main#compile-main.cpp.oa5b6a1ba,default/main.cpp.o: In function `main':
main.cpp:(.text+0x98): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
[-] PROCESSING BUCK FILES...FINISHED 0.1s [100%] 🐌 New Buck instance
[-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)
[-] BUILDING...FINISHED 0.4s [100%] (2/3 JOBS, 1 UPDATED, 1 [33.3%] CACHE MISS)
Compiling manually works:
c++ main.cpp -o main -lpthread
My setup:
$ buck --version
buck version v2017.05.31.01
$ c++ --version
c++ (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.