Note that there are some explanatory texts on larger screens.

plurals
  1. POld complains: in function "_start", undefined reference to "__libc_csu_fini" & "__libc_csu_init"
    primarykey
    data
    text
    <p>I'm compiled a GTK+ program using clang, rather than gcc. So far so good, except I can't have <em>ld</em> link correctly.</p> <p>Original makefile called gcc to do the linking, like this:</p> <blockquote> <p>gcc -g -O2 -export-dynamic -o my_application somefile.o another.o -pthread -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgconf-2 -lglade-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lxml2 -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0 </p> </blockquote> <p>If I simply substitute <em>gcc</em> with <em>clang</em> in the above command, I get this warning from the latter:</p> <blockquote> <p>clang: warning: argument unused during compilation: '-e xport-dynamic'</p> </blockquote> <p>Problem is: clang doesn't recognize "-export-dynamic" as a linker option, so it doesn't pass it off to <em>ld</em>. This causes the references to external functions to be scrapped: when final binary is executed, neither the menu options nor the buttons react.</p> <p>If I do final linking step with gcc the binary works perfectly (even though it was really compiled with clang and gcc only does the linking). Since I'm trying to completely replace gcc with clang in my machine, this is not acceptable.</p> <p>So I tried this:</p> <blockquote> <p>ld /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o -g -O2 -export-dynamic my_application somefile.o another.o -o -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgconf-2 -lglade-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lxml2 -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0 </p> </blockquote> <p>By adding first 3 objects I avoid the "can't find _start" message. But then I get the aforementioned two complaints:</p> <blockquote> <p>/usr/lib/crt1.o: In function <code>_start</code>: (.text+0x12): undefined reference to <code>__libc_csu_fini</code> /usr/lib/crt1.o: In function <code>_start</code>: (.text+0x19): undefined reference to <code>__libc_csu_init</code></p> </blockquote> <p>I tried adding crtbegin.o and crtend.o at the list, even before <em>crt1.o</em> , to no avail. What is the linker's correct invocation?</p> <p>(Post Edit): If nothing else works, is there a way to catch what exact parameters <em>gcc</em> is passing to <em>ld</em> when <em>gcc</em> is used for the linking?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload