i2c tools build failure with gcc 4.6
Seen with latest i2c-tools from svn repository.
gcc 4.6:
gcc-4.6 -Llib -li2c -o tools/i2cdetect tools/i2cdetect.o tools/i2cbusses.o tools/i2cdetect.o: In function `main':
i2cdetect.c:(.text.startup+0x557): undefined reference to i2c_smbus_write_quick' i2cdetect.c:(.text.startup+0x5e9): undefined reference to i2c_smbus_read_byte'
collect2: ld returned 1 exit status
make: *** [tools/i2cdetect] Error 1
gcc-4.4:
gcc-4.4 -Llib -li2c -o tools/i2cdetect tools/i2cdetect.o tools/i2cbusses.o
[ no error ]
Any idea ?
Guenter
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Quoted 9 lines
gcc 4.6:
gcc-4.6 -Llib -li2c -o
tools/i2cdetecttools/i2cdetect.otools/i2cbusses.otools/i2cdetect.o: In function `main':
i2cdetect.c:(.text.startup+0x557): undefined reference toi2c_smbus_write_quick' i2cdetect.c:(.text.startup+0x5e9): undefined reference toi2c_smbus_read_byte'
collect2: ld returned 1 exit status
make: *** [tools/i2cdetect] Error 1
Quoted 6 lines
gcc-4.4:
gcc-4.4 -Llib -li2c -otools/i2cdetecttools/i2cdetect.otools/i2cbusses.o[ no error ]
Any idea ?
I'm using gcc 4.6.2 (from openSUSE 12.1) and "the latest i2c-tools" (that would be from October 25th if I can trust the CHANGES timestamp) builds just fine for me. OTOH this is a linking problem, not building problem, so the version of "ld" may be more relevant. Are you using the same version of "ld" in both cases?
The error messages suggest that gcc (and subsequently ld) doesn't find the symbols exported by libi2c. I can't figure out any reason why it would be so. Can you show us the output of "nm lib/libi2c.so.0.1.0"? This is what I get here:
0000000000201e30 a _DYNAMIC0000000000201fe8 a _GLOBAL_OFFSET_TABLE_
w _Jv_RegisterClasses0000000000201e10 d __CTOR_END__0000000000201e08 d __CTOR_LIST__0000000000201e20 d __DTOR_END__0000000000201e18 d __DTOR_LIST__0000000000000f10 r __FRAME_END__0000000000201e28 d __JCR_END__0000000000201e28 d __JCR_LIST__
0000000000202028 a __bss_start
w __cxa_finalize@@GLIBC_2.2.5
0000000000000c90 t __do_global_ctors_aux
0000000000000850 t __do_global_dtors_aux
0000000000202020 d __dso_handle
U __errno_location@@GLIBC_2.2.5
w __gmon_start__0000000000202028 a _edata
0000000000202038 a _end0000000000000cc8 t _fini00000000000007c8 t _init0000000000000cd8 t _real_fini
0000000000000830 t call_gmon_start
0000000000202028 b completed.5890
0000000000202030 b dtor_idx.589200000000000008d0 t frame_dummy
0000000000000900 T i2c_smbus_access0000000000000c00 T i2c_smbus_block_process_call0000000000000a40 T i2c_smbus_process_call0000000000000a70 T i2c_smbus_read_block_data
0000000000000950 T i2c_smbus_read_byte00000000000009a0 T i2c_smbus_read_byte_data0000000000000b30 T i2c_smbus_read_i2c_block_data00000000000009f0 T i2c_smbus_read_word_data0000000000000ad0 T i2c_smbus_write_block_data
0000000000000980 T i2c_smbus_write_byte00000000000009d0 T i2c_smbus_write_byte_data0000000000000ba0 T i2c_smbus_write_i2c_block_data
0000000000000940 T i2c_smbus_write_quick0000000000000a20 T i2c_smbus_write_word_data
U ioctl@@GLIBC_2.2.5
This could also be a Makefile dependency issue... I can't remember what, if anything, guarantees that the library is built before the tools which use it.
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Jean Delvare
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Oh, right, "the latest one I have", which is svn revision 6075. Is that the latest ?
Quoted 67 lines
Quoted 9 lines
gcc 4.6:
gcc-4.6 -Llib -li2c -o
tools/i2cdetecttools/i2cdetect.otools/i2cbusses.otools/i2cdetect.o: In function `main':
i2cdetect.c:(.text.startup+0x557): undefined reference toi2c_smbus_write_quick' i2cdetect.c:(.text.startup+0x5e9): undefined reference toi2c_smbus_read_byte'
collect2: ld returned 1 exit status
make: *** [tools/i2cdetect] Error 1Quoted 6 lines
gcc-4.4:
gcc-4.4 -Llib -li2c -otools/i2cdetecttools/i2cdetect.otools/i2cbusses.o[ no error ]
Any idea ?
I'm using gcc 4.6.2 (from openSUSE 12.1) and "the latest i2c-tools" (that would be from October 25th if I can trust the CHANGES timestamp) builds just fine for me. OTOH this is a linking problem, not building problem, so the version of "ld" may be more relevant. Are you using the same version of "ld" in both cases?
The error messages suggest that gcc (and subsequently ld) doesn't find the symbols exported by libi2c. I can't figure out any reason why it would be so. Can you show us the output of "nm
lib/libi2c.so.0.1.0"? This is what I get here:
0000000000201e30a_DYNAMIC0000000000201fe8a _GLOBAL_OFFSET_TABLE_
w_Jv_RegisterClasses0000000000201e10d__CTOR_END__0000000000201e08d__CTOR_LIST__0000000000201e20d__DTOR_END__0000000000201e18d__DTOR_LIST__0000000000000f10r__FRAME_END__0000000000201e28d__JCR_END__0000000000201e28d__JCR_LIST__
0000000000202028 a__bss_startw __cxa_finalize@@GLIBC_2.2.5 0000000000000c90 t __do_global_ctors_aux 0000000000000850 t __do_global_dtors_aux 0000000000202020 d __dso_handle U __errno_location@@GLIBC_2.2.5 w __gmon_start__0000000000202028 a
_edata
0000000000202038 a_end0000000000000cc8t_fini00000000000007c8t_init0000000000000cd8t_real_fini
0000000000000830 tcall_gmon_start
0000000000202028 b completed.5890
0000000000202030 b dtor_idx.589200000000000008d0tframe_dummy
0000000000000900 Ti2c_smbus_access0000000000000c00Ti2c_smbus_block_process_call0000000000000a40Ti2c_smbus_process_call0000000000000a70Ti2c_smbus_read_block_data
0000000000000950 Ti2c_smbus_read_byte00000000000009a0Ti2c_smbus_read_byte_data0000000000000b30Ti2c_smbus_read_i2c_block_data00000000000009f0Ti2c_smbus_read_word_data0000000000000ad0Ti2c_smbus_write_block_data
0000000000000980 Ti2c_smbus_write_byte00000000000009d0Ti2c_smbus_write_byte_data0000000000000ba0Ti2c_smbus_write_i2c_block_data
0000000000000940 Ti2c_smbus_write_quick0000000000000a20Ti2c_smbus_write_word_data
Quoted 2 lines
U ioctl@@GLIBC_2.2.5
Hmm - I seem to be having the same.
Quoted 4 lines
This could also be a
Makefiledependency issue... I can't remember what, if anything, guarantees that the library is built before the tools which use it.
Repeating the command doesn't help, though.
Maybe I am missing some commits ?
Guenter
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Guenter Roeck
Quoted 8 lines · Jean Delvare
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Oh, right, "the latest one I have", which is svn revision 6075. Is that the latest ?
"svn status -u" says 6091 but I think this includes the changes to other trees (lm-sensors.) I have i2c-tools/CHANGES at revision 6083.
Quoted 8 lines
Quoted 4 lines
(...)
This could also be aMakefiledependency issue... I can't remember what, if anything, guarantees that the library is built before the tools which use it.Repeating the command doesn't help, though.
Maybe I am missing some commits ?
The error you get doesn't ring any bell and nothing in CHANGES seems relevant.
If it helps, I have made my current SVN snapshot available at:
http://khali.linux-fr.org/devel/misc/i2c-tools-SVN.tar.gz
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 23 lines · Jean Delvare
Quoted 11 lines · Guenter Roeck
Quoted 8 lines · Jean Delvare
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Oh, right, "the latest one I have", which is svn revision 6075. Is that the latest ?
"svn status -u" says 6091 but I think this includes the changes to other trees (lm-sensors.) I have i2c-tools/CHANGES at revision 6083.
Quoted 7 lines
Quoted 4 lines
(...)
This could also be aMakefiledependency issue... I can't remember what, if anything, guarantees that the library is built before the tools which use it.Repeating the command doesn't help, though.
Quoted 8 lines
Quoted 1 line
Maybe I am missing some commits ?
The error you get doesn't ring any bell and nothing in CHANGES seems relevant.
If it helps, I have made my current SVN snapshot available at:
http://khali.linux-fr.org/devel/misc/i2c-tools-SVN.tar.gz
I copied it, but get the same result.
My gcc is from Ubuntu. There is some mention of the problem on the web, on pastebin, so others seem to have the same problem.
Guenter
Quoted 7 lines · Jean Delvare
Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Jean Delvare
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Oh, right, "the latest one I have", which is svn revision 6075. Is that the latest ?
"svn status -u" says 6091 but I think this includes the changes to other trees (lm-sensors.) I have i2c-tools/CHANGES at revision 6083.
The SVN repository should be back now, thanks to Axel Thimm.
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Jean Delvare
Quoted 10 lines · Jean Delvare
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Jean Delvare
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Oh, right, "the latest one I have", which is svn revision 6075. Is that the latest ?
"svn status -u" says 6091 but I think this includes the changes to other trees (lm-sensors.) I have i2c-tools/CHANGES at revision 6083.
The SVN repository should be back now, thanks to Axel Thimm.
It is, thanks. No improvement, though; I still get the same error. Trying to find out what is happening.
Guenter
Quoted 11 lines · Jean Delvare
Quoted 10 lines · Jean Delvare
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Jean Delvare
Hi Guenter,
Quoted 1 line · Guenter Roeck
Seen with latest i2c-tools from svn repository.
With the subversion repository having gone on vacation, "latest" doesn't mean much :(
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Oh, right, "the latest one I have", which is svn revision 6075. Is that the latest ?
"svn status -u" says 6091 but I think this includes the changes to other trees (lm-sensors.) I have i2c-tools/CHANGES at revision 6083.
The SVN repository should be back now, thanks to Axel Thimm.
I found the problem. -li2c must be specified after the .o files.
Patch:
tools/Module.mk +4 -4
@@ -21,16 +21,16 @@ TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget # $(TOOLS_DIR)/i2cdetect: $(TOOLS_DIR)/i2cdetect.o $(TOOLS_DIR)/i2cbusses.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cdump: $(TOOLS_DIR)/i2cdump.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cset: $(TOOLS_DIR)/i2cset.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) # # Objects
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Guenter,
Quoted 19 lines · Guenter Roeck
I found the problem. -li2c must be specified after the .o files.
Patch:
tools/Module.mk +2
-2@@ -21,16 +21,16 @@ TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget # $(TOOLS_DIR)/i2cdetect: $(TOOLS_DIR)/i2cdetect.o $(TOOLS_DIR)/i2cbusses.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cdump: $(TOOLS_DIR)/i2cdump.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS)
tools/Module.mk TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget · line 36
Quoted 10 lines
tools/Module.mk +2
-2$(TOOLS_DIR)/i2cset: $(TOOLS_DIR)/i2cset.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) # # Objects
Hmm, OK. The gcc manual page is somewhat confusing on this topic but as I understand it, when processing a library, it only considers symbols which were already referenced but not defined, and discards the rest. So object files must indeed come first on the command line.
Why it has always worked for me the other way around is a mystery.
You have write permissions to the repository, so please just commit this fix, thanks.
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 38 lines · Jean Delvare
Hi Guenter,
Quoted 19 lines · Guenter Roeck
I found the problem. -li2c must be specified after the .o files.
Patch:
tools/Module.mk +2
-2@@ -21,16 +21,16 @@ TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget # $(TOOLS_DIR)/i2cdetect: $(TOOLS_DIR)/i2cdetect.o $(TOOLS_DIR)/i2cbusses.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cdump: $(TOOLS_DIR)/i2cdump.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS)tools/Module.mk TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget · line 36
Quoted 10 lines
tools/Module.mk +2
-2$(TOOLS_DIR)/i2cset: $(TOOLS_DIR)/i2cset.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o - $(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) # # ObjectsHmm, OK. The gcc manual page is somewhat confusing on this topic but as I understand it, when processing a library, it only considers symbols which were already referenced but not defined, and discards the rest. So object files must indeed come first on the command line.
Quoted 2 lines
Why it has always worked for me the other way around is a mystery.
Something must have changed, since it works for me with an older version of gcc (4.4).
Quoted 3 lines
You have write permissions to the repository, so please just commit this fix, thanks.
Done.
Guenter