You are not logged in.
When trying to compile test.c
int main (int c, char** a) {
printf ("hello\n");
}
I get
/usr/lib/gcc/i586-pc-mingw32/3.4.5/libgcc.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
I'm still using slitaz 4.0 - but I got the mingw32 packages from the cooking repository. Is that a problem?
------------------------
Verbose output
Reading specs from /usr/lib/gcc/i586-pc-mingw32/3.4.5/specs
Configured with: /home/slitaz/wok/mingw32-gcc/source/mingw32-gcc-3.4.5-20060117-2/configure --prefix=/usr --libexecdir=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-sysroot=/usr/i586-pc-mingw32 --disable-shared --disable-debug --target=i586-pc-mingw32 --enable-languages=c,c++,ada --enable-threads=win32 --disable-win32-registry --enable-sjlj-exceptions --build=i486-slitaz-linux --host=i486-slitaz-linux
Thread model: win32
gcc version 3.4.5 (mingw-vista special r2)
/usr/lib/gcc/i586-pc-mingw32/3.4.5/cc1 -quiet -v test.c -quiet -dumpbase test.c -mtune=pentium -auxbase test -version -o /tmp/ccnCjGjr.s
ignoring nonexistent directory "/usr/i586-pc-mingw32/usr/local/include"
ignoring nonexistent directory "/usr/i586-pc-mingw32/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i586-pc-mingw32/3.4.5/include
/usr/lib/gcc/i586-pc-mingw32/3.4.5/../../../../i586-pc-mingw32/include
End of search list.
GNU C version 3.4.5 (mingw-vista special r2) (i586-pc-mingw32)
compiled by GNU C version 4.6.3.
GGC heuristics: --param ggc-min-expand=34 --param ggc-min-heapsize=8192
test.c:5:2: warning: no newline at end of file
/usr/lib/gcc/i586-pc-mingw32/3.4.5/../../../../i586-pc-mingw32/bin/as -o /tmp/ccMm7lBK.o /tmp/ccnCjGjr.s
/usr/lib/gcc/i586-pc-mingw32/3.4.5/collect2 -Bdynamic /usr/lib/gcc/i586-pc-mingw32/3.4.5/../../../../i586-pc-mingw32/lib/crt2.o /usr/lib/gcc/i586-pc-mingw32/3.4.5/crtbegin.o -L/usr/lib/gcc/i586-pc-mingw32/3.4.5 -L/usr/lib/gcc/i586-pc-mingw32/3.4.5 -L/usr/lib/gcc/i586-pc-mingw32/3.4.5/../../../../i586-pc-mingw32/lib -L/usr/i586-pc-mingw32/lib -L/usr/i586-pc-mingw32/usr/lib /tmp/ccMm7lBK.o -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i586-pc-mingw32/3.4.5/crtend.o
/usr/lib/gcc/i586-pc-mingw32/3.4.5/libgcc.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
tux@slitaz:~/projects/mingw$
Offline
Hi,
What command do you type to compile? You gave only its output. I'm no expert but the "-Bdynamic" flag looks odd (all the more as your mingw was configured with --disable-shared).
Also, maybe launching the collect2 command yourself with the --verbose flag will give useful info?
Offline
Hi llev, thanks for your reply! The command is just
>i586-pc-mingw32-gcc test.c
and the non-verbose output
/usr/lib/gcc/i586-pc-mingw32/3.4.5/libgcc.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
I tried
file libgcc.a
libgcc.a: current ar archive
nm libgcc.a
nm: _chkstk.o: File format not recognized
nm: _muldi3.o: File format not recognized
nm: _negdi2.o: File format not recognized
and more similar output.
I should assume the object files are in windows binary format or something like that?
As to the compiler/linker flags, I think they are defaults? I just installed the packages and didn't modify anything.
I'd like to know if the package works fine in SliTaz 5.0 or other systems, or else I happen to be the first person to try it and found out it's broken. Thanks!
Offline
1) Maybe try [c]i586-pc-mingw32-gcc -static test.c[/c]
2) To get more verbose output by "collect2", try:
[c]i586-pc-mingw32-gcc -c test.c
/usr/lib/gcc/i586-pc-mingw32/3.4.5/collect2 --verbose -Bdynamic /usr/lib/gcc/i586-pc-mingw32/3.4.5/../../../../i586-pc-mingw32/lib/crt2.o /usr/lib/gcc/i586-pc-mingw32/3.4.5/crtbegin.o -L/usr/lib/gcc/i586-pc-mingw32/3.4.5 -L/usr/lib/gcc/i586-pc-mingw32/3.4.5 -L/usr/lib/gcc/i586-pc-mingw32/3.4.5/../../../../i586-pc-mingw32/lib -L/usr/i586-pc-mingw32/lib -L/usr/i586-pc-mingw32/usr/lib test.o -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i586-pc-mingw32/3.4.5/crtend.o[/c]
edit: it may be simpler to call:
[c]i586-pc-mingw32-gcc -Wl,--verbose test.c[/c]
;-)
3) Try again 2) after replacing -Bdynamic by -Bstatic.
4) I think you should not call [c]nm[/c], rather [c]i586-pc-mingw32-nm[/c] or something similar.
5) As for me, I do cross-compiling but not with this package. I installed "mxe" ("MinGW cross-environment") from their site; because mxe allows me to statically link to GTK.
6) And yes, using a package from the repo of version "X" on version "Y" of a distribution is generally source of problems, so it may be the source of this problem you're facing.
Offline
Thanks for your reply llev! Much appreciated.
1) gives same error
2) -Bdynamic gives http://pastebin.com/dLWjcKtX
3) -Bstatic gives http://pastebin.com/aGGZ06Q2
4) You're right. i586-pc-mingw32-nm works and lists lots of symbols. I was hopping it would give some hint about some problem with libgcc.a but as far I read the output, it doesn't. Then again, I'm not really sure what I should be looking for.
5) I installed mingw on windows and it moslty works. I can compile a working gtk test program (though I also ran into some weird behaviour).
6) Well, I'll try again when I get SliTaz 5.0 then. Thanks for your help! 
Offline
4) From ranlib man page:
[c]ranlib generates an index to the contents of an archive and stores it
in the archive. The index lists each symbol defined by a member of
an archive that is a relocatable object file.
You may use nm -s or nm --print-armap to list this index.[/c]
So I'd first check there's no index (as the error message says), then try to run ranlib as advised by the error (after doing a backup of libgcc.a!).
5) I can also compile gtk programs with MinGW under Windows, *but* /not/ statically. Then if you want to distribute your software you need to distribute all GTK dll's as well!
6) Try mxe 
Offline
Thank you very much for your help llev. I feel so stupid.
Yes, first thing I did was run ranlib as the message suggested, but I used the 'normal' version of ranlib ( i486-slitaz-linux-ranlib )
I now tried
>i586-pc-mingw32-ranlib libgcc.a
and compilation works! Thanks again!!
Offline
[ Generated in 0.022 seconds, 8 queries executed - Memory usage: 1.55 MiB (Peak: 1.77 MiB) ]