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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:10:43+00:00 2026-06-01T15:10:43+00:00

My requirement is to work on some interface .h files. Right now I have

  • 0

My requirement is to work on some interface .h files. Right now I have .h and .cpp/.cc files in my project.

I need to compile it into shared 64-bit linux compatible library (*.so), using NetBeans/ Eclipse on Linux Fedora.

  • 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-01T15:10:45+00:00Added an answer on June 1, 2026 at 3:10 pm

    If you are compiling a library from the 3 C++ source files called a.cc, b.cc, and c.cc respectively;

    
    g++ -fpic -Wall -c a.cc
    
    g++ -fpic -Wall -c b.cc
    
    g++ -fpic -Wall -c c.cc
    
    g++ -shared -Wl,-soname,libmylib.so.0 -o libmylib.so.0.0.0 a.o b.o c.o
    

    Then you install the library using ldconfig, see

    man 8 ldconfig

    you can then compile the program that uses the libary as follows (but be sure to prefix

    extern "C"

    before the class declarations in the header files included in the source code using the library.)

    g++ -o myprog main.cc -lmylib

    I have tried these compile options with my own sample code, and have been successful.

    Basically What is covered in Shared Libraries applies to C++, just replace gcc with g++.

    The theory behind all of this is;

    Libraries are loaded dynamically when the program is first loaded, as can be confirmed by doing a system call trace on a running program, e.g. strace -o trace.txt ls which will dump a list of the system calls that the program made during execution into a file called trace.txt. At the top of the file you will see that the program (in this case ls) had indeed mmapped all the library’s into memory.

    Since libraries are loaded dynamically, it is unknown at link time where the library code will exist in the program’s virtual address space during run time. Therefore library code must be compiled using position independent code – Hence the -fpic option which tells the translation stage to generate assembly code that has been coded with position independent code in mind. If you tell gcc/g++ to stop after the translation stage, with the -S (upper case S) option, and then look at resulting ‘.s’ file, once with the -fpic option, and once without, you will see the difference (i.e. the dynamic code has @GOTPCREL and @PLT, at least on x86_64).

    The linker, of course must be told to link all the ELF relocatatable object types into executable code suitable for use as a Linux shared library.

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

Sidebar

Related Questions

Now there is a new requirement. I have got some adhoc work at hand.
I need some idea to implement the following requirement in the web application .
I have a requirement for implementing a data-store. Basically, I just need to be
I have written some code based on a specification from my boss. A requirement
I have a need to do some real-time reporting on the functionality of a
I'm doing some R&D work, and as such am exploring design patterns. I have
Where I work it is a requirement for us to go through stored procedures
Requirement is this ... We have our 3 web-applications deployed in RHEL-5 server, we
Requirement: I need to run multiple animations one by one. I'm using onAnimationEnd() to
Requirement of my app is to have UINavigationController at the bottom with play, rewind

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.