LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   libv4l-0.1 compiule problem (https://www.linuxquestions.org/questions/linux-software-2/libv4l-0-1-compiule-problem-776651/)

business_kid 12-18-2009 05:58 AM

libv4l-0.1 compiule problem
 
Hi. I grabbed the latest source, compiled it for 64 bit, made clean and then wanted a 32 bit version. The site
http://hansdegoede.livejournal.com/7622.html gives this line

make PREFIX=/usr CFLAGS=-m32 LDFLAGS=-m32

That failed for the lack of libv4lconvert.h (in ../include). A symlink fixed that. Now I get this

Code:

gcc -fpic -m32 -o libv4lconvert/spca501.o -c libv4lconvert/spca501.c
gcc -fpic -m32 -o libv4lconvert/bayer.o -c libv4lconvert/bayer.c
gcc -m32 -Wl,-soname,libv4lconvert.so.0 -o lib/libv4lconvert.so.0 libv4lconvert/libv4lconvert.o libv4lconvert/tinyjpeg.o libv4lconvert/jidctflt.o libv4lconvert/spca561-decompress.o libv4lconvert/rgbyuv.o libv4lconvert/spca501.o libv4lconvert/bayer.o
/usr/lib64/gcc/x86_64-slamd64-linux/4.2.4/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [lib/libv4lconvert.so.0] Error 1

which, at a guess, is glibc related My installed glibc stuff is
Code:

bash-3.1$ ls /var/log/packages/glibc*
/var/log/packages/glibc-2.7-x86_64_slamd64-9              /var/log/packages/glibc-solibs-2.7-x86_64_slamd64-9
/var/log/packages/glibc-i18n-2.7-noarch_slamd64-9    /var/log/packages/glibc-zoneinfo-2.7-noarch_slamd64-9
/var/log/packages/glibc-profile-2.7-x86_64_slamd64-9  /var/log/packages/glibc32-2.7-x86_64_slamd64-9

Any ideas please? I do seem to have a 32bit compat library there.

Edit: /usr/lib64/gcc/x86_64-slamd64-linux/4.2.4/../../../../lib/crt1.o actually exists, is 32 bit and has a function called 'main' according to readelf :-o.

JohnGraham 12-18-2009 10:07 AM

Quote:

Originally Posted by business_kid (Post 3796568)
Code:

gcc -fpic -m32 -o libv4lconvert/spca501.o -c libv4lconvert/spca501.c
gcc -fpic -m32 -o libv4lconvert/bayer.o -c libv4lconvert/bayer.c
gcc -m32 -Wl,-soname,libv4lconvert.so.0 -o lib/libv4lconvert.so.0 libv4lconvert/libv4lconvert.o libv4lconvert/tinyjpeg.o libv4lconvert/jidctflt.o libv4lconvert/spca561-decompress.o libv4lconvert/rgbyuv.o libv4lconvert/spca501.o libv4lconvert/bayer.o
/usr/lib64/gcc/x86_64-slamd64-linux/4.2.4/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [lib/libv4lconvert.so.0] Error 1

Edit: /usr/lib64/gcc/x86_64-slamd64-linux/4.2.4/../../../../lib/crt1.o actually exists, is 32 bit and has a function called 'main' according to readelf :-o.

First, if crt1.o really does have a *defined* symbol called 'main' then something is very, very wrong! If you look closely you should see that it uses a symbol called main - readelf will give you a list of symbols the object file uses as well as ones it defines.

Second, your problem is that the -shared flag isn't specified in the gcc command to create the .so library.

business_kid 12-19-2009 03:24 AM

Thanks for the reply John. Adding the shared flag to CFLAGS and LDFLAGS allowed it to compile. Thank heavens for search options in a man page!

Just FYI Here's what ctrl.o shows from readelf
Code:

There are no program headers in this file.

Relocation section '.rel.text' at offset 0x49c contains 4 entries:
 Offset    Info    Type            Sym.Value  Sym. Name
0000000c  00000a01 R_386_32          00000000  __libc_csu_fini
00000011  00000c01 R_386_32          00000000  __libc_csu_init
00000018  00000d01 R_386_32          00000000  main
0000001d  00001002 R_386_PC32        00000000  __libc_start_main


JohnGraham 12-19-2009 09:57 AM

Ah - don't know what option you're passing to readelf, but if you use --symbols you'll get output like:

Code:

Symbol table '.symtab' contains 25 entries:
  Num:    Value  Size Type    Bind  Vis      Ndx Name
...
    20: 00000000    0 NOTYPE  GLOBAL DEFAULT  UND main

Which shows the symbol main to be UND (undefined). A simpler program with simpler output is nm if you just want to look at which symbols there are:

Code:

$ nm /usr/lib/crt1.o
00000000 R _IO_stdin_used
00000000 D __data_start
        U __libc_csu_fini
        U __libc_csu_init
        U __libc_start_main
00000000 R _fp_hw
00000000 T _start
00000000 W data_start
        U main

Where 'U' means undefined - you can also just pass it --defined to look at what that .o/.a/.so file defines.

business_kid 12-20-2009 02:52 AM

Thx. I passed readelf the '-a'. I'm not a programmer, but an LFS builder, so one gets fairly competent at failed compiles without fully knowing what is going on.


All times are GMT -5. The time now is 02:13 AM.