-
-
Save superchausette/0bad76dac41da43ad09b to your computer and use it in GitHub Desktop.
Compilation and static link of static link
This file contains hidden or 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 <stdio.h> | |
void print_name(){ | |
printf("LIB A\n"); | |
} |
This file contains hidden or 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 <stdio.h> | |
void print_name(){ | |
printf("LIB A (BIS) \n"); | |
} | |
void print_name_bis() { | |
print_name(); | |
} |
This file contains hidden or 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 <stdio.h> | |
#define INTERNAL __attribute__((visibility("hidden"))) | |
INTERNAL extern void print_name(); | |
void print_all_name() { | |
printf("Print all name:\n"); | |
print_name(); | |
} |
This file contains hidden or 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
#!/bin/bash | |
rm *.o 2>/dev/null | |
rm *.a 2>/dev/null | |
rm prog 2>/dev/null | |
echo "Compiling A" | |
gcc -W -g -c -o a.o a.c | |
ar rcs liba.a a.o | |
rm *.o 2>/dev/null | |
echo "Compiling ABIS" | |
gcc -W -g -c -o abis.o abis.c | |
ar rcs libabis.a abis.o | |
rm *.o 2>/dev/null | |
echo "Compiling B" | |
gcc -W -g -c -o b.o b.c | |
ar -x liba.a | |
ar rcs libb.a *.o | |
rm *.o 2>/dev/null | |
echo "Compiling PROG" | |
gcc prog.c -L. -lb -labis -o prog | |
rm *.o 2>/dev/null |
This file contains hidden or 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 <stdio.h> | |
extern void print_all_name(); | |
extern void print_name(); | |
extern void print_name_bis(); | |
int main(int argc, char ** argv) { | |
printf("MAIN\n"); | |
print_all_name(); | |
print_name(); | |
print_name_bis(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment