Last active
May 30, 2019 13:28
-
-
Save semihkekul/87f9e263e9a804e2646764ec736062a3 to your computer and use it in GitHub Desktop.
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 bar(); | |
void foo(){ | |
bar(); | |
} | |
int main(){ | |
foo(); | |
return 0; | |
} | |
/******************************************************************/ | |
$ g++ linking.cpp -save-temps | |
linking.o: In function `foo()': | |
linking.cpp:(.text+0x5): undefined reference to `bar()' | |
collect2: error: ld returned 1 exit status | |
$ nm linking.o | |
U _GLOBAL_OFFSET_TABLE_ | |
U _Z3barv | |
0000000000000000 T _Z3foov | |
000000000000000c T main |
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 bar(); | |
void foo(){ | |
//bar(); | |
} | |
int main(){ | |
foo(); | |
return 0; | |
} | |
$ g++ linking.cpp -save-temps | |
no error | |
$ nm linking.o | |
0000000000000000 T _Z3foov | |
0000000000000007 T main |
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 bar(); | |
void foo(){ | |
bar(); | |
} | |
int main(){ | |
//foo(); | |
return 0; | |
} | |
$ g++ linking.cpp -save-temps -O1 | |
linking.o: In function `foo()': | |
linking.cpp:(.text+0x5): undefined reference to `bar()' | |
collect2: error: ld returned 1 exit status | |
$ nm linking.o | |
U _GLOBAL_OFFSET_TABLE_ | |
U _Z3barv | |
0000000000000000 T _Z3foov | |
000000000000000e T main |
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 bar(); | |
static void foo(){ | |
bar(); | |
} | |
int main(){ | |
//foo(); | |
return 0; | |
} | |
$ g++ linking.cpp -save-temps -O1 | |
no error | |
$ nm linking.o | |
0000000000000000 T main |
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 bar(); | |
static void foo(){ | |
bar(); | |
} | |
int main(){ | |
//foo(); | |
return 0; | |
} | |
$ g++ linking.cpp -save-temps -O0 | |
linking.o: In function `foo()': | |
linking.cpp:(.text+0x5): undefined reference to `bar()' | |
collect2: error: ld returned 1 exit status | |
$ nm linking.o | |
U _GLOBAL_OFFSET_TABLE_ | |
U _Z3barv | |
0000000000000000 T _Z3foov | |
000000000000000c T main |
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
/* linkingHelper.cpp content */ | |
void bar(){} | |
/******************************************************************/ | |
/* linking.cpp content */ | |
void foo(){ | |
bar(); | |
} | |
int main(){ | |
foo(); | |
return 0; | |
} | |
$ g++ linking.cpp linkingHelper.cpp -save-temps -O1 | |
no error | |
$ nm linking.o | |
U _GLOBAL_OFFSET_TABLE_ | |
U _Z3barv | |
0000000000000000 T _Z3foov | |
000000000000000e T main |
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
/* linkingHelper.cpp content */ | |
static void bar(){} | |
/******************************************************************/ | |
/* linking.cpp content */ | |
void foo(){ | |
bar(); | |
} | |
int main(){ | |
foo(); | |
return 0; | |
} | |
$ g++ linking.cpp linkingHelper.cpp -save-temps -O1 | |
linking.o: In function `foo()': | |
linking.cpp:(.text+0x5): undefined reference to `bar()' | |
linking.o: In function `main': | |
linking.cpp:(.text+0x13): undefined reference to `bar()' | |
collect2: error: ld returned 1 exit status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment