linking time type mismatching error

L

lionqiang

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::allocator<char> > said:
, 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::allocator<char> > said:
, 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
 
V

Victor Bazarov

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
 
L

lionqiang

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 said:
CreateMatrix.cpp:(.text+0x2cd): undefined reference to
`std::getAlignmentTool(std::basic_string<char, std::char_traits<char>,

^^^^^^^^^^^^^^^^^^^^^> std::allocator said:
../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
 
V

Victor Bazarov

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 said:
CreateMatrix.cpp:(.text+0x2cd): undefined reference to
`std::getAlignmentTool(std::basic_string<char,
std::char_traits<char>,

^^^^^^^^^^^^^^^^^^^^^> std::allocator said:
../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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top