Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Build qt5 on centos7, linker can not link libiconv even if it exists
QtWS25 Last Chance

Build qt5 on centos7, linker can not link libiconv even if it exists

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
4 Posts 2 Posters 722 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yanni
    wrote on last edited by
    #1

    From here, I know that there are two versions of the library iconv. Obviously (see build error log below), the version that used in QT is from GNU libiconv, instead of that glibc. Since my centos does not have a libiconv, I downloaded and builded it, then add its lib/ to the top of my $LIBRARY_PATH. But the linker still can not find it.

    g++ -Wl,-e,qt_core_boilerplate -Wl,--no-undefined -Wl,--version-script,QtCore.version -Wl,-O1 -Wl,--enable-new-dtags -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list,/home/me/my_soft/qt-everywhere-src-5.15.5/qtbase/src/corelib/QtCore.dynlist -Wl,-soname,libQt5Core.so.5 -o libQt5Core.so.5.15.5 .obj/minimum-linux.o .obj/qstring_compat.o .obj/qabstractanimation.o .obj/qvariantanimation.o .obj/qpropertyanimation.o .obj/qanimationgroup.o .obj/qsequentialanimationgroup.o .obj/qparallelanimationgroup.o .obj/qpauseanimation.o .obj/qendian.o .obj/qglobal.o .obj/qlibraryinfo.o .obj/qmalloc.o .obj/qnumeric.o .obj/qfloat16.o .obj/qoperatingsystemversion.o .obj/qlogging.o .obj/qrandom.o .obj/qhooks.o .obj/qversiontagging.o .obj/qrunnable.o .obj/qthread.o .obj/qthread_unix.o .obj/qatomic.o .obj/qmutex.o .obj/qreadwritelock.o .obj/qsemaphore.o .obj/qthreadpool.o .obj/qthreadstorage.o .obj/qwaitcondition_unix.o .obj/qexception.o .obj/qfutureinterface.o .obj/qfuturewatcher.o .obj/qresultstore.o .obj/qarraydata.o .obj/qbitarray.o .obj/qcryptographichash.o .obj/qfreelist.o .obj/qhash.o .obj/qline.o .obj/qlinkedlist.o .obj/qlist.o .obj/qpoint.o .obj/qmap.o .obj/qmargins.o .obj/qmessageauthenticationcode.o .obj/qcontiguouscache.o .obj/qrect.o .obj/qrefcount.o .obj/qringbuffer.o .obj/qshareddata.o .obj/qsharedpointer.o .obj/qsimd.o .obj/qsize.o .obj/qversionnumber.o .obj/qcommandlineoption.o .obj/qcommandlineparser.o .obj/bignum.o .obj/bignum-dtoa.o .obj/cached-powers.o .obj/diy-fp.o .obj/double-conversion.o .obj/fast-dtoa.o .obj/fixed-dtoa.o .obj/strtod.o .obj/qeasingcurve.o .obj/qtimeline.o .obj/qbytearray.o .obj/qbytearraylist.o .obj/qbytearraymatcher.o .obj/qcollator.o .obj/qlocale.o .obj/qlocale_tools.o .obj/qregexp.o .obj/qstring.o .obj/qstringbuilder.o .obj/qstringlist.o .obj/qstringview.o .obj/qtextboundaryfinder.o .obj/qunicodetools.o .obj/qvsnprintf.o .obj/qlocale_unix.o .obj/qcollator_posix.o .obj/qregularexpression.o .obj/harfbuzz-buffer.o .obj/harfbuzz-gdef.o .obj/harfbuzz-gsub.o .obj/harfbuzz-gpos.o .obj/harfbuzz-impl.o .obj/harfbuzz-open.o .obj/harfbuzz-stream.o .obj/harfbuzz-shaper-all.o .obj/qharfbuzz.o .obj/qdatetime.o .obj/qcalendar.o .obj/qgregoriancalendar.o .obj/qjuliancalendar.o .obj/qmilankoviccalendar.o .obj/qromancalendar.o .obj/qhijricalendar.o .obj/qislamiccivilcalendar.o .obj/qjalalicalendar.o .obj/qtimezone.o .obj/qtimezoneprivate.o .obj/qtimezoneprivate_tz.o .obj/qdatetimeparser.o .obj/qabstractfileengine.o .obj/qbuffer.o .obj/qdataurl.o .obj/qtldurl.o .obj/qdebug.o .obj/qdir.o .obj/qdiriterator.o .obj/qfile.o .obj/qfiledevice.o .obj/qfileinfo.o .obj/qipaddress.o .obj/qiodevice.o .obj/qlockfile.o .obj/qnoncontiguousbytedevice.o .obj/qstorageinfo.o .obj/qtemporarydir.o .obj/qtemporaryfile.o .obj/qresource.o .obj/qresource_iterator.o .obj/qsavefile.o .obj/qstandardpaths.o .obj/qurl.o .obj/qurlidna.o .obj/qurlquery.o .obj/qurlrecode.o .obj/qfsfileengine.o .obj/qfsfileengine_iterator.o .obj/qfilesystementry.o .obj/qfilesystemengine.o .obj/qfileselector.o .obj/qloggingcategory.o .obj/qloggingregistry.o .obj/qfilesystemwatcher.o .obj/qfilesystemwatcher_polling.o .obj/qfilesystemwatcher_inotify.o .obj/qprocess.o .obj/qprocess_unix.o .obj/qsettings.o .obj/qfsfileengine_unix.o .obj/qfilesystemengine_unix.o .obj/qlockfile_unix.o .obj/qfilesystemiterator_unix.o .obj/forkfd_qt.o .obj/qstandardpaths_unix.o .obj/qstorageinfo_unix.o .obj/qabstractitemmodel.o .obj/qitemselectionmodel.o .obj/qabstractproxymodel.o .obj/qconcatenatetablesproxymodel.o .obj/qidentityproxymodel.o .obj/qsortfilterproxymodel.o .obj/qtransposeproxymodel.o .obj/qstringlistmodel.o .obj/qfactoryinterface.o .obj/qpluginloader.o .obj/qfactoryloader.o .obj/quuid.o .obj/qlibrary.o .obj/qelfparser_p.o .obj/qmachparser.o .obj/qlibrary_unix.o .obj/qabstracteventdispatcher.o .obj/qabstractnativeeventfilter.o .obj/qbasictimer.o .obj/qdeadlinetimer.o .obj/qelapsedtimer.o .obj/qeventloop.o .obj/qcoreapplication.o .obj/qcoreevent.o .obj/qmetaobject.o .obj/qmetatype.o .obj/qmetaobjectbuilder.o .obj/qmimedata.o .obj/qobject.o .obj/qobjectcleanuphandler.o .obj/qsignalmapper.o .obj/qsocketnotifier.o .obj/qtimer.o .obj/qtranslator.o .obj/qvariant.o .obj/qcoreglobaldata.o .obj/qsharedmemory.o .obj/qsystemsemaphore.o .obj/qpointer.o .obj/qmath.o .obj/qsystemerror.o .obj/qtestsupport_core.o .obj/qcore_unix.o .obj/qeventdispatcher_unix.o .obj/qtimerinfo_unix.o .obj/qelapsedtimer_unix.o .obj/qsharedmemory_posix.o .obj/qsharedmemory_systemv.o .obj/qsharedmemory_unix.o .obj/qsystemsemaphore_posix.o .obj/qsystemsemaphore_systemv.o .obj/qsystemsemaphore_unix.o .obj/qutfcodec.o .obj/qlatincodec.o .obj/qsimplecodec.o .obj/qtextcodec.o .obj/qisciicodec.o .obj/qtsciicodec.o .obj/qgb18030codec.o .obj/qjpunicode.o .obj/qeucjpcodec.o .obj/qjiscodec.o .obj/qsjiscodec.o .obj/qeuckrcodec.o .obj/qbig5codec.o .obj/qiconvcodec.o .obj/qcborcommon.o .obj/qcbordiagnostic.o .obj/qcborvalue.o .obj/qdatastream.o .obj/qjsoncbor.o .obj/qjsondocument.o .obj/qjsonobject.o .obj/qjsonarray.o .obj/qjsonvalue.o .obj/qjsonwriter.o .obj/qjsonparser.o .obj/qtextstream.o .obj/qxmlstream.o .obj/qxmlutils.o .obj/qcborstreamreader.o .obj/qcborstreamwriter.o .obj/qbinaryjson.o .obj/qbinaryjsonarray.o .obj/qbinaryjsonobject.o .obj/qbinaryjsonvalue.o .obj/qstatemachine.o .obj/qabstractstate.o .obj/qstate.o .obj/qfinalstate.o .obj/qhistorystate.o .obj/qabstracttransition.o .obj/qsignaltransition.o .obj/qeventtransition.o .obj/qmimedatabase.o .obj/qmimetype.o .obj/qmimemagicrulematcher.o .obj/qmimetypeparser.o .obj/qmimemagicrule.o .obj/qmimeglobpattern.o .obj/qmimeprovider.o .obj/moc_qcalendar.o .obj/moc_qobjectdefs.o .obj/moc_qmimetype.o  -lpthread -lm -lz /home/me/my_soft/qt-everywhere-src-5.15.5/qtbase/lib/libqtpcre2.a -ldl
    
    .obj/qiconvcodec.o: In function `qIconvCodecStateFree(QTextCodec::ConverterState*)':
    qiconvcodec.cpp:(.text+0x105): undefined reference to `libiconv_close'
    .obj/qiconvcodec.o: In function `QIconvCodec::IconvState::~IconvState()':
    qiconvcodec.cpp:(.text+0x20f): undefined reference to `libiconv_close'
    .obj/qiconvcodec.o: In function `QIconvCodec::createIconv_t(char const*, char const*) const':
    

    After adding -liconv mannually to the end of the following g++ command, it can succuessfully link.

    My question is, why linker can not find libiconv even if it is on top of my $LIBRARY_PATH ? May be glibc has been linked previously, it found symbols there and directly use it here, without looking into $LIBRARY_PATH ?

    Below is a test used to demonstrate that I have to explicilty specify link to libiconv (copied from previous stackoverflow answer)

    #include <iconv.h>
    
    int main( int argc, char **argv ) {
            iconv_t cd = iconv_open( "UTF-8", "ISO-8859-1" );
            iconv_close( cd );
            return 0;
    }
    

    gcc -H iconv.c -o hh

    . /home/me/my_soft/libiconv/1.17/include/iconv.h
    .. /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
    .. /usr/include/errno.h
    ... /usr/include/features.h
    .... /usr/include/sys/cdefs.h
    ..... /usr/include/bits/wordsize.h
    .... /usr/include/gnu/stubs.h
    ..... /usr/include/gnu/stubs-64.h
    ... /usr/include/bits/errno.h
    .... /usr/include/linux/errno.h
    ..... /usr/include/asm/errno.h
    ...... /usr/include/asm-generic/errno.h
    ....... /usr/include/asm-generic/errno-base.h
    .. /usr/include/wchar.h
    ... /usr/include/stdio.h
    ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdarg.h
    ... /usr/include/bits/wchar.h
    .... /usr/include/bits/wordsize.h
    ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
    ... /usr/include/xlocale.h
    Multiple include guards may be useful for:
    /usr/include/asm/errno.h
    /usr/include/bits/errno.h
    /usr/include/errno.h
    /usr/include/gnu/stubs-64.h
    /usr/include/gnu/stubs.h
    /usr/include/linux/errno.h
    /usr/include/wchar.h
    /tmp/ccJ122v1.o: In function `main':
    iconv.c:(.text+0x1a): undefined reference to `libiconv_open'
    iconv.c:(.text+0x2a): undefined reference to `libiconv_close'
    collect2: error: ld returned 1 exit status
    

    However, if gcc -H iconv.c -o hh -liconv, it succeeds.

    . /home/me/my_soft/libiconv/1.17/include/iconv.h
    .. /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
    .. /usr/include/errno.h
    ... /usr/include/features.h
    .... /usr/include/sys/cdefs.h
    ..... /usr/include/bits/wordsize.h
    .... /usr/include/gnu/stubs.h
    ..... /usr/include/gnu/stubs-64.h
    ... /usr/include/bits/errno.h
    .... /usr/include/linux/errno.h
    ..... /usr/include/asm/errno.h
    ...... /usr/include/asm-generic/errno.h
    ....... /usr/include/asm-generic/errno-base.h
    .. /usr/include/wchar.h
    ... /usr/include/stdio.h
    ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdarg.h
    ... /usr/include/bits/wchar.h
    .... /usr/include/bits/wordsize.h
    ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
    ... /usr/include/xlocale.h
    Multiple include guards may be useful for:
    /usr/include/asm/errno.h
    /usr/include/bits/errno.h
    /usr/include/errno.h
    /usr/include/gnu/stubs-64.h
    /usr/include/gnu/stubs.h
    /usr/include/linux/errno.h
    /usr/include/wchar.h
    
    JonBJ 1 Reply Last reply
    0
    • Y yanni

      From here, I know that there are two versions of the library iconv. Obviously (see build error log below), the version that used in QT is from GNU libiconv, instead of that glibc. Since my centos does not have a libiconv, I downloaded and builded it, then add its lib/ to the top of my $LIBRARY_PATH. But the linker still can not find it.

      g++ -Wl,-e,qt_core_boilerplate -Wl,--no-undefined -Wl,--version-script,QtCore.version -Wl,-O1 -Wl,--enable-new-dtags -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list,/home/me/my_soft/qt-everywhere-src-5.15.5/qtbase/src/corelib/QtCore.dynlist -Wl,-soname,libQt5Core.so.5 -o libQt5Core.so.5.15.5 .obj/minimum-linux.o .obj/qstring_compat.o .obj/qabstractanimation.o .obj/qvariantanimation.o .obj/qpropertyanimation.o .obj/qanimationgroup.o .obj/qsequentialanimationgroup.o .obj/qparallelanimationgroup.o .obj/qpauseanimation.o .obj/qendian.o .obj/qglobal.o .obj/qlibraryinfo.o .obj/qmalloc.o .obj/qnumeric.o .obj/qfloat16.o .obj/qoperatingsystemversion.o .obj/qlogging.o .obj/qrandom.o .obj/qhooks.o .obj/qversiontagging.o .obj/qrunnable.o .obj/qthread.o .obj/qthread_unix.o .obj/qatomic.o .obj/qmutex.o .obj/qreadwritelock.o .obj/qsemaphore.o .obj/qthreadpool.o .obj/qthreadstorage.o .obj/qwaitcondition_unix.o .obj/qexception.o .obj/qfutureinterface.o .obj/qfuturewatcher.o .obj/qresultstore.o .obj/qarraydata.o .obj/qbitarray.o .obj/qcryptographichash.o .obj/qfreelist.o .obj/qhash.o .obj/qline.o .obj/qlinkedlist.o .obj/qlist.o .obj/qpoint.o .obj/qmap.o .obj/qmargins.o .obj/qmessageauthenticationcode.o .obj/qcontiguouscache.o .obj/qrect.o .obj/qrefcount.o .obj/qringbuffer.o .obj/qshareddata.o .obj/qsharedpointer.o .obj/qsimd.o .obj/qsize.o .obj/qversionnumber.o .obj/qcommandlineoption.o .obj/qcommandlineparser.o .obj/bignum.o .obj/bignum-dtoa.o .obj/cached-powers.o .obj/diy-fp.o .obj/double-conversion.o .obj/fast-dtoa.o .obj/fixed-dtoa.o .obj/strtod.o .obj/qeasingcurve.o .obj/qtimeline.o .obj/qbytearray.o .obj/qbytearraylist.o .obj/qbytearraymatcher.o .obj/qcollator.o .obj/qlocale.o .obj/qlocale_tools.o .obj/qregexp.o .obj/qstring.o .obj/qstringbuilder.o .obj/qstringlist.o .obj/qstringview.o .obj/qtextboundaryfinder.o .obj/qunicodetools.o .obj/qvsnprintf.o .obj/qlocale_unix.o .obj/qcollator_posix.o .obj/qregularexpression.o .obj/harfbuzz-buffer.o .obj/harfbuzz-gdef.o .obj/harfbuzz-gsub.o .obj/harfbuzz-gpos.o .obj/harfbuzz-impl.o .obj/harfbuzz-open.o .obj/harfbuzz-stream.o .obj/harfbuzz-shaper-all.o .obj/qharfbuzz.o .obj/qdatetime.o .obj/qcalendar.o .obj/qgregoriancalendar.o .obj/qjuliancalendar.o .obj/qmilankoviccalendar.o .obj/qromancalendar.o .obj/qhijricalendar.o .obj/qislamiccivilcalendar.o .obj/qjalalicalendar.o .obj/qtimezone.o .obj/qtimezoneprivate.o .obj/qtimezoneprivate_tz.o .obj/qdatetimeparser.o .obj/qabstractfileengine.o .obj/qbuffer.o .obj/qdataurl.o .obj/qtldurl.o .obj/qdebug.o .obj/qdir.o .obj/qdiriterator.o .obj/qfile.o .obj/qfiledevice.o .obj/qfileinfo.o .obj/qipaddress.o .obj/qiodevice.o .obj/qlockfile.o .obj/qnoncontiguousbytedevice.o .obj/qstorageinfo.o .obj/qtemporarydir.o .obj/qtemporaryfile.o .obj/qresource.o .obj/qresource_iterator.o .obj/qsavefile.o .obj/qstandardpaths.o .obj/qurl.o .obj/qurlidna.o .obj/qurlquery.o .obj/qurlrecode.o .obj/qfsfileengine.o .obj/qfsfileengine_iterator.o .obj/qfilesystementry.o .obj/qfilesystemengine.o .obj/qfileselector.o .obj/qloggingcategory.o .obj/qloggingregistry.o .obj/qfilesystemwatcher.o .obj/qfilesystemwatcher_polling.o .obj/qfilesystemwatcher_inotify.o .obj/qprocess.o .obj/qprocess_unix.o .obj/qsettings.o .obj/qfsfileengine_unix.o .obj/qfilesystemengine_unix.o .obj/qlockfile_unix.o .obj/qfilesystemiterator_unix.o .obj/forkfd_qt.o .obj/qstandardpaths_unix.o .obj/qstorageinfo_unix.o .obj/qabstractitemmodel.o .obj/qitemselectionmodel.o .obj/qabstractproxymodel.o .obj/qconcatenatetablesproxymodel.o .obj/qidentityproxymodel.o .obj/qsortfilterproxymodel.o .obj/qtransposeproxymodel.o .obj/qstringlistmodel.o .obj/qfactoryinterface.o .obj/qpluginloader.o .obj/qfactoryloader.o .obj/quuid.o .obj/qlibrary.o .obj/qelfparser_p.o .obj/qmachparser.o .obj/qlibrary_unix.o .obj/qabstracteventdispatcher.o .obj/qabstractnativeeventfilter.o .obj/qbasictimer.o .obj/qdeadlinetimer.o .obj/qelapsedtimer.o .obj/qeventloop.o .obj/qcoreapplication.o .obj/qcoreevent.o .obj/qmetaobject.o .obj/qmetatype.o .obj/qmetaobjectbuilder.o .obj/qmimedata.o .obj/qobject.o .obj/qobjectcleanuphandler.o .obj/qsignalmapper.o .obj/qsocketnotifier.o .obj/qtimer.o .obj/qtranslator.o .obj/qvariant.o .obj/qcoreglobaldata.o .obj/qsharedmemory.o .obj/qsystemsemaphore.o .obj/qpointer.o .obj/qmath.o .obj/qsystemerror.o .obj/qtestsupport_core.o .obj/qcore_unix.o .obj/qeventdispatcher_unix.o .obj/qtimerinfo_unix.o .obj/qelapsedtimer_unix.o .obj/qsharedmemory_posix.o .obj/qsharedmemory_systemv.o .obj/qsharedmemory_unix.o .obj/qsystemsemaphore_posix.o .obj/qsystemsemaphore_systemv.o .obj/qsystemsemaphore_unix.o .obj/qutfcodec.o .obj/qlatincodec.o .obj/qsimplecodec.o .obj/qtextcodec.o .obj/qisciicodec.o .obj/qtsciicodec.o .obj/qgb18030codec.o .obj/qjpunicode.o .obj/qeucjpcodec.o .obj/qjiscodec.o .obj/qsjiscodec.o .obj/qeuckrcodec.o .obj/qbig5codec.o .obj/qiconvcodec.o .obj/qcborcommon.o .obj/qcbordiagnostic.o .obj/qcborvalue.o .obj/qdatastream.o .obj/qjsoncbor.o .obj/qjsondocument.o .obj/qjsonobject.o .obj/qjsonarray.o .obj/qjsonvalue.o .obj/qjsonwriter.o .obj/qjsonparser.o .obj/qtextstream.o .obj/qxmlstream.o .obj/qxmlutils.o .obj/qcborstreamreader.o .obj/qcborstreamwriter.o .obj/qbinaryjson.o .obj/qbinaryjsonarray.o .obj/qbinaryjsonobject.o .obj/qbinaryjsonvalue.o .obj/qstatemachine.o .obj/qabstractstate.o .obj/qstate.o .obj/qfinalstate.o .obj/qhistorystate.o .obj/qabstracttransition.o .obj/qsignaltransition.o .obj/qeventtransition.o .obj/qmimedatabase.o .obj/qmimetype.o .obj/qmimemagicrulematcher.o .obj/qmimetypeparser.o .obj/qmimemagicrule.o .obj/qmimeglobpattern.o .obj/qmimeprovider.o .obj/moc_qcalendar.o .obj/moc_qobjectdefs.o .obj/moc_qmimetype.o  -lpthread -lm -lz /home/me/my_soft/qt-everywhere-src-5.15.5/qtbase/lib/libqtpcre2.a -ldl
      
      .obj/qiconvcodec.o: In function `qIconvCodecStateFree(QTextCodec::ConverterState*)':
      qiconvcodec.cpp:(.text+0x105): undefined reference to `libiconv_close'
      .obj/qiconvcodec.o: In function `QIconvCodec::IconvState::~IconvState()':
      qiconvcodec.cpp:(.text+0x20f): undefined reference to `libiconv_close'
      .obj/qiconvcodec.o: In function `QIconvCodec::createIconv_t(char const*, char const*) const':
      

      After adding -liconv mannually to the end of the following g++ command, it can succuessfully link.

      My question is, why linker can not find libiconv even if it is on top of my $LIBRARY_PATH ? May be glibc has been linked previously, it found symbols there and directly use it here, without looking into $LIBRARY_PATH ?

      Below is a test used to demonstrate that I have to explicilty specify link to libiconv (copied from previous stackoverflow answer)

      #include <iconv.h>
      
      int main( int argc, char **argv ) {
              iconv_t cd = iconv_open( "UTF-8", "ISO-8859-1" );
              iconv_close( cd );
              return 0;
      }
      

      gcc -H iconv.c -o hh

      . /home/me/my_soft/libiconv/1.17/include/iconv.h
      .. /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
      .. /usr/include/errno.h
      ... /usr/include/features.h
      .... /usr/include/sys/cdefs.h
      ..... /usr/include/bits/wordsize.h
      .... /usr/include/gnu/stubs.h
      ..... /usr/include/gnu/stubs-64.h
      ... /usr/include/bits/errno.h
      .... /usr/include/linux/errno.h
      ..... /usr/include/asm/errno.h
      ...... /usr/include/asm-generic/errno.h
      ....... /usr/include/asm-generic/errno-base.h
      .. /usr/include/wchar.h
      ... /usr/include/stdio.h
      ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdarg.h
      ... /usr/include/bits/wchar.h
      .... /usr/include/bits/wordsize.h
      ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
      ... /usr/include/xlocale.h
      Multiple include guards may be useful for:
      /usr/include/asm/errno.h
      /usr/include/bits/errno.h
      /usr/include/errno.h
      /usr/include/gnu/stubs-64.h
      /usr/include/gnu/stubs.h
      /usr/include/linux/errno.h
      /usr/include/wchar.h
      /tmp/ccJ122v1.o: In function `main':
      iconv.c:(.text+0x1a): undefined reference to `libiconv_open'
      iconv.c:(.text+0x2a): undefined reference to `libiconv_close'
      collect2: error: ld returned 1 exit status
      

      However, if gcc -H iconv.c -o hh -liconv, it succeeds.

      . /home/me/my_soft/libiconv/1.17/include/iconv.h
      .. /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
      .. /usr/include/errno.h
      ... /usr/include/features.h
      .... /usr/include/sys/cdefs.h
      ..... /usr/include/bits/wordsize.h
      .... /usr/include/gnu/stubs.h
      ..... /usr/include/gnu/stubs-64.h
      ... /usr/include/bits/errno.h
      .... /usr/include/linux/errno.h
      ..... /usr/include/asm/errno.h
      ...... /usr/include/asm-generic/errno.h
      ....... /usr/include/asm-generic/errno-base.h
      .. /usr/include/wchar.h
      ... /usr/include/stdio.h
      ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdarg.h
      ... /usr/include/bits/wchar.h
      .... /usr/include/bits/wordsize.h
      ... /cm/shared/apps/gcc8/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stddef.h
      ... /usr/include/xlocale.h
      Multiple include guards may be useful for:
      /usr/include/asm/errno.h
      /usr/include/bits/errno.h
      /usr/include/errno.h
      /usr/include/gnu/stubs-64.h
      /usr/include/gnu/stubs.h
      /usr/include/linux/errno.h
      /usr/include/wchar.h
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @yanni said in Build qt5 on centos7, linker can not link libiconv even if it exists:

      After adding -liconv mannually to the end of the following g++ command, it can succuessfully link.

      linker can not find libiconv even if it is on top of my $LIBRARY_PATH

      Maybe I have it wrong, but I don't understand your question. Regardless of library path, if you want code to link with a library you have to specify -l<library-name>.

      And you show an include directory hierarchy, but includes are not an issue here.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yanni
        wrote on last edited by
        #3

        Yeah, you are right, we have to specify -l<lib-name>, I forgot it. So, this is a bug in the QT? It needs libiconv, but it does not specify it in g++ command.

        I show include directory here becasuse there are two versions of the iconv, one in glibc, one in libiconv, their headers have the same name <iconv.h>. I was worried about that I include the header from libiconv, but link against lib from glibc (use the command gcc -H iconv.c -o hh), this would yield exactly the same error, as follows

        /tmp/ccJ122v1.o: In function `main':
        iconv.c:(.text+0x1a): undefined reference to `libiconv_open'
        iconv.c:(.text+0x2a): undefined reference to `libiconv_close'
        collect2: error: ld returned 1 exit status
        

        By the way, I did not find the dependency of libiconv in qt-wiki, but it indeed need it here. It is weird.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yanni
          wrote on last edited by yanni
          #4

          It seems to be a bug, see here and here

          To solve this, the configure comamnd should be adjusted:

          ./configure --iconv=posix
          

          The syntax is a little bit different from that in configure --help output, see here

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved