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 7836577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:12:58+00:00 2026-06-02T14:12:58+00:00

I have a closed-source 3rd-party shared library I need to link against. Unfortunately, the

  • 0

I have a closed-source 3rd-party shared library I need to link against. Unfortunately, the creators of the 3rd-party library didn’t bother to limit which symbols are exported and exported all symbols. The 3rd-party library internally uses an incompatible version of a popular library that I am using in my code but exports conflicting symbols (google’s protobuf library). This leads to a runtime error when the protobuffer library version check finds the compile time and run time versions of the library are not compatible. I can solve the problem by reverting to an older version of protobufs 2.3 that matches the version used in the 3rd party library. However, protbuf 2.3 has performance issues that make it unusable slow for my application. I need a way to use protobuf 2.4 in my code and let the 3rd-party library use it’s own internal v 2.3.

Is there a way to generate a new version of the 3rd party library that doesn’t export the symbols from the protobuf v 2.3 library used internally given only the so file? If I had the source, it would be an easier problem. It seems that tools like objcopy and strip can’t actually modify the dynamic symbol table. The only idea I have so far is to create my own shim library that exports only the symbols I need by redirecting calls to the 3rd-party library (opened with dlopen perhaps?).

Is there a better solution?

  • 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-02T14:13:00+00:00Added an answer on June 2, 2026 at 2:13 pm

    I found a solution that works… I created a shim library that redirects calls to the third-party library allowing code outside the library to see protbuf v2.4 symbols while code inside the third-party library sees protobuf v2.3 symbols. This workaround was based on the idea posted here: http://www.linuxjournal.com/article/7795

    I had to modify the dlopen flags to include RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND. The RTLD_LOCAL flag keeps symbols inside the third-party library from being seen outside the shim library (prevents symbols leaking out). The RTLD_DEEPBIND forces calls from inside the 3rd party library to see only the internal version of the symbols (keeps symbols from leaking in).

    To be concrete, here is an example excerpt from my shim library.

    #include <stdio.h>
    #include <stdint.h>
    #include <dlfcn.h>
    #include "libhdfs/hdfs.h"
    
    //#define PRINT_DEBUG_STUFF
    
    // Helper function to retrieve a function pointer to a function from libMapRClient
    // while isolating the symbols used internally from those already linked externaly
    // to workaround symbol collision problem with the current version of libMapRClient.
    void* GetFunc(const char* name){
      #ifdef PRINT_DEBUG_STUFF
        printf("redirecting %s\n", name);
      #endif
      void *handle;
      char *error;
    
      handle = dlopen("/opt/mapr/lib/libMapRClient.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
    
      if (!handle) {
        fputs(dlerror(), stderr);
        exit(1);
      }
      void* fp = dlsym(handle, name);
      if ((error = dlerror()) != 0) {
        fprintf(stderr, "%s\n", error);
        exit(1);
      }
      return fp;
    }
    
    
    hdfsFS hdfsConnect(const char* host, tPort port) {
      typedef hdfsFS (*FP) (const char* host, tPort port);
      static FP ext = 0;
      if (!ext) {
        ext = (FP)GetFunc("hdfsConnect");
      }
      return ext(host, port);
    }
    
    
    int hdfsCloseFile(hdfsFS fs, hdfsFile file) {
      typedef int (*FP) (hdfsFS fs, hdfsFile file);
      static FP ext = 0;
      if (!ext) {
        ext = (FP)GetFunc("hdfsCloseFile");
      }
      return ext(fs, file);
    }
    

    … and so on for the other public API functions

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

Sidebar

Related Questions

I have situation where a 3rd party open source product I am using is
I have a third-party, closed source application that exports a COM interface, which I
I need to verify something for which I have doubts. If a shared library
i have a closed source program that prints output to standard output. i need
Here is my problem: I have a closed-source third-party Win32 application, which acts as
I have a closed source application which put a 13 character long timestamp in
I'm using a library which is closed source that is starting a background task
I have a closed source unmanaged DLL coded in C++ that I wanted to
Suppose I have Project X under closed source. It references/links to component Y which
I have a specific language (its private, and closed source) that I'm writing code

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.