[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Linking problems with gcc 4.6.1 and GNUstep trunk
From: |
Wolfgang Lux |
Subject: |
Re: Linking problems with gcc 4.6.1 and GNUstep trunk |
Date: |
Tue, 21 Feb 2012 09:29:43 +0100 |
Philippe Roussel wrote:
> Using gcc 4.6.1, the GNU runtime and GNUstep trunk I get this when building
> for example gap/system-apps/Addresses/Goodies/adserver :
>
>> This is gnustep-make 2.6.2. Type 'make print-gnustep-make-help' for help.
>> Making all for tool adserver...
>> Linking tool adserver ...
>> ./obj/adserver.obj/adserver.m.o:(.data.rel+0x10): undefined reference to
>> `__objc_class_name_ADPublicAddressBook'
>> ./obj/adserver.obj/adserver.m.o:(.data.rel+0x30): undefined reference to
>> `__objc_class_name_ADLocalAddressBook'
>> collect2: ld a retourné 1 code d'état d'exécution
>> make[3]: *** [obj/adserver] Erreur 1
>> make[2]: *** [internal-tool-all_] Erreur 2
>> make[1]: *** [adserver.all.tool.variables] Erreur 2
>> make: *** [internal-all] Erreur 2
>
> GNUmakefile
>
>> include $(GNUSTEP_MAKEFILES)/common.make
>>
>> TOOL_NAME=adserver
>>
>> adserver_OBJC_FILES=adserver.m
>> adserver_OBJCFLAGS=-I../Frameworks -Wall
>> adserver_LDFLAGS=\
>> -L../Frameworks/Addresses/Addresses.framework/Versions/A \
>> -lAddresses
>> -include GNUmakefile.preamble
>> -include GNUmakefile.local
>> include $(GNUSTEP_MAKEFILES)/tool.make
>> -include GNUmakefile.postamble
>
> Linking command
>
>> gcc -rdynamic -L../Frameworks/Addresses/Addresses.framework/Versions/A
>> -lAddresses -pthread -shared-libgcc -fexceptions -fgnu-runtime -o
>> obj/adserver \
>> ./obj/adserver.obj/adserver.m.o \
>> -L/home/philou/GNUstep/Library/Libraries
>> -L/opt/GNUstep-trunk/Local/Library/Libraries
>> -L/opt/GNUstep-trunk/System/Library/Libraries -lgnustep-base -lpthread
>> -lobjc -lm
>
> If I modify the makefile like this
>
>> --- GNUmakefile 1 May 2007 23:08:38 -0000 1.1
>> +++ GNUmakefile 20 Feb 2012 21:57:05 -0000
>> @@ -5,8 +5,8 @@
>> adserver_OBJC_FILES=adserver.m
>> adserver_OBJCFLAGS=-I../Frameworks -Wall
>> adserver_LDFLAGS=\
>> - -L../Frameworks/Addresses/Addresses.framework/Versions/A \
>> - -lAddresses
>> + -L../Frameworks/Addresses/Addresses.framework/Versions/A
>> +ADDITIONAL_TOOL_LIBS+=-lAddresses
>> -include GNUmakefile.preamble
>> -include GNUmakefile.local
>> include $(GNUSTEP_MAKEFILES)/tool.make
>
> it all works and the linking command is
>
>> gcc -rdynamic -L../Frameworks/Addresses/Addresses.framework/Versions/A
>> -pthread -shared-libgcc -fexceptions -fgnu-runtime -o obj/adserver \
>> ./obj/adserver.obj/adserver.m.o \
>> -L/home/philou/GNUstep/Library/Libraries
>> -L/opt/GNUstep-trunk/Local/Library/Libraries
>> -L/opt/GNUstep-trunk/System/Library/Libraries -lAddresses -lgnustep-base
>> -lpthread -lobjc -lm
>
> Is this a problem in gnustep-make, gcc, the makefile ?
I would say this is the expected behavior. The XXX_LDFLAGS variables are
supposed to provide library paths, i.e., -L options, but not libraries
themselves, i.e., -l options. These should be provided via a XXX_LIBS flags
(and if I'm not mistaken adserver_LIBS should do the job). The reason for this
separation is that for many linkers the order of arguments on the command line
matters. The problem with the initial version of your Makefile is that
-lAddresses appeared before ./obj/adserver.obj/adserver.m.o on the command line
and hence the library wasn't used to resolve undefined references in the object
file. The second version of the makefile gets the order of arguments right,
i.e., -LAddresses appears after ./obj/adserver.obj/adserver.m.o in the link
command line.
Wolfgang