Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B buck
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 201
    • Issues 201
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 22
    • Merge requests 22
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • buck
  • Issues
  • #1443
Closed
Open
Issue created Jul 27, 2017 by Administrator@rootContributor

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.
Assignee
Assign to
Time tracking