- How to list exported functions in a shared lib on Ubuntu
- 3 Answers 3
- c++ экспортировании функций из so
- Thread: howto export functions in *.so libraries
- howto export functions in *.so libraries
- Re: howto export functions in *.so libraries
- Re: howto export functions in *.so libraries
- Re: howto export functions in *.so libraries
- Bookmarks
- Posting Permissions
How to list exported functions in a shared lib on Ubuntu
I have just built a shared lib on Ubuntu, and when I attempt to use the function, the application that loads the library is reporting ‘xxx’ symbol not found. I want to check (i.e. list) the functions that are exported by my library so I can investigate this issue further. Relevant details: OS: Ubuntu 9.10 compiler: gcc 4.4.1 linker: GNU ld 2.20
3 Answers 3
GNU nm lists the symbols from object files objfile. If no object files are listed as arguments, nm assumes the file a.out. [reference]
Thanks for that. It appears my symbol is exported, but undefined (it has a ‘U’ next to the function name). How can a function be exported and yet be undefined (IIRC, a linker option prevents this kind of absurbity). More importantly, what can I do to fix it?
By «Fixing it», I mean how can I ensure that my functions are exported AND DEFINED in the shared library?
Could it be that the undefined symbol is contained in another shared object? Check out Void’s advice.
Were you able to find the root cause for your problem? I am trying to link a FORTRAN-based library and it is showing a function as undefined in the output shared library
For exported functions add —defined-only option, otherwise this way you’ll get imports too. Also, to get only functions and not e.g. something like _edata , you should look for the symbols with T or t in the second column. So, something like this: nm -DCg —defined-only $MY_LIB | grep ‘^[0-9a-f]\+ [Tt] ‘
Is your shared library in the library load path or in the application’s run-time search path? It sounds like the dynamic linker can’t find your library. Try running ldd on your application to see if the library can be found at run-time, e.g.:
$ ldd /usr/bin/less linux-gate.so.1 => (0x0072a000) libncurses.so.5 => /lib/libncurses.so.5 (0x00c68000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x007c7000) libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x00286000) /lib/ld-linux.so.2 (0x002a1000)
See the ld.so(8) man page for additional details on library search paths.
c++ экспортировании функций из so
в линуксе kept simple — все символы экспортируются по-умолчанию, не надо ничего делать.
если Qt — лучше пользоваться Q_DECL_EXPORT и Q_DECL_IMPORT — меньше гемора будет с виндой. QtCreator генерит такой код по умолчанию при создании shared library проекта. Посмотри.
так у меня статическая либа не создаётся в code blocks для exporta из so
так у меня статическая либа не создаётся в code blocks для exporta из so
она не нужна, .so линкуется в программу напрямую
как мне её подключить к программе?
man gcc, ключи -l -L тебе в помощь
лан буду за компом попробую
как мне её подключить к программе?
gcc object_files path_to_lib.so -o program
gcc object_files -L/dierectory/with/lib -lname -o program
при этом .so файл должен иметь имя libname.so
#define API __attribute__ ((visibility("default"))) #ifdef __cplusplus extern "C" < #endif int API some_api_fun(); #ifdef __cplusplus >#endif
компилятору скорми -fvisibility=hidden, тогда наружу будут торчать только те, что тебе надо. Это ускорит загрузку приложения.
How To Write Shared Libraries Ulrich Drepper Red Hat, Inc. drepper@redhat.com August 20, 2006
Нинада тибе никакая статическая либо. Под правильными платформами всё сделано без лишнего долбанутого гемора с либфайлами и сошки проверсиированы на уровне имени файла.
Про всякие dllMain, которые безпричинно крешат всё при запуске loadlibrary я вообще молчу. Такие дела.
И вообще, после портирования туда даже кутишных приложений у меня руки потом тресутся два дня. Такое чувство что ту платформу придумали садомазо, ибо на каждом шаге кажется что тебе специально палки в колёса вставляют.
Другое дело линукс. Всё работает из коробки.
nanoolinux ★★★★ ( 15.10.13 14:00:32 MSK )
Последнее исправление: nanoolinux 15.10.13 14:01:40 MSK (всего исправлений: 1)
How To Write Shared Libraries Ulrich Drepper Red Hat, Inc. drepper@redhat.com August 20, 2006
Плюсую Дреппера. Читать обязатлельно для полного понимания.
Thread: howto export functions in *.so libraries
5 Cups of Ubuntu
howto export functions in *.so libraries
I am trying to convert one windows program to Linux.
The question is:
what is linux equivalent for
extern «C» int (__declspec(dllexport))someFunction(char* someparam)
Frothy Coffee!
Re: howto export functions in *.so libraries
Is just a mere macro to usually force the compiler to produce stdcall calling convention. In Linux AFAIK we only use cdecl ( http://en.wikipedia.org/wiki/X86_calling_conventions ).
Have fun!
5 Cups of Ubuntu
Re: howto export functions in *.so libraries
Frothy Coffee!
Re: howto export functions in *.so libraries
to be precise, the calling convention applies to i386 arch.
For x86-64 Windows and Linux follow 2 slightly different conventions: Linux follows AMD ABI calling convention, instead, as usual, M$ way is to slightly diverge from it from no apparent reason. sigh.
Anyway, given more registers in x86-64, a lot of variables are passed into them, instead of being put onto the stack then read (as happens with i386 convention). So even just for this reason (and believe me there are many more) x86-64 is faster than i386.
- Site Areas
- Settings
- Private Messages
- Subscriptions
- Who’s Online
- Search Forums
- Forums Home
- Forums
- The Ubuntu Forum Community
- Ubuntu Official Flavours Support
- New to Ubuntu
- General Help
- Installation & Upgrades
- Hardware
- Desktop Environments
- Networking & Wireless
- Multimedia Software
- Ubuntu Specialised Support
- Ubuntu Development Version
- Security
- Virtualisation
- Ubuntu Servers, Cloud and Juju
- Server Platforms
- Ubuntu Cloud and Juju
- Gaming & Leisure
- Emulators
- Wine
- Development & Programming
- Packaging and Compiling Programs
- Development CD/DVD Image Testing
- Ubuntu Application Development
- Ubuntu Dev Link Forum
- Programming Talk
- Repositories & Backports
- Ubuntu Backports
- Bug Reports / Support
- Ubuntu Backports
- System76 Support
- Apple Hardware Users
- Ubuntu Community Discussions
- Ubuntu, Linux and OS Chat
- Recurring Discussions
- Full Circle Magazine
- The Cafe
- Cafe Games
- Market
- Mobile Technology Discussions (CLOSED)
- Announcements & News
- Weekly Newsletter
- Membership Applications
- The Fridge Discussions
- Forum Council Agenda
- Forum Feedback & Help
- Request a LoCo forum
- Resolution Centre
- Ubuntu, Linux and OS Chat
- Other Discussion and Support
- Other OS Support and Projects
- Other Operating Systems
- Ubuntu/Debian BASED
- Debian
- MINT
- Arch and derivatives
- Fedora/RedHat and derivatives
- Mandriva/Mageia
- Slackware and derivatives
- openSUSE and SUSE Linux Enterprise
- Mac OSX
- PCLinuxOS
- Gentoo and derivatives
- Windows
- BSD
- Any Other OS
- Other Operating Systems
- Assistive Technology & Accessibility
- Art & Design
- Education & Science
- Documentation and Community Wiki Discussions
- Tutorials
- Outdated Tutorials & Tips
- Ubuntu Women
- Ubuntu LoCo Team Forums
- Americas LoCo Teams
- Argentina Team
- Software
- Hardware
- Comunidad
- Arizona Team — US
- Arkansas Team — US
- Brazil Team
- California Team — US
- Canada Team
- Centroamerica Team
- Chile Team
- Comunidad
- Hardware
- Software
- Instalaci�n y Actualizaci�n
- Colombia Team — Colombia
- Georgia Team — US
- Illinois Team
- Indiana — US
- Kentucky Team — US
- Maine Team — US
- Minnesota Team — US
- Mississippi Team — US
- Nebraska Team — US
- New Mexico Team — US
- New York — US
- North Carolina Team — US
- Ohio Team — US
- Oklahoma Team — US
- Oregon Team — US
- Pennsylvania Team — US
- Peru Team
- Texas Team — US
- Uruguay Team
- Utah Team — US
- Virginia Team — US
- West Virginia Team — US
- Argentina Team
- Asia and Oceania LoCo Teams
- Australia Team
- Bangladesh Team
- Hong Kong Team
- Myanmar Team
- Philippine Team
- Singapore Team
- Europe, Middle East, and African (EMEA) LoCo Teams
- Albania Team
- Catalan Team
- Portugal Team
- Egypt Team
- Georgia Team
- Ireland Team — Ireland
- Kenyan Team — Kenya
- Kurdish Team — Kurdistan
- Lebanon Team
- Morocco Team
- Saudi Arabia Team
- Sudan Team
- Tunisia Team
- Other Forums & Teams
- LoCo Archive
- Afghanistan Team
- Alabama Team — US
- Alaska Team — US
- Algerian Team
- Andhra Pradesh Team — India
- Austria Team
- Bangalore Team
- Bolivia Team
- Cameroon Team
- Colorado Team — US
- Connecticut Team
- Costa Rica Team
- Delhi Team
- Ecuador Team
- El Salvador Team
- Florida Team — US
- Galician LoCo Team
- Greek team
- Hawaii Team — US
- Honduras Team
- Idaho Team — US
- Iowa Team — US
- Jordan Team
- Kansas Team — US
- Libya Team
- Louisiana Team — US
- Maryland Team — US
- Massachusetts Team
- Michigan Team — US
- Missouri Team — US
- Montana Team — US
- Namibia Team
- Nevada Team — US
- New Hampshire Team — US
- New Jersey Team — US
- Northeastern Team — US
- Panama Team
- Paraguay Team
- Qatar Team
- Quebec Team
- Rhode Island Team — US
- Senegal Team
- South Carolina Team — US
- South Dakota Team — US
- Switzerland Team
- Tamil Team — India
- Tennessee Team — US
- Trinidad & Tobago Team
- Uganda Team
- United Kingdom Team
- US LoCo Teams
- Venezuela Team
- Wales Team
- Washington DC Team — US
- Washington State Team — US
- Wisconsin Team
- Yemen Team
- Za Team — South Africa
- Zimbabwe Team
- Americas LoCo Teams
- Other OS Support and Projects
- Ubuntu Official Flavours Support
Bookmarks
Bookmarks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts