Last active
December 18, 2015 02:19
-
-
Save rnapier/5710509 to your computer and use it in GitHub Desktop.
Example of circular linking issues with g++. See http://stackoverflow.com/questions/16926608/including-static-libraries-with-all-load-flag
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
void A() {} | |
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
void A(); | |
void Aprime(); | |
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
void Aprime() {} | |
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 "a.h" | |
void B() { | |
Aprime(); | |
} | |
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
void B(); | |
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
all: test | |
testa: source.o libA.a libB.a | |
g++ source.cpp -o test libA.a libB.a | |
testb: | |
g++ source.cpp -o test libB.a libA.a | |
libA.a: a.o aprime.o | |
ar -r libA.a a.o aprime.o | |
libB.a: b.o | |
ar -r libB.a b.o | |
clean: | |
rm -f *.o test *.a | |
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 "a.h" | |
#include "b.h" | |
int main (int argc, char const *argv[]) | |
{ | |
A(); | |
B(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment