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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:43:31+00:00 2026-05-15T20:43:31+00:00

I am using an older system that has gcc 2.95.3, I have to link

  • 0

I am using an older system that has gcc 2.95.3, I have to link in two objects that although they have nothing to do with each other, they each have similarly named methods. I can’t rename either of them, but I would hope there is a way to build them as to not have the linker complain. The methods it is complaining about are each internally called by classes within the object. What can I do?

  • 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-15T20:43:31+00:00Added an answer on May 15, 2026 at 8:43 pm

    If you have a complete GNU toolchain, you should be able to work around your problem using objcopy, like this (if I’ve understood your problem correctly):

    Here are two very similar objects, “foo” and “bar”, both of which export a symbol called clash – which is used internally, but doesn’t really need to be exported at all:

    $ cat foo.c
    #include <stdio.h>
    void clash(char *s) { printf("foo: %s\n", s); }
    void foo(char *s) { clash(s); }
    $ 
    

    and

    $ cat bar.c
    #include <stdio.h>
    void clash(char *s) { printf("bar: %s\n", s); }
    void bar(char *s) { clash(s); }
    $ 
    

    And here’s the main code, which wants to use both:

    $ cat main.c
    extern void foo(char *s);
    extern void bar(char *s);
    
    int main(void)
    {
        foo("Hello");
        bar("world");
        return 0;
    }
    $ 
    

    Linking them together doesn’t work:

    $ gcc -Wall -c foo.c  
    $ gcc -Wall -c bar.c
    $ gcc -Wall -c main.c
    $ gcc -o test main.o foo.o bar.o
    bar.o: In function `clash':
    bar.c:(.text+0x0): multiple definition of `clash'
    foo.o:foo.c:(.text+0x0): first defined here
    collect2: ld returned 1 exit status
    $ 
    

    So, use objcopy to change the visibility of clash in one (or both, if you like!) of the objects:

    $ objcopy --localize-symbol=clash bar.o bar2.o
    $ 
    

    Now you can link successfully with the modified object – and the program behaves as it should:

    $ gcc -o test main.o foo.o bar2.o
    $ ./test
    foo: Hello
    bar: world
    $ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some older (broken) code that has a join using a *= table1.ID
I have two programs written in C++ that use Winsock. They both accept TCP
I am working with an order system that has two tables Order and OrderLine
I'm using Entity Framework 4.1 Code First and I have a table that has
I've got an older ASP/VBScript app that I'm maintaining/upgrading and its currently using the
I have a website that allows users to query for specific recipes using various
I have a webpage that has to be displayed in several different languages based
I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat
Using gcc and ld on x86_64 linux I need to link against a newer
I have a C++ code base that has been working for a long time.

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.