|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi,
How do we go about compiling the program with -static and -Wall? Why is there a need to use -static when we can compile using: gcc -Wall -o file file.c? I tried using gcc -Wall -static file file.c but there are quite a number of warnings from this statement. Can someone please help? Thanks in advance! =) |
| Sponsored Links |
|
|
|
|||||
|
You use -static to compile the libraries into the executable. This way the user doesn't have to have any additional libraries installed in order for the program to run. When you compile without -static you are linking dynamically.
What errors do you receive when you compile with -static?
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages! |
|
|||
|
Hi Jordan, thanks for your reply =)
gcc -Wall -static fork fork.c results in error: gcc: fork: No such file or directory. After trying again, I finally used command line: gcc -Wall -g -c -o fork -static fork.c and it compile with no errors. But when I tried to do a strace ./fork, there was an error saying: ERROR: unable to open /dev/log. I'm not sure what was happening. I'm using SSH (Secure Shell Client) to run my command. |
|
|||
|
Quote:
-c tells it to compile only, do not create an executable. -o allows you to name the intermediate object file. So, you are in effect not making an executable, so there is nothing to trace. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |