i have three files an assembly file.
an file main.c jus to print hello
and an include file which contains print function.
how to compile it in gcc and link it..
help on compiling code
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
http://users.actcom.co.il/~choo/lupg/tu ... -unix.html
That file (first on google!) gives background info on how to compile C programs.
http://www.osdev.org/wiki/Bare_bones
Shows you how to integrate assembly into a C project (which is probably what you are doing).
Before we can help you more, we need to know more about your project and compilation environment. Are you using Cygwin? Linux? Visual Studio 2008 Enterprise?
Also, is the include file a .c or a .h file, or something different?
Edit: Better input, better output. More info always helps. Also, if you have tried to compile it yourself, tell us what commands you used and where you got stuck. Then we can really get going.
That file (first on google!) gives background info on how to compile C programs.
http://www.osdev.org/wiki/Bare_bones
Shows you how to integrate assembly into a C project (which is probably what you are doing).
Before we can help you more, we need to know more about your project and compilation environment. Are you using Cygwin? Linux? Visual Studio 2008 Enterprise?
Also, is the include file a .c or a .h file, or something different?
Edit: Better input, better output. More info always helps. Also, if you have tried to compile it yourself, tell us what commands you used and where you got stuck. Then we can really get going.
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
You'll want to use something along the lines of the following:
If you don't have a linker.ld, use the one from the Bare Bones tutorial. You should use #include in your C source file to include the header file.
Give that a go, and report any problems you have, we'll help you sort it out. Best bet is to just try different things until one works.
Code: Select all
gcc -c source.c -o source.o
nasm -f elf -o loader.o loader.s
ld -T linker.ld source.o loader.o
Give that a go, and report any problems you have, we'll help you sort it out. Best bet is to just try different things until one works.
these are the two files
help me in compiling and linking these files..
- Attachments
-
- Desktop.rar
- these r the files
- (891 Bytes) Downloaded 18 times
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Things to do:
1. Clean Up code (Indent and add a header - project name and file pourpose)
2. Create `texmem` variable (unsigned char)
3. Create clear_screen() and newline() functions
4. Compile using Yayyak's instructions and the linker.ld file from the barebones tutorial.
If you are having problems post your problem with the error messages included please.
Also, don't upload attachments in RAR format, use ZIP or tar.gz, it makes life easier for all of us.
-- Sorry if this seems condescending, I'm getting a bit tired --
1. Clean Up code (Indent and add a header - project name and file pourpose)
2. Create `texmem` variable (unsigned char)
3. Create clear_screen() and newline() functions
4. Compile using Yayyak's instructions and the linker.ld file from the barebones tutorial.
If you are having problems post your problem with the error messages included please.
Also, don't upload attachments in RAR format, use ZIP or tar.gz, it makes life easier for all of us.
-- Sorry if this seems condescending, I'm getting a bit tired --
The errors you are getting is because your assembly file is in AT&T syntax, while you're trying to compile it with NASM. Assemble it with GAS instead via GCC, like so:
Note: Are you sure you're good for OSdev? From what you've said so far, it doesn't seem like you have the slightest idea what your doing. Are you proficient in C and do you know the basics of assembly? See if you have the Required Knowledge.
Code: Select all
gcc -c source.c -o source.o
gcc -c loader.S -o loader.o
ld -T linker.ld source.o loader.o
"Sufficiently advanced stupidity is indistinguishable from malice."