Linking libraries?
- From: "Solar" <geeker87@xxxxxxxxx>
- Date: 30 May 2006 02:36:23 -0700
Hi,
I'm a bit new to assembly. I'm programming on a linux machine (using
nasm) and as part of a programming challenge set by a friend, I am
trying to write a program that gets and displays the PATH environment
variable.
I made a stub C program to get the environment variable and found that
getenv() leaves a pointer to the string in eax, etc (please bear with
me, a lot of this stuff is new to me and I can't find any good
tutorials on the web).
However, I'm having a problem linking my program.
At the top of the file I have:
extern _getenv
global _start
section .data
; yada yada
section .text
; yada yada
As I was made aware that this is the way to tell ld that the getenv
function is in another object(? - I could be wrong, feel free to
correct me :))
I'm getting the following errors:
matt@matrix ~ $ ld -o path path.o
path.o: In function `_start':
path.asm:(.text+0x6): undefined reference to `_getenv'
Its a bit mystical to me, as far as I can see its all correct. I
thought that maybe part of the problem would be how I'm using ld, but I
couldn't find anything in the man pages.
If anyone could point me in the right direction as to how I'd solve
this, it would be very helpful :) Also, if anyone has any suggestions
for any online tutorials that are specific to assembly programming
under linux, that would be helpful too. Being the generic student, I'm
too poor/lazy to buy one (delete as appropriate)!
.
- Follow-Ups:
- Re: Linking libraries?
- From: Frank Kotler
- Re: Linking libraries?
- From: Julienne Walker
- Re: Linking libraries?
- From: Dirk Wolfgang Glomp
- Re: Linking libraries?
- Prev by Date: Re: NASM
- Next by Date: Re: Linking libraries?
- Previous by thread: Re: itoa assembly version
- Next by thread: Re: Linking libraries?
- Index(es):
Relevant Pages
|