public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Help with gcc partial link (option -ar)
@ 2011-02-22  8:28 horseloverFat
  2011-02-22  9:01 ` Cedric Roux
  0 siblings, 1 reply; 10+ messages in thread
From: horseloverFat @ 2011-02-22  8:28 UTC (permalink / raw)
  To: gcc-help


Hello all,

I am porting a system from irix 6 to red-hat,
I am trying to generate an archive library of gcc generated objects (those
were generated using gcc -c).
This library is then to be used by a different module using it, this module
contains the main entry point for the start of execution. 

I am trying to use the option -ar, as was originally used on the irix
machine. 
From my reading (for example:
http://www.mihaiu.name/2002/library_development_linux/)
I understand that this should generate "partial link".

As I mentioned, I am running on red-hat, using gcc version 3.4.6, and am
trying the following command:
> gcc -ar  -o outcome.a file1.o file2.o

To my surprise, the outcome of this is : "undefined reference to main".
Well, those files really do not contain a "main" function since that
function is on another module and is to be linked later with this library
(outcome.a) - I would have expected the -ar parameter to supress the need
for such main function, since it is a "partial link", and doen't create an
executable. Later on, I tried removing the -ar parameter and the outcome
remains the same.

Does anyone know what i'm doing wrong here?

Thank you.
-- 
View this message in context: http://old.nabble.com/Help-with-gcc-partial-link-%28option--ar%29-tp30983560p30983560.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22  8:28 Help with gcc partial link (option -ar) horseloverFat
@ 2011-02-22  9:01 ` Cedric Roux
  2011-02-22 16:03   ` horseloverFat
  0 siblings, 1 reply; 10+ messages in thread
From: Cedric Roux @ 2011-02-22  9:01 UTC (permalink / raw)
  To: horseloverFat; +Cc: gcc-help

On 02/22/2011 08:56 AM, horseloverFat wrote:
> I am trying to use the option -ar, as was originally used on the irix
> machine.
> trying the following command:
>> gcc -ar  -o outcome.a file1.o file2.o
> Does anyone know what i'm doing wrong here?

use "ar" directly: ar cr outcome.a file1.o file2.o
gnu ar is in the binutils package.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22  9:01 ` Cedric Roux
@ 2011-02-22 16:03   ` horseloverFat
  2011-02-22 16:14     ` Ian Lance Taylor
  2011-02-22 16:32     ` Cedric Roux
  0 siblings, 2 replies; 10+ messages in thread
From: horseloverFat @ 2011-02-22 16:03 UTC (permalink / raw)
  To: gcc-help


Thanks a lot for your help,
yet I already tried that, but simply running "ar" doesn't seem to generate
the appropriate output for the 
final link stage.

Is there a difference between "ar" and "gcc -ar" or are those suppose to
return the same?

Thanks again!


Cedric Roux-4 wrote:
> 
> On 02/22/2011 08:56 AM, horseloverFat wrote:
>> I am trying to use the option -ar, as was originally used on the irix
>> machine.
>> trying the following command:
>>> gcc -ar  -o outcome.a file1.o file2.o
>> Does anyone know what i'm doing wrong here?
> 
> use "ar" directly: ar cr outcome.a file1.o file2.o
> gnu ar is in the binutils package.
> 
> 

-- 
View this message in context: http://old.nabble.com/Help-with-gcc-partial-link-%28option--ar%29-tp30983560p30986943.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:03   ` horseloverFat
@ 2011-02-22 16:14     ` Ian Lance Taylor
  2011-02-22 16:32     ` Cedric Roux
  1 sibling, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2011-02-22 16:14 UTC (permalink / raw)
  To: horseloverFat; +Cc: gcc-help

horseloverFat <gabriel.satanovsky@gmail.com> writes:

> Is there a difference between "ar" and "gcc -ar" or are those suppose to
> return the same?

There is no gcc -ar option.

I do not know what that option is supposed to do on Irix 6.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:03   ` horseloverFat
  2011-02-22 16:14     ` Ian Lance Taylor
@ 2011-02-22 16:32     ` Cedric Roux
  2011-02-22 16:39       ` horseloverFat
  1 sibling, 1 reply; 10+ messages in thread
From: Cedric Roux @ 2011-02-22 16:32 UTC (permalink / raw)
  To: horseloverFat; +Cc: gcc-help

On 02/22/2011 04:47 PM, horseloverFat wrote:
>
> Thanks a lot for your help,
> yet I already tried that, but simply running "ar" doesn't seem to generate
> the appropriate output for the
> final link stage.

How does the link stage fails? what errors do you get?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:32     ` Cedric Roux
@ 2011-02-22 16:39       ` horseloverFat
  2011-02-22 16:59         ` Cedric Roux
                           ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: horseloverFat @ 2011-02-22 16:39 UTC (permalink / raw)
  To: gcc-help


Cedric, it acts as if the types and variables that were defined in the 2
input files (I named them file1.o and file2.o) were not declared anywhere.
Namely, running:

> ld output.o file3.o 

yeilds the same results as simply running:

> ld file3.o

Ian, if that option did not exist I would have recevied an error message on
the command I issued, wouldn't I?



Cedric Roux-4 wrote:
> 
> On 02/22/2011 04:47 PM, horseloverFat wrote:
>>
>> Thanks a lot for your help,
>> yet I already tried that, but simply running "ar" doesn't seem to
>> generate
>> the appropriate output for the
>> final link stage.
> 
> How does the link stage fails? what errors do you get?
> 
> 

-- 
View this message in context: http://old.nabble.com/Help-with-gcc-partial-link-%28option--ar%29-tp30983560p30987337.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:39       ` horseloverFat
@ 2011-02-22 16:59         ` Cedric Roux
  2011-02-24 10:07           ` horseloverFat
  2011-02-22 18:46         ` Andi Hellmund
  2011-02-23  2:03         ` Ian Lance Taylor
  2 siblings, 1 reply; 10+ messages in thread
