linking time type mismatching error

Discussion in 'C++' started by lionqiang@gmail.com, Nov 16, 2007.

  1. Guest

    I am trying to compile a package protclust-1.0.1 which is written by
    someone by in 2003.
    The run of ./configure is ok without error. But when I try to compile
    it, 'make' stops with following error message.

    It seems there is a type mismatch between the type used in the program
    and the basic c++ string type ...
    Or I am missing some point ??

    All the programs have passed the syntax check using 'gcc -fsyntax-only
    -Wall'.
    Note: to compile this package you also need another package called
    xmlio-1.0.0 .

    many thanks,

    The following the error message I got after call 'make'.
    ---------------------------------------------------------
    /bin/sh ../libtool --mode=link c++ -I/users/sista/qfu/local/include -
    O2 -o CreateMatrix CreateMatrix.o ../Matrix/libMatrix.a ../
    Clustering/libClustering.a ../Global/libGlobal.
    a -L/users/sista/qfu/local/lib -lxmlio -lexpat
    c++ -I/users/sista/qfu/local/include -O2 -o CreateMatrix
    CreateMatrix.o ../Matrix/libMatrix.a ../Clustering/libClustering.a ../
    Global/libGlobal.a -L/users/sista/qfu/local/lib /u
    sers/sista/qfu/local/lib/libxmlio.so /usr/lib/libexpat.so -Wl,--rpath -
    Wl,/users/sista/qfu/local/lib -Wl,--rpath -Wl,/users/sista/qfu/local/
    lib
    CreateMatrix.o: In function `main':
    CreateMatrix.cpp:(.text+0x298): undefined reference to
    `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    CreateMatrix.cpp:(.text+0x2cd): undefined reference to
    `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    .../Matrix/libMatrix.a(Matrix.o): In function `std::Matrix::save()':
    Matrix.cpp:(.text+0x296d): undefined reference to
    `std::writeSubstitutionMatrix(std::SubstitutionMatrix)'
    Matrix.cpp:(.text+0x298f): undefined reference to
    `std::writeScalingMethod(std::ScalingMethod)'
    Matrix.cpp:(.text+0x29b1): undefined reference to
    `std::writeAlignmentTool(std::AlignmentTool)'
    .../Matrix/libMatrix.a(Matrix.o): In function
    `std::Matrix::Matrix(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> > const&, std::map<std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >,
    std::basic_string<char, std::char_traits<char>, std::allocator<char>
    >, std::less<std::basic_string<char, std::char_traits<char>,

    std::allocator<char> > >,
    std::allocator<std::pair<std::basic_string<char,
    std::char_traits<char>, std::allocator<char> > const,
    std::basic_string<char, std::char_traits<char>, s
    td::allocator<char> > > > >&)':
    Matrix.cpp:(.text+0x3583): undefined reference to
    `std::eek:perator>>(std::basic_istream<char, std::char_traits<char> >&,
    std::SubstitutionMatrix&)'
    Matrix.cpp:(.text+0x3f9e): undefined reference to
    `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    Matrix.cpp:(.text+0x4019): undefined reference to
    `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    .../Matrix/libMatrix.a(Matrix.o): In function
    `std::Matrix::Matrix(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> > const&, std::map<std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >,
    std::basic_string<char, std::char_traits<char>, std::allocator<char>
    >, std::less<std::basic_string<char, std::char_traits<char>,

    std::allocator<char> > >,
    std::allocator<std::pair<std::basic_string<char,
    std::char_traits<char>, std::allocator<char> > const,
    std::basic_string<char, std::char_traits<char>, s
    td::allocator<char> > > > >&)':
    Matrix.cpp:(.text+0x5258): undefined reference to
    `std::eek:perator>>(std::basic_istream<char, std::char_traits<char> >&,
    std::SubstitutionMatrix&)'
    Matrix.cpp:(.text+0x5d31): undefined reference to
    `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    Matrix.cpp:(.text+0x5da3): undefined reference to
    `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    .../Matrix/libMatrix.a(Matrix.o): In function
    `std::Matrix::Matrix(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >, std::basic_string<char, std::char_traits
    <char>, std::allocator<char> > const&, std::AccessMode, unsigned
    short)':
    Matrix.cpp:(.text+0x85c1): undefined reference to
    `std::eek:perator>>(std::basic_istream<char, std::char_traits<char> >&,
    std::SubstitutionMatrix&)'
    Matrix.cpp:(.text+0x919d): undefined reference to
    `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    Matrix.cpp:(.text+0x920c): undefined reference to
    `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    .../Matrix/libMatrix.a(Matrix.o): In function
    `std::Matrix::Matrix(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >, std::basic_string<char, std::char_traits
    <char>, std::allocator<char> > const&, std::AccessMode, unsigned
    short)':
    Matrix.cpp:(.text+0xc8fa): undefined reference to
    `std::eek:perator>>(std::basic_istream<char, std::char_traits<char> >&,
    std::SubstitutionMatrix&)'
    Matrix.cpp:(.text+0xd598): undefined reference to
    `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    Matrix.cpp:(.text+0xd61e): undefined reference to
    `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,
    std::allocator<char> >)'
    collect2: ld returned 1 exit status
    make[2]: *** [CreateMatrix] Error 1
    make[2]: Leaving directory `/users/sista/qfu/tmp/protclust-1.0.1.org/
    Tools'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/users/sista/qfu/tmp/protclust-1.0.1.org/
    Tools'
    make: *** [all-recursive] Error 1
    , Nov 16, 2007
    #1
    1. Advertising

  2. wrote:
    > I am trying to compile a package protclust-1.0.1 which is written by
    > someone by in 2003.
    > The run of ./configure is ok without error. But when I try to compile
    > it, 'make' stops with following error message.
    >
    > It seems there is a type mismatch between the type used in the program
    > and the basic c++ string type ...
    > Or I am missing some point ??


    You are. It has nothing to do with the string type. It is all about
    where the functions are declared when they are used in your program.

    >
    > All the programs have passed the syntax check using 'gcc -fsyntax-only
    > -Wall'.
    > Note: to compile this package you also need another package called
    > xmlio-1.0.0 .
    >
    > many thanks,
    >
    > The following the error message I got after call 'make'.
    > ---------------------------------------------------------
    > /bin/sh ../libtool --mode=link c++ -I/users/sista/qfu/local/include -
    > O2 -o CreateMatrix CreateMatrix.o ../Matrix/libMatrix.a ../
    > Clustering/libClustering.a ../Global/libGlobal.
    > a -L/users/sista/qfu/local/lib -lxmlio -lexpat
    > c++ -I/users/sista/qfu/local/include -O2 -o CreateMatrix
    > CreateMatrix.o ../Matrix/libMatrix.a ../Clustering/libClustering.a
    > ../ Global/libGlobal.a -L/users/sista/qfu/local/lib /u
    > sers/sista/qfu/local/lib/libxmlio.so /usr/lib/libexpat.so -Wl,--rpath
    > - Wl,/users/sista/qfu/local/lib -Wl,--rpath
    > -Wl,/users/sista/qfu/local/ lib
    > CreateMatrix.o: In function `main':
    > CreateMatrix.cpp:(.text+0x298): undefined reference to
    > `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,

    ^^^^^^^^^^^^^^^^^^^^^
    > std::allocator<char> >)'
    > CreateMatrix.cpp:(.text+0x2cd): undefined reference to
    > `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,

    ^^^^^^^^^^^^^^^^^^^^^
    > std::allocator<char> >)'
    > ../Matrix/libMatrix.a(Matrix.o): In function `std::Matrix::save()':

    ^^^^^^^^^^^^^^^^^^^
    > [..]


    This is very suspect. Why does the linker think it needs all those
    functions from the 'std' namespace. For whatever reason you put
    the declarations of those function in 'std' namespace when you had
    no business to do so. Make sure you fix the declarations.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Nov 16, 2007
    #2
    1. Advertising

  3. Guest

    On Nov 16, 10:21 pm, "Victor Bazarov" <> wrote:
    > wrote:
    > > It seems there is a type mismatch between the type used in the program
    > > and the basic c++ string type ...
    > > Or I am missing some point ??

    >
    > You are. It has nothing to do with the string type. It is all about
    > where the functions are declared when they are used in your program.


    Can you make this point more clean ? Sorry, I am newbie about c++ ...

    > > CreateMatrix.cpp:(.text+0x298): undefined reference to
    > > `std::getScalingMethod(std::basic_string<char, std::char_traits<char>,

    >
    > ^^^^^^^^^^^^^^^^^^^^^> std::allocator<char> >)'
    > > CreateMatrix.cpp:(.text+0x2cd): undefined reference to
    > > `std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,

    >
    > ^^^^^^^^^^^^^^^^^^^^^> std::allocator<char> >)'
    > > ../Matrix/libMatrix.a(Matrix.o): In function `std::Matrix::save()':

    >
    > ^^^^^^^^^^^^^^^^^^^
    >
    > > [..]

    >
    > This is very suspect. Why does the linker think it needs all those
    > functions from the 'std' namespace. For whatever reason you put
    > the declarations of those function in 'std' namespace when you had
    > no business to do so. Make sure you fix the declarations.


    Yes, I know it is a very bad habit. It has a not very reasonable
    reason though.
    The package I try to compile is written in 2003. For unclear reason,
    it is
    written with a mixed use of namespace. Most of the cpp and h file
    comes with

    #ifdef HAVE_NAMESPACES
    using namespace std;
    #endif

    for the reason unclear to me. They cause some compilation errors,
    hence I removed
    them all. But then some function are then declared in 'std'
    namespace.

    I think I need to check the error more carefully. I will report my
    discover later today.

    PS: what is the intention of using #ifdef HAVE_NAMESPACES macro ?

    thx anyway
    , Nov 17, 2007
    #3
  4. wrote:
    > On Nov 16, 10:21 pm, "Victor Bazarov" <> wrote:
    >> wrote:
    >>> It seems there is a type mismatch between the type used in the
    >>> program and the basic c++ string type ...
    >>> Or I am missing some point ??

    >>
    >> You are. It has nothing to do with the string type. It is all about
    >> where the functions are declared when they are used in your program.

    >
    > Can you make this point more clean ? Sorry, I am newbie about c++ ...


    Clean? You mean, clear? I am not sure how much clearer I can make it.
    The missing functions have 'std::' in front of their names. Apparently,
    the compiler thinks they will come from 'std' namespace. Nothing should
    come from 'std' namespace except for the standard functions, types, and
    objects. Since 'getScalingMethod', 'getAlightmentTool', are definitely
    *not* standard, they should *not* be expected to come from 'std'.

    That means you placed them (the declarations) there, and you need to
    take them out. It has nothing to do with 'std::basic_string<char...'
    which is in fact what 'std::string' is.

    >
    >>> CreateMatrix.cpp:(.text+0x298): undefined reference to
    >>> `std::getScalingMethod(std::basic_string<char,
    >>> std::char_traits<char>,

    >>
    >> ^^^^^^^^^^^^^^^^^^^^^> std::allocator<char> >)'
    >>> CreateMatrix.cpp:(.text+0x2cd): undefined reference to
    >>> `std::getAlignmentTool(std::basic_string<char,
    >>> std::char_traits<char>,

    >>
    >> ^^^^^^^^^^^^^^^^^^^^^> std::allocator<char> >)'
    >>> ../Matrix/libMatrix.a(Matrix.o): In function `std::Matrix::save()':

    >>
    >> ^^^^^^^^^^^^^^^^^^^
    >>
    >>> [..]

    >>
    >> This is very suspect. Why does the linker think it needs all those
    >> functions from the 'std' namespace. For whatever reason you put
    >> the declarations of those function in 'std' namespace when you had
    >> no business to do so. Make sure you fix the declarations.

    >
    > Yes, I know it is a very bad habit. It has a not very reasonable
    > reason though.
    > The package I try to compile is written in 2003. For unclear reason,
    > it is
    > written with a mixed use of namespace. Most of the cpp and h file
    > comes with
    >
    > #ifdef HAVE_NAMESPACES
    > using namespace std;
    > #endif


    That wouldn't place the names of the functions into 'std'. It would
    simply bring the names declared in 'std' to the current scope.

    >
    > for the reason unclear to me. They cause some compilation errors,
    > hence I removed
    > them all. But then some function are then declared in 'std'
    > namespace.


    That's beyond my understanding.

    > I think I need to check the error more carefully. I will report my
    > discover later today.
    >
    > PS: what is the intention of using #ifdef HAVE_NAMESPACES macro ?


    I don't know. If I wrote it, I'd probably know why.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Nov 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. manish
    Replies:
    1
    Views:
    1,971
    Christopher Benson-Manica
    Apr 2, 2004
  2. engsol
    Replies:
    2
    Views:
    948
    Dan Bishop
    Jan 26, 2004
  3. flamesrock
    Replies:
    8
    Views:
    451
    Hendrik van Rooyen
    Nov 24, 2006
  4. Replies:
    0
    Views:
    321
  5. Lucio Mania

    linking web controls and components at design time in asp 2.0

    Lucio Mania, Dec 22, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    121
    Lucio Mania
    Dec 22, 2005
Loading...

Share This Page