Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:06:23+00:00 2026-06-15T06:06:23+00:00

I’ve created simplest EXECUTABLE and SHARED_LIBRARY. SHARED_LIBRARY doesn’t get loaded without changing LD_LIBRARY_PATH: #

  • 0

I’ve created simplest EXECUTABLE and SHARED_LIBRARY.
SHARED_LIBRARY doesn’t get loaded without changing LD_LIBRARY_PATH:

# ./hello
./hello
link_image[1995]: failed to link ./hello
CANNOT LINK EXECUTABLE

# LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./hello
Hello, world!

All code below:

first.h

#ifndef FIRST_H
#define FIRST_H

extern int first(int x, int y);

#endif /* FIRST_H */

first.c

#include "first.h"

int first( int x, int y ) {
    return x + y;
}

hello.c

#include <stdio.h>
#include "first.h"

int main( int argc, char **argv ) {
    printf( "Hello, world!\n" );
    first( 1000, 24 );
    return 0;
}

Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE    := first
LOCAL_SRC_FILES := first.c
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := hello
LOCAL_SRC_FILES := hello.c
LOCAL_SHARED_LIBRARIES := first
LOCAL_LDFLAGS := -Wl,-rpath,. -Wl,-rpath,/data/data/testlib/lib
include $(BUILD_EXECUTABLE)

readelf –all hello

...
Dynamic section at offset 0xef4 contains 25 entries:
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  INTERP         0x000154 0x00008154 0x00008154 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /system/bin/linker]
...
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libfirst.so]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x0000000f (RPATH)                      Library rpath: [.:/data/data/testlib/lib]

RPATH is here, but linker doesn’t use it for some reason.

Apparently dynamic linker works just fine on Android (with LD_LIBRARY_PATH and it’s no different RPATH either)

What do I do wrong?

Am I missing something obvious?

RPATH has two directories in my example, (.:/data/data/testlib/lib), one (.) should be sufficient.

There is no Java in this example. It’s not used and not needed for the project.

Basically I’m looking for a standard way to load shared libraries from “my directory” without changing LD_LIBRARY_PATH (it’s not possible sometimes) or using wrapper to dlopen all required libs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:06:24+00:00Added an answer on June 15, 2026 at 6:06 am

    The Bionic linker-loader (android/bionic/linker/linker.c in the AOSP source, if you want to check) seems to completely ignore RPATH in the ELF. It only considers LD_LIBRARY_PATH and a hardcoded array of “/vendor/lib” and “/system/lib”.

    This is based on a cursory scan of the code on the Ice Cream Sandwich tree I have checked out.

    This would explain the behavior you are seeing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn the jQuery validation plugin, so I created the simplest
I can't even get the simplest kind of binding library to work - I
I've created the simplest possible WPF control - It just overrides OnRender and draws
I created a plugin to bottom-align a element. In it's simplest form I did
What is the best/simplest way to detect if a queue I have created is
I created the simplest app ever - I basically just want to iframe my
Possible Duplicate: 19 Threads for WPF Application I just created a simplest WPF application
Using a VS2010 SP1 Data-tier application project, I created the simplest database I could:
This is probably an easy solution. I have created the simplest WCF host in
After trying to get sftp working ive ended up with the simplest possible sample

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.