From: Cedric Roux @ 2011-02-22 16:59 UTC (permalink / raw)
  To: horseloverFat; +Cc: gcc-help

On 02/22/2011 05:32 PM, horseloverFat wrote:
>
> Cedric, it acts as if the types and variables that were defined in the 2
> input files (I named them file1.o and file2.o) were not declared anywhere.
> Namely, running:
>
>> ld output.o file3.o
>
> yeilds the same results as simply running:
>
>> ld file3.o

what results? errors? what messages does ld print?
Maybe a full example would be easier to diagnose
for people on this mailing list.

> Cedric Roux-4 wrote:
>>
>> On 02/22/2011 04:47 PM, horseloverFat wrote:
>>>
>>> Thanks a lot for your help,
>>> yet I already tried that, but simply running "ar" doesn't seem to
>>> generate
>>> the appropriate output for the
>>> final link stage.
>>
>> How does the link stage fails? what errors do you get?
>>
>>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:39       ` horseloverFat
  2011-02-22 16:59         ` Cedric Roux
@ 2011-02-22 18:46         ` Andi Hellmund
  2011-02-23  2:03         ` Ian Lance Taylor
  2 siblings, 0 replies; 10+ messages in thread
From: Andi Hellmund @ 2011-02-22 18:46 UTC (permalink / raw)
  To: horseloverFat; +Cc: gcc-help


> Ian, if that option did not exist I would have recevied an error message on
> the command I issued, wouldn't I?
>    
It does for my 3.4.6 version:

# ./gcc --version
gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# ./gcc -ar test.c -c
cc1: error: unrecognized command line option "-ar"


And I can't find it in the official GCC documentation for 3.4.6, though 
maybe Ian is right that vanilla GCC doesn't know about an -ar option.

Maybe, your version is somehow "patched"?

Andi
>
>
> Cedric Roux-4 wrote:
>    
>> On 02/22/2011 04:47 PM, horseloverFat wrote:
>>      
>>> Thanks a lot for your help,
>>> yet I already tried that, but simply running "ar" doesn't seem to
>>> generate
>>> the appropriate output for the
>>> final link stage.
>>>        
>> How does the link stage fails? what errors do you get?
>>
>>
>>      
>    

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:39       ` horseloverFat
  2011-02-22 16:59         ` Cedric Roux
  2011-02-22 18:46         ` Andi Hellmund
@ 2011-02-23  2:03         ` Ian Lance Taylor
  2 siblings, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2011-02-23  2:03 UTC (permalink / raw)
  To: horseloverFat; +Cc: gcc-help

horseloverFat <gabriel.satanovsky@gmail.com> writes:

> Ian, if that option did not exist I would have recevied an error message on
> the command I issued, wouldn't I?

If you use -c, yes.  If you use it for a link command without -c, then
no.  This bug is fixed in the upcoming gcc 4.6 release.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help with gcc partial link (option -ar)
  2011-02-22 16:59         ` Cedric Roux
@ 2011-02-24 10:07           ` horseloverFat
  0 siblings, 0 replies; 10+ messages in thread
From: horseloverFat @ 2011-02-24 10:07 UTC (permalink / raw)
  To: gcc-help


Hey all,

I looked into it more carefully, and I have been running a "patched" version
of the gcc on the IRIX machine,
in which a call for:

>gcc -ar file1.o file2.o -o output.a

generates an implicit call to 

> ar -rc output.a file1.o file2.o

The fact that the gcc on red-hat did not throw an error on the "-ar"
parameter threw me off-course.
It seems that the problem lies in the tool that links the final outcome.

Thank you all for your help! 


Cedric Roux-4 wrote:
> 
> On 02/22/2011 05:32 PM, horseloverFat wrote:
>>
>> Cedric, it acts as if the types and variables that were defined in the 2
>> input files (I named them file1.o and file2.o) were not declared
>> anywhere.
>> Namely, running:
>>
>>> ld output.o file3.o
>>
>> yeilds the same results as simply running:
>>
>>> ld file3.o
> 
> what results? errors? what messages does ld print?
> Maybe a full example would be easier to diagnose
> for people on this mailing list.
> 
>> Cedric Roux-4 wrote:
>>>
>>> On 02/22/2011 04:47 PM, horseloverFat wrote:
>>>>
>>>> Thanks a lot for your help,
>>>> yet I already tried that, but simply running "ar" doesn't seem to
>>>> generate
>>>> the appropriate output for the
>>>> final link stage.
>>>
>>> How does the link stage fails? what errors do you get?
>>>
>>>
>>
> 
> 
> 
:handshake::handshake:
-- 
View this message in context: http://old.nabble.com/Help-with-gcc-partial-link-%28option--ar%29-tp30983560p31001286.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-02-24  6:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22  8:28 Help with gcc partial link (option -ar) horseloverFat
2011-02-22  9:01 ` Cedric Roux
2011-02-22 16:03   ` horseloverFat
2011-02-22 16:14     ` Ian Lance Taylor
2011-02-22 16:32     ` Cedric Roux
2011-02-22 16:39       ` horseloverFat
2011-02-22 16:59         ` Cedric Roux
2011-02-24 10:07           ` horseloverFat
2011-02-22 18:46         ` Andi Hellmund
2011-02-23  2:03         ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).