Skip to content

Commit

Permalink
build: Link dnf5-plugins/builddep_plugin to librpm
Browse files Browse the repository at this point in the history
Building with LDFLAGS='-Wl,-z,defs' shows among others:

$ /usr/bin/c++ -fPIC -O0 -g -Wl,-z,defs -shared  -o builddep_cmd_plugin.so CMakeFiles/builddep_cmd_plugin.dir/builddep.cpp.o CMakeFiles/builddep_cmd_plugin.dir/builddep_cmd_plugin.cpp.o  -Wl,-rpath,/tmp/d/libdnf5-cli:/tmp/d/libdnf5: /usr/lib64/librpmbuild.so ../../libdnf5-cli/libdnf5-cli.so.1 ../../libdnf5/libdnf5.so.1 -ldl -lstdc++ -lfmt -lsmartcols
[...]
/home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:125:(.text+0xba8): undefined reference to `rpmdsInit'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:127:(.text+0xbba): undefined reference to `rpmdsDNEVR'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:126:(.text+0xbe1): undefined reference to `rpmdsNext'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:129:(.text+0xbf6): undefined reference to `rpmdsFree'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:130:(.text+0xc0f): undefined reference to `rpmdsInit'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:132:(.text+0xc21): undefined reference to `rpmdsDNEVR'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:131:(.text+0xc48): undefined reference to `rpmdsNext'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:134:(.text+0xc5d): undefined reference to `rpmdsFree'
/usr/bin/ld: CMakeFiles/builddep_cmd_plugin.dir/builddep.cpp.o: in function `dnf5::BuildDepCommand::add_from_srpm_file(std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, char const*)':
/home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:141:(.text+0xc9f): undefined reference to `Fopen'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:142:(.text+0xcb6): undefined reference to `Ferror'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:143:(.text+0xd1d): undefined reference to `Fstrerror'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:145:(.text+0xd4d): undefined reference to `Fclose'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:152:(.text+0xd64): undefined reference to `rpmtsCreate'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:153:(.text+0xd79): undefined reference to `rpmtsSetVSFlags'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:154:(.text+0xd95): undefined reference to `rpmReadPackageFile'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:155:(.text+0xda4): undefined reference to `rpmtsFree'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:156:(.text+0xdb0): undefined reference to `Fclose'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:160:(.text+0xddd): undefined reference to `rpmdsNewPool'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:160:(.text+0xde5): undefined reference to `rpmdsInit'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:162:(.text+0xdf7): undefined reference to `rpmdsDNEVR'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:161:(.text+0xe46): undefined reference to `rpmdsNext'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:167:(.text+0xe5b): undefined reference to `rpmdsFree'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:168:(.text+0xe76): undefined reference to `rpmdsNewPool'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:168:(.text+0xe7e): undefined reference to `rpmdsInit'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:170:(.text+0xe90): undefined reference to `rpmdsDNEVR'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:169:(.text+0xeb7): undefined reference to `rpmdsNext'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:172:(.text+0xecc): undefined reference to `rpmdsFree'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:177:(.text+0xf2c): undefined reference to `headerFree'
/usr/bin/ld: CMakeFiles/builddep_cmd_plugin.dir/builddep.cpp.o: in function `dnf5::BuildDepCommand::run()':
/home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:223:(.text+0x1966): undefined reference to `rpmPushMacro'
/usr/bin/ld: /home/test/dnf5/dnf5-plugins/builddep_plugin/builddep.cpp:231:(.text+0x1aae): undefined reference to `rpmPopMacro'

All these functions are explicitly called from builddep.cpp, hence
builddep.cpp must include header files defining the functions and must
link to libraries providing them.

rpmbuild header and library were utilizied. But librpm and librpmio were
completely missing. This patch adds them.

Related to
<rpm-software-management#267>.
  • Loading branch information
ppisar committed Nov 3, 2023
1 parent 8598828 commit fab992d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dnf5-plugins/builddep_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ set_target_properties(builddep_cmd_plugin PROPERTIES PREFIX "")
find_library(RPMBUILD NAMES rpmbuild REQUIRED)
target_link_libraries(builddep_cmd_plugin PRIVATE ${RPMBUILD})

pkg_check_modules(RPM REQUIRED rpm)
target_link_libraries(builddep_cmd_plugin PRIVATE ${RPM_LIBRARIES})

target_link_libraries(builddep_cmd_plugin PRIVATE libdnf5 libdnf5-cli)
target_link_libraries(builddep_cmd_plugin PRIVATE dnf5)

Expand Down
5 changes: 5 additions & 0 deletions dnf5-plugins/builddep_plugin/builddep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include <libdnf5/rpm/package_query.hpp>
#include <libdnf5/utils/bgettext/bgettext-mark-domain.h>
#include <rpm/rpmbuild.h>
#include <rpm/rpmds.h>
#include <rpm/rpmio.h>
#include <rpm/rpmlib.h>
#include <rpm/rpmmacro.h>
#include <rpm/rpmts.h>

#include <iostream>

Expand Down

0 comments on commit fab992d

Please sign in to comment.