Web lists-archives.com

Re: [Mingw-users] Can't do partial linking with libmoldname.a?




emm... I'm not linking an executable and an object file. In fact, I 
tried to partial linking an object file and a library (or archive file), 
that succeeds. But when I tried to generate EXE from the partial linking 
output object file, it failed.

my first step:
	test.c  ===== gcc C compiler =====> test.o
	(compile only, no linking, succeed)
second step:
	test.o + libmoldname.a === ld linker ===> big.o
	(partial linking an object file 'test.o' and an archive file 
'libmoldname.a', should generate an object file 'big.o', succeed)
third step:
	big.o ==== use gcc as linker ====> test.exe
	(generate executable from one object file, failed)

	
> an executable  is as a result of linking two object files , you can't
> link an executable and an object file , again gcc is a c compiler not
> a linker although it can invoke it  ,  in your  command you seem to
> want gcc to combine an object file to an executable , if you have
> issues with linking I suggest you learn to use makefiles,makefile
> generators(cmake) etc and analyze the generated makefiles , ld.exe is
> the linker ,thank you.
>
> On 25/11/2016, 张博洋 <zhangboyang.id@xxxxxxxxx> wrote:
>>
>> Hello,
>>      I'm trying to do partial linking a .o file with libmoldname.a, the
>> partial linking is OK, but when I linking the generated .o to .exe, the
>> linking failed. Here are my steps:
>>      I have a C source file, test.c, with the following code:
>>          #include <stdio.h>
>>          #include <string.h>
>>          int main()
>>          {
>>              puts(strdup("hello"));
>>                  // strdup() is in libmoldname.a
>>              return 0;
>>          }
>>      Compile the C code (success):
>>          gcc -c -o test.o test.c
>>          Partial linking (success):
>>          ld -o big.o -r test.o /mingw/lib/libmoldname.a
>>      Finally, link to generate EXE file (failed):
>>          gcc -o test.exe big.o
>>      The error message is:
>>
>> c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe:
>> final link failed: File truncated
>>
>>      Is this a bug? Or the libmoldname.a can't be partial linked?
>>
>> --
>> Regards,
>> Zhang Boyang
>> School of Computer Science, Fudan University, P.R.China
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> MinGW-users mailing list
>> MinGW-users@xxxxxxxxxxxxxxxxxxxxx
>>
>> This list observes the Etiquette found at
>> http://www.mingw.org/Mailing_Lists.
>> We ask that you be polite and do the same.  Disregard for the list etiquette
>> may cause your account to be moderated.
>>
>> _______________________________________________
>> You may change your MinGW Account Options or unsubscribe at:
>> https://lists.sourceforge.net/lists/listinfo/mingw-users
>> Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe
>>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> MinGW-users mailing list
> MinGW-users@xxxxxxxxxxxxxxxxxxxxx
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe
>


------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe