Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   undefined reference to `link' (http://www.velocityreviews.com/forums/t805412-undefined-reference-to-link.html)

Jinsong Zhao 11-01-2011 03:41 PM

undefined reference to `link'
 
Hi there,

I tried to compile a c program
(http://people.sc.fsu.edu/~jburkardt/...lit/f77split.c) using
MinGW/gcc 4.6.1:

gcc f77split.c

however, I get the following error message:

f77split.c:(.text+0x4a9): undefined reference to `link'
collect2: ld returned 1 exit status

However, compiled the same code with gcc 4.4.x on a Linux machine, and
succeed.

Does it mean I missing something on my Windows XP with MinGW/gcc 4.6.1?

Any suggestions will be really appreciated.

Regards,
Jinsong

Mark Bluemel 11-01-2011 03:46 PM

Re: undefined reference to `link'
 
On 11/01/2011 03:41 PM, Jinsong Zhao wrote:
> Hi there,
>
> I tried to compile a c program
> (http://people.sc.fsu.edu/~jburkardt/...lit/f77split.c) using
> MinGW/gcc 4.6.1:
>
> gcc f77split.c
>
> however, I get the following error message:
>
> f77split.c:(.text+0x4a9): undefined reference to `link'
> collect2: ld returned 1 exit status
>
> However, compiled the same code with gcc 4.4.x on a Linux machine, and
> succeed.
>
> Does it mean I missing something on my Windows XP with MinGW/gcc 4.6.1?
>
> Any suggestions will be really appreciated.


The code tries to use the link() (and unlink() I think) routines which
are part of POSIX, not C. They'll be present on a Linux/Unix system, but
probably not on Windows, even wth MinGW.

Jinsong Zhao 11-01-2011 04:01 PM

Re: undefined reference to `link'
 
On 2011-11-1 23:46, Mark Bluemel wrote:
> On 11/01/2011 03:41 PM, Jinsong Zhao wrote:
>> Hi there,
>>
>> I tried to compile a c program
>> (http://people.sc.fsu.edu/~jburkardt/...lit/f77split.c) using
>> MinGW/gcc 4.6.1:
>>
>> gcc f77split.c
>>
>> however, I get the following error message:
>>
>> f77split.c:(.text+0x4a9): undefined reference to `link'
>> collect2: ld returned 1 exit status
>>
>> However, compiled the same code with gcc 4.4.x on a Linux machine, and
>> succeed.
>>
>> Does it mean I missing something on my Windows XP with MinGW/gcc 4.6.1?
>>
>> Any suggestions will be really appreciated.

>
> The code tries to use the link() (and unlink() I think) routines which
> are part of POSIX, not C. They'll be present on a Linux/Unix system, but
> probably not on Windows, even wth MinGW.


yes, the code use link and unlink routines.

Is it possible to compile the code on Windows? If yes, how to change the
code?

Thanks.

Regards,
Jinsong

Mark Bluemel 11-01-2011 04:21 PM

Re: undefined reference to `link'
 
On 11/01/2011 04:01 PM, Jinsong Zhao wrote:
> On 2011-11-1 23:46, Mark Bluemel wrote:
>> On 11/01/2011 03:41 PM, Jinsong Zhao wrote:
>>> Hi there,
>>>
>>> I tried to compile a c program
>>> (http://people.sc.fsu.edu/~jburkardt/...lit/f77split.c) using
>>> MinGW/gcc 4.6.1:
>>>
>>> gcc f77split.c
>>>
>>> however, I get the following error message:
>>>
>>> f77split.c:(.text+0x4a9): undefined reference to `link'
>>> collect2: ld returned 1 exit status
>>>
>>> However, compiled the same code with gcc 4.4.x on a Linux machine, and
>>> succeed.
>>>
>>> Does it mean I missing something on my Windows XP with MinGW/gcc 4.6.1?
>>>
>>> Any suggestions will be really appreciated.

>>
>> The code tries to use the link() (and unlink() I think) routines which
>> are part of POSIX, not C. They'll be present on a Linux/Unix system, but
>> probably not on Windows, even wth MinGW.

>
> yes, the code use link and unlink routines.
>
> Is it possible to compile the code on Windows? If yes, how to change the
> code?


You need to work out what the link and unlink routines are being used
for - I think it's to rename a temporary work file to become an output
file - and then write appropriate code to do that using routines which
are available on Windows. You probably should ask in a windows forum for
help with those routines.


Mike Manilone 11-02-2011 04:42 AM

Re: undefined reference to `link'
 
On 2011-11-01, Jinsong Zhao <jszhao@yeah.net> wrote:
> On 2011-11-1 23:46, Mark Bluemel wrote:
>> On 11/01/2011 03:41 PM, Jinsong Zhao wrote:
>>> Hi there,
>>>
>>> I tried to compile a c program
>>> (http://people.sc.fsu.edu/~jburkardt/...lit/f77split.c) using
>>> MinGW/gcc 4.6.1:
>>>
>>> gcc f77split.c
>>>
>>> however, I get the following error message:
>>>
>>> f77split.c:(.text+0x4a9): undefined reference to `link'
>>> collect2: ld returned 1 exit status
>>>
>>> However, compiled the same code with gcc 4.4.x on a Linux machine, and
>>> succeed.
>>>
>>> Does it mean I missing something on my Windows XP with MinGW/gcc 4.6.1?
>>>
>>> Any suggestions will be really appreciated.

>>
>> The code tries to use the link() (and unlink() I think) routines which
>> are part of POSIX, not C. They'll be present on a Linux/Unix system, but
>> probably not on Windows, even wth MinGW.

>
> yes, the code use link and unlink routines.
>
> Is it possible to compile the code on Windows? If yes, how to change the
> code?


Cygwin may have `link`/`unlink`. Try it.

--
Best Regards,
Mike Manilone.

jgharston 11-02-2011 11:43 AM

Re: undefined reference to `link'
 
Mark Bluemel wrote:
> > yes, the code use link and unlink routines.

> You need to work out what the link and unlink routines are being used
> for - I think it's to rename a temporary work file to become an output


If you're using link/unlink to rename a file, the stdio library
contains
the standard rename() function.

Always start by looking in your standard libraries for the
functionality
you're looking for before going trekking off in other directions.

JGH

Keith Thompson 11-02-2011 09:10 PM

Re: undefined reference to `link'
 
jgharston <jgh@arcade.demon.co.uk> writes:
> Mark Bluemel wrote:
>> > yes, the code use link and unlink routines.

>> You need to work out what the link and unlink routines are being used
>> for - I think it's to rename a temporary work file to become an output

>
> If you're using link/unlink to rename a file, the stdio library
> contains
> the standard rename() function.
>
> Always start by looking in your standard libraries for the
> functionality you're looking for before going trekking off in other
> directions.


rename() doesn't do what the Unix link() system call does.

link() creates a new name for a file. The new name and the old name
both refer to the same file in the same way; neither of them is, in any
real sense, the original.

The C standard library doesn't provide anything with equivalent
functionality -- probably because there's no guarantee that the
underlying OS or filesystem is capable of supporting it.

(I tried using the "ln" command under Cygwin, a Unix emulation layer
that runs on top of MS Windows, and got some odd and inconsistent
results.)

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Keith Thompson 11-02-2011 10:30 PM

Re: undefined reference to `link'
 
gordonb.d5wxg@burditt.org (Gordon Burditt) writes:
[...]
> Note that the link/unlink procedure assumes that this can be done
> repeatedly: if the destination file already exists (left over from
> the last time the code was executed), it is removed; then the rename
> is done.


Not according to the link(2) man page on my system:

If newpath exists it will not be overwritten.

And link() is *not* a form of renaming. It creates a new name for a
file; the old name continues to exist.

[...]

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Keith Thompson 11-03-2011 02:24 AM

Re: undefined reference to `link'
 
gordonb.wk71i@burditt.org (Gordon Burditt) writes:
> Read the code containing two unlink() calls and one link() call.
> *THAT CODE*, not link() alone, performs a rough equivalent of a
> rename().

[...]

What is this in response to? (check parent article) Oh, I see, this is
a followup to my post, and since I've told you not to quote my words
without attribution, you've decided to post followups without quoting
me at all.

In the future, I request that you don't do this.

I explicitly deny permission to quote my words without attribution. I
ask that you not post followups to my articles without quoting my words.

The obvious solution is to quote with attribution, as everyone else
does. If you're paranoid, you can use an attribution line that doesn't
claim that I *really* wrote the quoted words, like "Someone claiming to
be Keith Thompson writes:".

Another solution would be just not to post followups to anything I
write. And if that's inconvenient, I suggest that it's entirely your
own fault.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Kaz Kylheku 11-03-2011 02:40 AM

Re: undefined reference to `link'
 
On 2011-11-01, Jinsong Zhao <jszhao@yeah.net> wrote:
> f77split.c:(.text+0x4a9): undefined reference to `link'
> collect2: ld returned 1 exit status


The external name "link", or even "please_link", does not guarantee results. :)


All times are GMT. The time now is 10:43 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.