Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-2007, 07:06 AM
littlevamp littlevamp is offline
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0
littlevamp is on a distinguished road
Default Compiler using -Wall and -static

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! =)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-08-2007, 02:34 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,650
Last Blog:
PHP Objects, Patterns,...
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-08-2007, 10:05 PM
littlevamp littlevamp is offline
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0
littlevamp is on a distinguished road
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-10-2007, 05:24 AM
Cynic Cynic is offline
Newbie
 
Join Date: Sep 2007
Posts: 4
Rep Power: 0
Cynic is on a distinguished road
Default

Quote:
Originally Posted by littlevamp View Post
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.
It's been a while since I compiled using gcc, but let me see if I can get this right.

-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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 04:53 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads