Last active
October 17, 2023 02:35
-
-
Save selfboot/f4943c0a09fe8b333df64f2098eeed16 to your computer and use it in GitHub Desktop.
Suppose there is a main.cpp which depends on utils.cpp and static libraries static_A, and static libraries static_A depend on static libraries static_B, here static_A compile without -fno-omit-frame-pointer, but everything else with -fno-omit-frame-pointer, and the final generated binary, each static library and cpp Do functions in files have fr…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree | |
. | |
├── main.cpp | |
├── Makefile | |
├── static_A | |
│ ├── static_A.cpp | |
│ └── static_A.h | |
├── static_B | |
│ ├── static_B.cpp | |
│ └── static_B.h | |
├── utils.cpp | |
└── utils.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <unistd.h> | |
#include "utils.h" | |
#include "static_A/static_A.h" | |
void function_entry(){ | |
write(1, "Inside main function\n", 21); | |
printUtils(); | |
printStaticA(); | |
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | |
} | |
int main() { | |
while (true) { | |
function_entry(); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile | |
all: main | |
main: main.o utils.o libstatic_A.a libstatic_B.a | |
g++ -fno-omit-frame-pointer main.o utils.o -L. -lstatic_A -lstatic_B -o main | |
main.o: main.cpp utils.h static_A/static_A.h static_B/static_B.h | |
g++ -fno-omit-frame-pointer -c main.cpp | |
utils.o: utils.cpp utils.h | |
g++ -fno-omit-frame-pointer -c utils.cpp | |
libstatic_A.a: static_A/static_A.o | |
ar rvs libstatic_A.a static_A/static_A.o | |
libstatic_B.a: static_B/static_B.o | |
ar rvs libstatic_B.a static_B/static_B.o | |
static_A/static_A.o: static_A/static_A.cpp static_A/static_A.h static_B/static_B.h | |
g++ -fno-omit-frame-pointer -I./static_B -c static_A/static_A.cpp -o static_A/static_A.o | |
static_B/static_B.o: static_B/static_B.cpp static_B/static_B.h | |
g++ -fno-omit-frame-pointer -c static_B/static_B.cpp -o static_B/static_B.o | |
clean: | |
rm -f *.o *.a main static_A/*.o static_B/*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <thread> | |
#include "static_B.h" | |
void printStaticA() { | |
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | |
printStaticB(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
void printStaticA(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <thread> | |
void printStaticB() { | |
std::this_thread::sleep_for(std::chrono::milliseconds(20)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
void printStaticB(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <thread> | |
void printUtils() { | |
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
void printUtils(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment