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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:48:53+00:00 2026-05-26T20:48:53+00:00

I have got a f2.cpp file // f2.cpp #include <iostream> void f2() { std::cout

  • 0

I have got a f2.cpp file

// f2.cpp
#include <iostream>

void f2()
{
    std::cout << "It's a call of f2 function" << std::endl;
}

I use cygwin with crosstool compiler gcc.

g++ -fPIC -c f2.cpp
g++ -shared -o libf2.so f2.o

I have got a libf2.so file. Now I want to call f2 function in f1 library (shared object too) libf1.so.

It’s a f1.cpp and i want take f1.so

// f1.cpp
#include <iostream>
void f1()
{
    std::cout << "f1 function is calling f2()..." << std::endl;
    f2();
}

How i must compile f1.cpp? I don’t want to use dlclose, dlerror, dlopen, dlsym…
Аt last i want to use f1.so in main.cpp as a shared object library too… without using use dlclose, dlerror, dlopen, dlsym. How I must compile main.cpp, when i will have a f1.so ?

// main.cpp
#include <iostream>
int main()
{
    f1();
    return 0;
}
  • 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-26T20:48:53+00:00Added an answer on May 26, 2026 at 8:48 pm

    declare f2() in a header file. and compile libf1.so similar to libf2.

    Now compile main linking against f1 and f2.
    It should look something like this
    g++ -lf2 -lf1 -L /path/to/libs main.o

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

Sidebar

Related Questions

I have got a C function in a static library, let's call it A,
Currently, I have this function inside my other cpp file: UINT32 functionHtml(const wchar_t *url)
I have rand.cpp and rand.hpp file and have rand_unif() function. I have included rand.hpp
I have the following C++ code. #include <iostream> using namespace std; int testfunction(int input)
id.cpp #include stdafx.h #include <iostream> using namespace std; class A { public: static int
I have got the following code from here to read an Excel file using
i got a compile error which i do not understand. i have a h/cpp
#include <iostream> #include <fstream> #include <string> using namespace std; int main (int argc, char*
I have a file named test1.cpp namespace a { int main1() { return 3;
Have got an NSString *str = @12345.6789 and want to find out if there

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.