![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compile gcc on AIX 5.2 | untamed | AIX | 7 | 01-31-2008 02:21 AM |
| How do I compile source undfer Suse Linux? | Mark Ward | Linux | 3 | 05-26-2006 10:28 AM |
| ¿compile .ksh? | DebianJ | Shell Programming and Scripting | 1 | 05-09-2005 01:33 PM |
| Compile freeBSD binaries in Linux | shalmoo | High Level Programming | 0 | 10-01-2003 12:38 AM |
| How to compile using gcc... | lilprogrammer | High Level Programming | 4 | 08-21-2002 09:48 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
hi everyone,
i am a beginner of C and doing a subject which involved c programming under unix. i tried compile the c program under linux. but i can only get the a.out file in /usr/bin, not in the current dir. can anyone know how to change the sys. configration. Please help. thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
The C compiler does not know what to call your final executable, so it has defaulted the name to a.out.
It is unusual for the compiler to place the output in the /usr/bin directory, usually it is placed into your current directory. Nearly all compiliers, including those on Unix and Linux will accept a number of command line switches and parameters. By using command line parameters you can change the behaviour of the compiler significantly. See for yourself by doing: man cc or man gcc This will give you a very lengthy description of what to expect from your compiler. Also read the man page on your linker. man ld Somewhere in that lot will be a way to change the output file name. If necessary you can give it an explicit path name. Finally, if you did not realise it already, the a.out file is (or should be) a fully runnable executable. You can always rename it using the move or copy command! Regards MBB.
__________________
Senior Analyst/Programmer |
|
#3
|
||||
|
||||
|
I'm not sure why your resulting "a.out" file is
ending up in /usr/bin BUT... normally you would have to be a priviledged user (i.e. root) to be able to write into that directory. I would strongly recommend that you DO NOT experiment with writing and compiling programs as root (or any other priviledged user). Login to your system as an ordinary user to do this sort of thing. On directing the compiler, try the "-o" option to generate your executable... gcc -o hello hello.c ...will compile the C program "hello.c" and will create an executable file called "hello" in the current working directory. |
||||
| Google The UNIX and Linux Forums |