Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3704 - libubus ubus_invoke function undefined reference to #8724

Closed
openwrt-bot opened this issue Mar 24, 2021 · 3 comments
Closed

FS#3704 - libubus ubus_invoke function undefined reference to #8724

openwrt-bot opened this issue Mar 24, 2021 · 3 comments
Labels

Comments

@openwrt-bot
Copy link

hansdals:

Supply the following if possible:

  • Device problem occurs on
  • Software versions of OpenWrt/LEDE release, packages, etc.
  • Steps to reproduce

I'm compiling custom packages that I can unfortunately not share, but the problem is as follows:

This is more a suggestion than a bug report.
I sometimes get undefined reference to ubus_invoke in libfoo.so.
I have tried to replicate the linking error with a simple c program, but it compiles fine (on my ubuntu machine with latest libubus compiled from source today)..

#include <stdio.h>
#include <libubus.h>

int main()
{
ubus_invoke(NULL, 0, NULL, NULL, NULL, NULL, 0);
return 0;
}
gcc test.c -lubus

I think the problem here is that the ubus CMakeLists.txt file has LIB_SOURCES libubus.c (and more), but the definition of ubus_invoke() is in libubus.h. Causing libubus.so to not have that symbol/function.
So if I in a main program call a function in libfoo that calls ubus_invoke, then I can end up with a undefined reference to ubus_invoke ?

Suggest moving the definitions to the .c file , or add libubus.h to LIB_SOURCES

again I'm sorry I couldn't replicate the problem.

@openwrt-bot
Copy link
Author

hansdals:

oh shoot. I don't know how to edit the original task above.
Maybe it was a bad idea to suggest adding libubus.h to LIB_SOURCES. If so, it is possible to get "multiple definitions of" errors in the build. I'd suggest just moving the "return ubus_invoke_fd) definitions from libubus.h to libubus.c
:)

@openwrt-bot
Copy link
Author

ynezz:

I sometimes get undefined reference to ubus_invoke in libfoo.so.

Then you need to fix the libfoo.so, your toolchain/build because ubus_invoke() is declared as static inline int in libubus.h which means, that you should've it included in your libfoo.so already, statically, there is no such symbol in libubus.so:

$objdump -tT build/libubus.so | grep ubus_invoke 0000000000003b4b g F .text 00000000000000a0 ubus_invoke_async_fd 0000000000003beb g F .text 000000000000007a ubus_invoke_fd 0000000000003beb g DF .text 000000000000007a Base ubus_invoke_fd 0000000000003b4b g DF .text 00000000000000a0 Base ubus_invoke_async_fd

$ objdump -tT build/examples/client | grep ubus_invoke
0000000000000000 F UND 0000000000000000 ubus_invoke_async_fd
0000000000000000 F UND 0000000000000000 ubus_invoke_fd
0000000000000000 DF UND 0000000000000000 ubus_invoke_async_fd
0000000000000000 DF UND 0000000000000000 ubus_invoke_fd

@hansdals
Copy link

Since this is what comes up with google, I'll reply here. No idea where this openwrt-bot got these messages from.

ynezz is right about the static inline, but the situation I had was different.
Since the libubus in my sdk was an older version than on the router, libubus api had changed from having int ubus_invoke to static inline int ubus invoke. Causing issues with mismatch between sdk and router.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants