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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:25:04+00:00 2026-05-16T11:25:04+00:00

I need to link my C++ programs against a couple shared libraries which generate

  • 0

I need to link my C++ programs against a couple shared libraries which generate way too much output to std::cout and std::cerr rendering them both useless for my uses. I have access to the C++ source code of these libraries, but cannot modify them.

Is there a way to redirect their output to a different stream or suppress it when linked against my code? I would prefer a clean way in C++, but fearing that that would be impossible I will also be happy with dirty linker hacks. Also a “proxy libstdc++” would be fine as a last resort.

I am working with a GNU toolchain (g++, libtool, ld) under Linux.

  • 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-05-16T11:25:05+00:00Added an answer on May 16, 2026 at 11:25 am

    Well nobody seems to have hit on it, here’s my linker suggestions:

    1. Interpose libc, provide your own write(), and filter output to file descriptors 1 and 2.
    2. Statically link your own code against libc, and then interpose the shared version to squelch write() as above.
    3. Interpose libc, providing a my_write() function that bypasses write() using dlsym().
    4. Wrap write when linking the shared libraries by passing -Wl,--wrap=write. Then squelch any output to file descriptors 1 and 2 in a function called __wrap_write. Other file descriptors should call through to __real_write.

    Note that for those that aren’t aware, file descriptors 1 and 2 correspond to stdout and stderr, which are eventually written to in the cout/cerr machinery. Often this is implemented cout calls fwrite which calls write, with varying levels of buffering and shenanigans at the different levels.

    Your best bet is option 4, the downside is you must tweak the final link for the shared libraries.

    Next best is option 2 above, the downside is your final executable is much bigger, but don’t have to use silly functions in your own code.

    Links

    Interposing

    • http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
    • http://www.jayconrod.com/cgi/view_post.py?23
    • http://dictionary.die.net/interposing
    • http://developers.sun.com/solaris/articles/lib_interposers.html

    Wrapping

    • http://www.jayconrod.com/cgi/view_post.py?23
    • http://okmij.org/ftp/syscall-interpose.html
    • Function interposition in Linux without dlsym
    • http://sourceware.org/ml/binutils/2000-09/msg00083.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 522k
  • Answers 522k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I need to convert it either to greyed-out/disabled using Image… May 16, 2026 at 9:23 pm
  • Editorial Team
    Editorial Team added an answer The radio's parent isn't actually the table row, it's the… May 16, 2026 at 9:23 pm
  • Editorial Team
    Editorial Team added an answer The answer can be found in the IEEE specification of… May 16, 2026 at 9:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm having trouble with Poco libraries. I need a simple solution to make the
I need to attach a file with mailx but at the moment I am
I'm building a C++ application and need to use PDCurses on Windows. I'm compiling
I need to control inbound and outbound traffic to/from a linux box from within
I need to understand the working of this particular program, It seems to be
Here is my old question Link I ask a question before,But I put the
If you check this link http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=107 it's written: For example, the abort() and exit()
I have a need to verify a specific hyperlink exists on a given web
I have a folder containing .tcb and .tch files. I need to know what
I'm working on refactoring a suite of old utilities and creating a new server

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.