Knowee
Questions
Features
Study Tools

Create a script called create_static_lib.sh that creates a static library called liball.a from all the .c files that are in the current directory.julien@ubuntu:~/0x09. Static Librairies$ ls *.c0-isupper.c 0-strcat.c 1-isdigit.c 1-strncat.c 2-strlen.c 3-islower.c 3-strcmp.c 4-isalpha.c 5-strstr.c 9-strcpy.c _putchar.c0-memset.c 100-atoi.c 1-memcpy.c 2-strchr.c 2-strncpy.c 3-puts.c 3-strspn.c 4-strpbrk.c 6-abs.cjulien@ubuntu:~/0x09. Static Librairies$ ./create_static_lib.sh julien@ubuntu:~/0x09. Static Librairies$ ls *.aliball.ajulien@ubuntu:~/0x09. Static Librairies$ ar -t liball.a0-isupper.o0-memset.o0-strcat.o100-atoi.o1-isdigit.o1-memcpy.o1-strncat.o2-strchr.o2-strlen.o2-strncpy.o3-islower.o3-puts.o3-strcmp.o3-strspn.o4-isalpha.o4-strpbrk.o5-strstr.o6-abs.o9-strcpy.o_putchar.ojulien@ubuntu:~/0x09. Static Librairies$

Question

Create a script called create_static_lib.sh that creates a static library called liball.a from all the .c files that are in the current directory.julien@ubuntu:~/0x09. Static Librairiesls.c0isupper.c0strcat.c1isdigit.c1strncat.c2strlen.c3islower.c3strcmp.c4isalpha.c5strstr.c9strcpy.cputchar.c0memset.c100atoi.c1memcpy.c2strchr.c2strncpy.c3puts.c3strspn.c4strpbrk.c6abs.cjulien@ubuntu: /0x09.StaticLibrairies ls *.c0-isupper.c 0-strcat.c 1-isdigit.c 1-strncat.c 2-strlen.c 3-islower.c 3-strcmp.c 4-isalpha.c 5-strstr.c 9-strcpy.c _putchar.c0-memset.c 100-atoi.c 1-memcpy.c 2-strchr.c 2-strncpy.c 3-puts.c 3-strspn.c 4-strpbrk.c 6-abs.cjulien@ubuntu:~/0x09. Static Librairies ./create_static_lib.sh julien@ubuntu:~/0x09. Static Librairiesls.aliball.ajulien@ubuntu: /0x09.StaticLibrairies ls *.aliball.ajulien@ubuntu:~/0x09. Static Librairies ar -t liball.a0-isupper.o0-memset.o0-strcat.o100-atoi.o1-isdigit.o1-memcpy.o1-strncat.o2-strchr.o2-strlen.o2-strncpy.o3-islower.o3-puts.o3-strcmp.o3-strspn.o4-isalpha.o4-strpbrk.o5-strstr.o6-abs.o9-strcpy.o_putchar.ojulien@ubuntu:~/0x09. Static Librairies$

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To create a script that creates a static library from all the .c files in the current directory, follow these steps:

  1. Open your terminal.

  2. Navigate to the directory containing your .c files using the cd command.

  3. Create a new file called create_static_lib.sh using the touch command like so: touch create_static_lib.sh.

  4. Open this file in your text editor. You can use the nano command for this: nano create_static_lib.sh.

  5. In the opened file, write the following script:

#!/bin/bash
gcc -c *.c
ar -rc liball.a *.o

This script first compiles all .c files in the current directory into object files (.o files) with the gcc -c *.c command. Then it archives these object files into a static library called liball.a with the ar -rc liball.a *.o command.

  1. Save and close the file. If you're using nano, you can do this by pressing Ctrl+X, then Y, then Enter.

  2. Now you need to make your script executable. You can do this with the chmod command like so: chmod +x create_static_lib.sh.

  3. You can now run your script with the following command: ./create_static_lib.sh.

  4. If everything went well, you should now have a static library called liball.a in your current directory. You can check this with the ls command.

  5. To see the object files contained in your static library, you can use the ar -t liball.a command.

This problem has been solved

Similar Questions

What command(s) can be used to list the symbols stored in a static library?

What command(s) can be used to list the symbols stored in a static library?ldarranlibnm

What command(s) can be used to list the symbols stored in a static library?Select all valid answersldarranlibnmI don't knowSubmit

Which of the following is an example of a dynamic linking library in Linux?Select one:a. .lib (library)b. .dylib (dynamic library)c. .so (shared object)d. .dll (dynamic link library)

Write a script that compiles a C file but does not link.The C file name will be saved in the variable $CFILEThe output file should be named the same as the C file, but with the extension .o instead of .c.Example: if the C file is main.c, the output file should be main.o

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.