# Unable to build devel/gammaray ld: error: unable to find library -liberty



## SlySven (Dec 14, 2020)

i wish to use the KDAB GammaRay tool to debug a Qt application I am working on. I have, I believe, an up to date 12.2-RELEASE (r366954) amd64 system but building this port/project is failing with the above error at step 176 of 961:

```
FAILED: lib/libgammaray_core-qt5_15-amd64.so.2.11.2 
: && /usr/bin/c++ -fPIC -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -Wsizeof-pointer-memaccess -Wreorder -Wformat-security -Wall -Wextra -pedantic -Woverloaded-virtual -Winit-self -Wmissing-include-dirs -Wunused -Wundef -Wpointer-arith -Wmissing-noreturn -Werror=return-type -Wswitch -Wno-gnu-zero-variadic-macro-arguments -std=gnu++0x -Qunused-arguments -Wdocumentation -fno-operator-names -Wzero-as-null-pointer-constant -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -fstack-protector-strong -shared -Wl,-soname,libgammaray_core-qt5_15-amd64.so.2.11.2 -o lib/libgammaray_core-qt5_15-amd64.so.2.11.2 core/CMakeFiles/gammaray_core.dir/gammaray_core_autogen/mocs_compilation.cpp.o core/CMakeFiles/gammaray_core.dir/__/3rdparty/qt/resourcemodel.cpp.o core/CMakeFiles/gammaray_core.dir/abstractbindingprovider.cpp.o core/CMakeFiles/gammaray_core.dir/aggregatedpropertymodel.cpp.o core/CMakeFiles/gammaray_core.dir/bindingaggregator.cpp.o core/CMakeFiles/gammaray_core.dir/bindingnode.cpp.o core/CMakeFiles/gammaray_core.dir/metaobject.cpp.o core/CMakeFiles/gammaray_core.dir/metaobjectregistry.cpp.o core/CMakeFiles/gammaray_core.dir/metaobjectrepository.cpp.o core/CMakeFiles/gammaray_core.dir/metaproperty.cpp.o core/CMakeFiles/gammaray_core.dir/probe.cpp.o core/CMakeFiles/gammaray_core.dir/probeguard.cpp.o core/CMakeFiles/gammaray_core.dir/probesettings.cpp.o core/CMakeFiles/gammaray_core.dir/probecontroller.cpp.o core/CMakeFiles/gammaray_core.dir/objectlistmodel.cpp.o core/CMakeFiles/gammaray_core.dir/objectclassinfomodel.cpp.o core/CMakeFiles/gammaray_core.dir/objectmethodmodel.cpp.o core/CMakeFiles/gammaray_core.dir/objectenummodel.cpp.o core/CMakeFiles/gammaray_core.dir/objecttreemodel.cpp.o core/CMakeFiles/gammaray_core.dir/objecttypefilterproxymodel.cpp.o core/CMakeFiles/gammaray_core.dir/problemcollector.cpp.o core/CMakeFiles/gammaray_core.dir/methodargumentmodel.cpp.o core/CMakeFiles/gammaray_core.dir/multisignalmapper.cpp.o core/CMakeFiles/gammaray_core.dir/signalspycallbackset.cpp.o core/CMakeFiles/gammaray_core.dir/singlecolumnobjectproxymodel.cpp.o core/CMakeFiles/gammaray_core.dir/stacktracemodel.cpp.o core/CMakeFiles/gammaray_core.dir/toolfactory.cpp.o core/CMakeFiles/gammaray_core.dir/toolmanager.cpp.o core/CMakeFiles/gammaray_core.dir/toolpluginmodel.cpp.o core/CMakeFiles/gammaray_core.dir/toolpluginerrormodel.cpp.o core/CMakeFiles/gammaray_core.dir/propertycontroller.cpp.o core/CMakeFiles/gammaray_core.dir/propertycontrollerextension.cpp.o core/CMakeFiles/gammaray_core.dir/proxytoolfactory.cpp.o core/CMakeFiles/gammaray_core.dir/util.cpp.o core/CMakeFiles/gammaray_core.dir/varianthandler.cpp.o core/CMakeFiles/gammaray_core.dir/objectdataprovider.cpp.o core/CMakeFiles/gammaray_core.dir/attributemodel.cpp.o core/CMakeFiles/gammaray_core.dir/qmetaobjectvalidator.cpp.o core/CMakeFiles/gammaray_core.dir/enumrepositoryserver.cpp.o core/CMakeFiles/gammaray_core.dir/enumutil.cpp.o core/CMakeFiles/gammaray_core.dir/execution.cpp.o core/CMakeFiles/gammaray_core.dir/classesiconsrepositoryserver.cpp.o core/CMakeFiles/gammaray_core.dir/propertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/propertyaggregator.cpp.o core/CMakeFiles/gammaray_core.dir/propertydata.cpp.o core/CMakeFiles/gammaray_core.dir/propertyfilter.cpp.o core/CMakeFiles/gammaray_core.dir/dynamicpropertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/qmetapropertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/metapropertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/associativepropertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/sequentialpropertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/objectinstance.cpp.o core/CMakeFiles/gammaray_core.dir/propertyadaptorfactory.cpp.o core/CMakeFiles/gammaray_core.dir/jsonpropertyadaptor.cpp.o core/CMakeFiles/gammaray_core.dir/paintbuffer.cpp.o core/CMakeFiles/gammaray_core.dir/paintbuffermodel.cpp.o core/CMakeFiles/gammaray_core.dir/paintanalyzer.cpp.o core/CMakeFiles/gammaray_core.dir/painterprofilingreplayer.cpp.o core/CMakeFiles/gammaray_core.dir/remoteviewserver.cpp.o core/CMakeFiles/gammaray_core.dir/tools/metatypebrowser/metatypesmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/messagehandler/messagehandler.cpp.o core/CMakeFiles/gammaray_core.dir/tools/messagehandler/messagemodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/metaobjectbrowser/metaobjectbrowser.cpp.o core/CMakeFiles/gammaray_core.dir/tools/metaobjectbrowser/metaobjecttreemodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/metatypebrowser/metatypebrowser.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/objectinspector.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/propertiesextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/methodsextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/connectionsextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/abstractconnectionsmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/inboundconnectionsmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/outboundconnectionsmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/enumsextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/classinfoextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/applicationattributeextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/bindingextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/bindingmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/objectinspector/stacktraceextension.cpp.o core/CMakeFiles/gammaray_core.dir/tools/problemreporter/availablecheckersmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/problemreporter/problemmodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/problemreporter/problemreporter.cpp.o core/CMakeFiles/gammaray_core.dir/tools/resourcebrowser/resourcebrowser.cpp.o core/CMakeFiles/gammaray_core.dir/tools/resourcebrowser/resourcefiltermodel.cpp.o core/CMakeFiles/gammaray_core.dir/remote/server.cpp.o core/CMakeFiles/gammaray_core.dir/remote/remotemodelserver.cpp.o core/CMakeFiles/gammaray_core.dir/remote/selectionmodelserver.cpp.o core/CMakeFiles/gammaray_core.dir/remote/serverdevice.cpp.o core/CMakeFiles/gammaray_core.dir/remote/tcpserverdevice.cpp.o core/CMakeFiles/gammaray_core.dir/remote/localserverdevice.cpp.o core/CMakeFiles/gammaray_core.dir/remote/serverproxymodel.cpp.o core/CMakeFiles/gammaray_core.dir/tools/messagehandler/loggingcategorymodel.cpp.o core/CMakeFiles/gammaray_core.dir/__/3rdparty/qt/5.5/private/qpaintbuffer.cpp.o core/CMakeFiles/gammaray_core.dir/gammaray_core_autogen/7BV4YJK25R/qrc_gammaray.cpp.o  -Wl,-rpath,"\$ORIGIN/:/usr/local/lib/qt5:/usr/local/lib"  common/libgammaray_common_internal.a  /usr/local/lib/libbfd.a  -ldl  -liberty  -lz  lib/libgammaray_common-qt5_15-amd64.so.2.11.2  lib/libgammaray_kitemmodels-qt5_15-amd64.so.2.11.2  /usr/local/lib/qt5/libQt5Gui.so.5.15.0  /usr/local/lib/qt5/libQt5Network.so.5.15.0  /usr/local/lib/qt5/libQt5Core.so.5.15.0  -Wl,-rpath-link,/usr/local/lib && :
ld: error: unable to find library -liberty
c++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/gammaray
```
I did retry with the suggested MAKE_JOBS_UNSAFE setting but it did not help.

It seems like I am having problems linking with the "libiberty" library {the name seems to have been choosen for humorous effect apparently - so that the linker command line reads `-liberty` - but that doesn't help when trying to _duckduckgo-ing_ for it}, i can see that I have the header files:

```
root@ripley:/usr/ports/devel/gammaray # ls -l /usr/local/include/libiberty/
total 116
-rw-r--r--  1 root  wheel  13139 24 Oct  2019 ansidecl.h
-rw-r--r--  1 root  wheel  23493 24 Oct  2019 demangle.h
-rw-r--r--  1 root  wheel   2576 24 Oct  2019 dyn-string.h
-rw-r--r--  1 root  wheel   2883 24 Oct  2019 fibheap.h
-rw-r--r--  1 root  wheel   5658 24 Oct  2019 floatformat.h
-rw-r--r--  1 root  wheel   7264 24 Oct  2019 hashtab.h
-rw-r--r--  1 root  wheel  23698 24 Oct  2019 libiberty.h
-rw-r--r--  1 root  wheel   3960 24 Oct  2019 objalloc.h
-rw-r--r--  1 root  wheel   2831 24 Oct  2019 partition.h
-rw-r--r--  1 root  wheel   5643 24 Oct  2019 safe-ctype.h
-rw-r--r--  1 root  wheel   1210 24 Oct  2019 sort.h
-rw-r--r--  1 root  wheel   5410 24 Oct  2019 splay-tree.h
root@ripley:/usr/ports/devel/gammaray #
```
I can also see the static (?) library:

```
root@ripley:/usr/ports/devel/gammaray # ls -l /usr/local/lib/libiberty.a 
-rw-r--r--  1 root  wheel  399652 24 Oct  2019 /usr/local/lib/libiberty.a
root@ripley:/usr/ports/devel/gammaray #
```

It seems that there is not any shared library files, so what to do about this?


----------



## SirDice (Dec 14, 2020)

I'm wondering where it comes from, what does `pkg which /usr/local/lib/libiberty.a` tell you?


----------



## SlySven (Dec 30, 2020)

```
root@ripley:/usr/ports # pkg which /usr/local/lib/libiberty.a
/usr/local/lib/libiberty.a was installed by package gnulibiberty-2.19.1_2
```

However I am not sure if that is going to help - the libiberty.a file is a static library isn't it - but I though the "-liberty" in the compilation command is going to be looking for a shared library i.e. a libiberty.so file...?

Checking that package:

```
root@ripley:/usr/ports/devel/gammaray # pkg query "%Fp" gnulibiberty
/usr/local/include/libiberty/ansidecl.h
/usr/local/include/libiberty/demangle.h
/usr/local/include/libiberty/dyn-string.h
/usr/local/include/libiberty/fibheap.h
/usr/local/include/libiberty/floatformat.h
/usr/local/include/libiberty/hashtab.h
/usr/local/include/libiberty/libiberty.h
/usr/local/include/libiberty/objalloc.h
/usr/local/include/libiberty/partition.h
/usr/local/include/libiberty/safe-ctype.h
/usr/local/include/libiberty/sort.h
/usr/local/include/libiberty/splay-tree.h
/usr/local/lib/libiberty.a
```

OTOH I have just scanned my Linux OS file system and it only has that same libiberty.a file - in /usr/lib/x86_64-linux-gnu/libiberty.a - however I cannot tell whether the path to the file on FreeBSD is where the port is expecting it to be. Next time I am running Linux I will see what the corresponding packages for that OS provides/depends one...


----------

