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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:54:41+00:00 2026-06-12T19:54:41+00:00

I have two projects written in C++. Suppose that the projects are named first

  • 0

I have two projects written in C++. Suppose that the projects are named first and second, the first being the base project, the second project has addons for the first so when I build and install the second project, it just adds to the functionality of the first.

I created two separate Makefile projects ‘first’ and ‘second’ and I am able to build both of them separately.

My problem is that I am not able to link the binaries generated in the ‘first’ as the base binaries for the ‘second’. I tried searching for similar questions on stackoverflow but I did not get any idea on how to link binaries generated in the ‘first’ to ‘second’, any help would be greatly appreciated.

Let me know if I need to reframe my question.

  • 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-12T19:54:42+00:00Added an answer on June 12, 2026 at 7:54 pm

    If you are using GCC, and read the reference for linker options you will notice to options for linking with external libraries:

    • -L<directory>

      This option tells the linker to add <directory> to the library search path. In other words, it tells the linker where to find library files.

    • -l<name-of-lib>

      This option tells the linker to link with a library. Libraries in POSIX environments (Linux, OSX, Windows using Cygwin or MinGW) are named like libname-of-lib.a, but with the -l option you don’t need to use the lib prefix or the .a extension. Also note that in the option -l, that is the small letter L (not capital i or the digit 1).

    To summarise: To link with a library from another directory you link like this:

    $ gcc <other flags> <object files> -o <executable> -L<directory> -l<library>
    

    In your case you should for the -L option specify the directory where the library for project1 is, and for the -l option you pass the basic name of the library.


    If on the other hand you don’t turn project1 into a library, and want to link with its object files directly, that’s fine too:

    $ gcc <flags> <object files of project1> <object files of project2> -o <executable>
    

    The object files can of course be full or relative paths. For example, if you have the following directory structure:

    /
    `-- home
        `-- user
            `-- myproject
                |-- project1
                `-- project2
    

    Then in if you are in the project2 directory you can access object files from project1 like

    ../project1/objectfile.o
    

    All of this can of course be placed in a Makefile.

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

Sidebar

Related Questions

I have two projects.One project is build in MVC asp.net and the other project
We have two projects that are both class libraries. Project 1 is a VS
I have been gone into a project (written in advance) that has some kind
I have two projects: 1) a project written in Visual C++ 2005 which targets
I have two projects, project A and Project B. Both are written in groovy
I have two visual studio projects, one written in C#, another written in fortran
I have two projects in my Solution. One implements my business logic and has
I have two projects in my solution   1- asp.net web project.   2-
I have a hobby project that is written in C# using MonoDevelop. I've been
I have been assigned a project with a lot of poorly written code that

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.