Results 1 to 7 of 7

Thread: Error when linking agains libdbus

  1. #1

    Default Error when linking agains libdbus

    This is my make file:
    Code:
    daemon-ui: main.c
        echo gcc -ggdb `pkg-config --libs dbus-1 --cflags dbus-1` main.c -o daemon-ui
        gcc -ggdb -o daemon-ui `pkg-config --libs dbus-1 --cflags dbus-1` main.c
    
    install:
        cp daemon-ui /usr/local/bin
        cp DaemonUI-session-helper /usr/local/bin
        cp etc.dbus-1.system..d.daemonUI..conf /etc/dbus-1/system.d/daemonUI.conf
        cp usr.share.dbus-1.system-services.pl..art..lach..slawek..apps..DaemonUI..service /usr/share/dbus-1/system-services/pl.art.lach.slawek.apps.DaemonUI.service
    This is my spec file:
    Code:
    Name:       DaemonUI
    Version:    0.0.1
    Release:    0.0.1
    Summary:    This package providces UI for system daemon
    License:      GPL-3.0-or-later
    BuildRequires: cmake
    BuildRequires: pkgconfig(dbus-1)
    Requires: dbus-1 systemd
    URL:        https://sourceforge.net/projects/DaemonUI
    Source0:    https://sourceforge.net/projects/DaemonUI/files/Sources/DaemonUI-%{version}.tar.gz
    
    %description
    This ststem daemon is designed to allow other daemon asking user for certain thinks. It only stores DBUS ID for of default Bonsole program for given session and share it for root program, which needs it.
    
    %prep
    %setup -q
    
    %build
    make
    
    %install
    
    mkdir -p %{buildroot}/%{_bindir}
    mkdir -p %{buildroot}/%{_prefix}/sbin
    mkdir -p %{buildroot}/%{_prefix}/share/dbus-1/system-services/
    mkdir -p %{buildroot}/etc/dbus-1/system.d
    
    install -m 0755 DaemonUI-session-helper %{buildroot}/%{_bindir}/
    install -m 0755 daemon-ui %{buildroot}/%{_prefix}/sbin/
    
    cp etc.dbus-1.system..d.daemonUI..conf %{buildroot}/etc/dbus-1/system.d/daemonUI.conf
    cp  usr.share.dbus-1.system-services.pl..art..lach..slawek..apps..DaemonUI..service %{buildroot}/%{_prefix}/share/dbus-1/system-services/pl.art.lach.slawek.apps.DaemonUI.service
    
    
    %files
    /%{_bindir}/DaemonUI-session-helper
    /%{_prefix}/sbin/daemon-ui
    /%{_prefix}/share/dbus-1/system-services/pl.art.lach.slawek.apps.DaemonUI.service
    /etc/dbus-1/system.d/daemonUI.conf
    %dir /*
    %dir /%{_prefix}/share/
    %dir /etc
    %dir /usr
    %dir /usr/share
    %dir /etc/dbus-1
    %dir /etc/dbus-1/system.d
    %dir /usr/share/dbus-1
    %dir /usr/share/dbus-1/system-services
    
    %changelog
    * Mon May 17 2021 Sławomir Lach <slawek@lach.art.pl>
    -

    This is end of output:
    Code:
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/cc3F8
    Jjj.o: in function `get_unix_process_from_id': 
    [   23s] /home/abuild/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:69: undefined reference to `dbus_e
    rror_init' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:71: undefined reference to `dbus_message_new_method_c
    all' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:77: undefined reference to `dbus_message_iter_init_ap
    pend' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:80: undefined reference to `dbus_message_iter_append_
    basic' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:85: undefined reference to `dbus_connection_send_with
    _reply' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:90: undefined reference to `dbus_connection_flush' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:91: undefined reference to `dbus_message_unref' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:93: undefined reference to `dbus_pending_call_block' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:94: undefined reference to `dbus_pending_call_steal_r
    eply' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:95: undefined reference to `dbus_pending_call_unref' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:97: undefined reference to `dbus_message_get_type' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:101: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:114: undefined reference to `dbus_error_init' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:115: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:116: undefined reference to `dbus_error_is_set' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/cc3F8
    Jjj.o: in function `send_dbus_reply_string_string': 
    [   23s] /home/abuild/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:231: undefined reference to `dbus_
    message_new_method_return' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:236: undefined reference to `dbus_message_iter_init_a
    ppend' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:237: undefined reference to `dbus_message_iter_append
    _basic' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:242: undefined reference to `dbus_message_iter_append
    _basic' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:247: undefined reference to `dbus_connection_send' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:252: undefined reference to `dbus_connection_flush' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:254: undefined reference to `dbus_message_unref' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/cc3F8
    Jjj.o: in function `connect_with_client': 
    [   23s] /home/abuild/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:264: undefined reference to `dbus_
    message_get_member' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:265: undefined reference to `dbus_message_get_interfa
    ce' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:268: undefined reference to `dbus_error_init' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:277: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:278: undefined reference to `dbus_message_get_sender' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:301: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:318: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:336: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:342: undefined reference to `dbus_message_get_args' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:349: undefined reference to `dbus_message_new_method_
    return' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:360: undefined reference to `dbus_message_iter_init_a
    ppend' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:363: undefined reference to `dbus_message_iter_append
    _basic' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:368: undefined reference to `dbus_message_iter_append
    _basic' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:374: undefined reference to `dbus_connection_send' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:379: undefined reference to `dbus_connection_flush' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:381: undefined reference to `dbus_message_unref' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/cc3F8
    Jjj.o: in function `init': 
    [   23s] /home/abuild/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:394: undefined reference to `dbus_
    error_init' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:395: undefined reference to `dbus_bus_get' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:398: undefined reference to `dbus_error_is_set' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:406: undefined reference to `dbus_error_free' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:410: undefined reference to `dbus_bus_request_name' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:411: undefined reference to `dbus_error_is_set' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:420: undefined reference to `dbus_connection_try_regi
    ster_object_path' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:426: undefined reference to `dbus_error_is_set' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:429: undefined reference to `dbus_error_free' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:434: undefined reference to `dbus_message_new_signal' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:443: undefined reference to `dbus_connection_send' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:449: undefined reference to `dbus_connection_flush' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:451: undefined reference to `dbus_message_unref' 
    [   23s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abui
    ld/rpmbuild/BUILD/DaemonUI-0.0.1/main.c:453: undefined reference to `dbus_connection_read_wri
    te_dispatch' 
    [   23s] collect2: error: ld returned 1 exit status 
    [   23s] make: *** [Makefile:3: daemon-ui] Error 1 
    [   23s] error: Bad exit status from /var/tmp/rpm-tmp.E9Oktv (%build) 
    [   23s]  
    [   23s]  
    [   23s] RPM build errors: 
    [   23s]     Bad exit status from /var/tmp/rpm-tmp.E9Oktv (%build) 
    [   23s]  
    [   23s] localhost.localdomain failed "build DaemonUI.spec" at Sat Jul 24 10:48:35 UTC 2021. 
    [   23s]  
    
    The buildroot was: /var/tmp/build-root/openSUSE_
    


  2. #2
    Join Date
    Sep 2012
    Posts
    6,801

    Default Re: Error when linking agains libdbus

    This question has nothing to do with OBS, it is general programming question.

    Quote Originally Posted by Lachu View Post
    Code:
        gcc -ggdb -o daemon-ui `pkg-config --libs dbus-1 --cflags dbus-1` main.c
    Libraries must be listed on command line after object modules that use them, not before.

  3. #3

    Default Re: Error when linking agains libdbus

    Thanks. But this build command (gcc) worked, when build normal executable (not for package). Why?

  4. #4
    Join Date
    Sep 2012
    Posts
    6,801

    Default Re: Error when linking agains libdbus

    Quote Originally Posted by Lachu View Post
    But this build command (gcc) worked, when build normal executable (not for package). Why?
    I do not know. I have no idea what normal executable is and sourceforge project in your spec file points to something without any downloads (and with different license and different description).

  5. #5

    Default Re: Error when linking agains libdbus

    Thanks a lot!

    Spec file corrected. By wrote normal executable I mean executable created by invocation of make on my shell, not by osc build tool during rpm creation. English is not my native.

  6. #6
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    31,738
    Blog Entries
    15

    Default Re: Error when linking agains libdbus

    Quote Originally Posted by Lachu View Post
    Thanks a lot!

    Spec file corrected. By wrote normal executable I mean executable created by invocation of make on my shell, not by osc build tool during rpm creation. English is not my native.
    Hi
    You might need to add the --as-needed flag, or add export SUSE_ASNEEDED=0 as the first line after %build in spec file.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  7. #7
    Join Date
    Sep 2012
    Posts
    6,801

    Default Re: Error when linking agains libdbus

    Quote Originally Posted by malcolmlewis View Post
    You might need to add the --as-needed flag
    Actually the problem is caused by --as-needed flag, you probably mean --no-as-needed.
    or add export SUSE_ASNEEDED=0 as the first line after %build in spec file.
    Yes, on OBS during build
    Code:
    SUSE_ASNEEDED=1
    Do you know where this variable is set? openSUSE linker defaults to --no-as-needed for normal binaries which explains why it works outside of OBS. It also is not RPM (building package locally works correctly).

    P.S. Thank you for explaining it. ld documentation is rather vague on effect of --as-needed and makes impression it affects only run-time linking. Not to mention completely undocumented magic variable.

    P.P.S. it turned out to be OBS specific issue after all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •