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

  • Home
  • SEARCH
  • 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 8023079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:27:47+00:00 2026-06-04T22:27:47+00:00

Below are the steps of how I generate the executable file using shared library.

  • 0

Below are the steps of how I generate the executable file using shared library.

  1. I have three files:

    File libhello.c

    /* hello.c - demonstrate library use. */
    #include <stdio.h>
    void hello(void)
    { 
        printf("Hello, library world./n");
    }
    

    File libhello.h

    /* hello.h - demonstrate library use. */
    void hello(void);
    

    File main.c

    /* main.c -- demonstrate direct use of the "hello" routine */
    #include "hello.h"
    int main(void)
    {
        hello();
        return 0;
    }
    
  2. I use the commands below to generate the shared library.

    gcc -g -Wall -fPIC -c hello.c -o hello.o
    gcc -shared -W,soname,-libhello.so.0 -o libhello.so.0.0.0 hello.o
    
  3. Finally, I add the library path to the LD_LIBRARY_PATH variable and try to create the executable file using the shared library.

    export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
    ln -s libhello.so.0.0.0 libhello.so.0
    gcc -g -Wall -c main.c -o main.o -I.
    gcc -o main main.o -lhello -L.
    

However, at the last step, there is one error: can’t find -lhello. So, where am I wrong?

Thanks.

  • 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-04T22:27:50+00:00Added an answer on June 4, 2026 at 10:27 pm

    gcc looks for libhello.so when linking a new program. libhello.so.0 is used when the dynamic dependencies of an already linked program are searched.

    In other terms: gcc -o main main.o -lhello -L. looks for libhello.so, and ./main looks for libhello.so.0. This allows to have multiple versions of a library available for legacy programs while precisely identifying the library that matches the installed headers.

    A symlink libhello.so -> libhello.so.0.0.0 should do the trick.

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

Sidebar

Related Questions

Following the steps detailed in http://msdn.microsoft.com/en-us/library/zt39148a.aspx#Y684 , I have created a Windows service which
Below is what I have +++++++++++++++++ +id1 + id2 + +++++++++++++++++ + 1 +
Below is what I have in my table. myTable ++++++++++++++++++++ Parent + Child ++++++++++++++++++++
Below is the code i'm looking at the moment. <s:View xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark title=data xmlns:model=model.*
Below are two programs that write 50,000,000 bytes to a file. The first program,
I found I could generate XDocument object from html by using SgmlReader.SL. https://bitbucket.org/neuecc/sgmlreader.sl/ The
I currently have the following code to generate a sales report over the last
I have two tables that i am inserting records into. I am using PHP
I have been working on the introduction on the link below and have been
Below I have a thread that updates a 'clock' label once per second. Once

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.