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; }