Im having issues trying to compile a CPP application with a dependency on X11 using buck as it appears to not be linking the X11 Lib and results in an undefined reference error:
undefined reference to `XOpenDisplay'
collect2: error: ld returned 1 exit status
After researching the error I tried to modify the BUCK file to provide the correct flags and tried in a few different formats:
platform_linker_flags = [
# ('^linux.*', ['-lX11','-L/usr/X11/lib','-I/opt/X11/include'])
('^linux.*', []),
('^linux.*', ['-lX11']),
('^linux.*', ['-L/usr/X11/lib']),
],
I tried as you can see above to change the structure etc to see if it made a difference in the linking process however it still does not resolve the dependency required for XOpenDisplay.
Can anyone possibly explain or reference the correct way to apply system libs to a buck project or allude to what may be going wrong in this build.
Try to create a "dummy" target for the system library:
prebuilt_cxx_library(
name = 'x11',
header_only = True,
exported_platform_linker_flags = [
('linux.*', [ '-lX11' ]),
],
)
cxx_library(
name = 'foo',
srcs = glob([
'**/*.cpp',
]),
deps = [
':x11',
],
)
This is the approach used by Buckaroo
There was some discussion of this here: https://github.com/facebook/buck/issues/1443