[Clp] problems compiling Clp with gcc/g++ 3.3.5

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Wed Feb 11 00:38:14 EST 2009


On Tue, 10 Feb 2009, Kish Shen wrote:

> As I mentioned in my previous post, I was unable to compile the latest
> trunk branch Cbc, and the problem seem to occur when compiling Clp. I
> have since tried compiling Cbc on a x86-64 Linux machine, which has
> gcc 4.1, and this compiled without the problem, so I assume it is an
> issue with the gcc version.

Though the message isn't very good, I think the code is in error.

> The problem occurs when trying to compile unitTest.cpp, apparently in
> line 1978 (see the partial output from the compiler at the end of this
> message). Line 1978 is the line starting with blockName in the following:
>
>     CoinStructuredModel structured;
>     int numberBlocks=5;
>     for (int i=0;i<numberBlocks;i++) {
>       std::string topName="row_master";
>       std::string blockName="block_";
>       blockName.append(1,'a'+i);

'a'+1 is an int, but is probably intended to be a char.
append is rather overloaded.
I think that int to char is not one of the
allowed conversions for overload resolution.
None of the non-template methods matched,
so the compiler inferred you wanted a template method,
but that didn't match either.
As the last thing tried, it got mentioned in the error message.

An explicit cast should fix it.

>       structured.addBlock(topName,blockName,top);
>       structured.addBlock(blockName,blockName,sub);
>     }
>
> This code is not in the unitTest.cpp of the Cbc I downloaded on
> 2008-11-04, which I was able to compile with gcc 3.3.
>
> I am wondering if it is possible to work around this problem? gcc 3
> is still not that old -- two different systems I have access to, and
> which were both set up about 3 to 4 years ago, both have gcc 3 (3.3 and
> 3.2) as the gcc compiler. I am not in a position to replace the gcc used
> on these system, and in any case, it would be perferable to be able to
> compile with gcc 3, because the binaries (we distribute in both binary
> and source forms) will run on more machines.
>
> Thanks and cheers,
>
> Kish
> ======
>
> The (start of) error output by g++ when compiling unitTest.cpp:
>
>
> if g++ -DHAVE_CONFIG_H -DUFL_BARRIER -I. -I`echo ../../../Clp/src`
> -I../inc  -I`echo /homes/kish/CoinCbcClp20090210/CoinUtils/src` -I`echo
> /homes/kish/CoinCbcClp20090210/i386_linux/Clp/../CoinUtils/inc`   -O2
> -fno-omit-frame-pointer -momit-leaf-frame-pointer -DNDEBUG   -MT
> unitTest.o -MD -MP -MF ".deps/unitTest.Tpo" -c -o unitTest.o
> ../../../Clp/src/unitTest.cpp; \
> then mv -f ".deps/unitTest.Tpo" ".deps/unitTest.Po"; else rm -f
> ".deps/unitTest.Tpo"; exit 1; fi
> /usr/include/c++/3.3.5/bits/stl_iterator_base_types.h: In instantiation
> of `std::iterator_traits<int>':
> /usr/include/c++/3.3.5/bits/basic_string.h:624:   instantiated from
> `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
> _Traits, _Alloc>::replace(__gnu_cxx::__normal_iterator<typename
> _Alloc::pointer, std::basic_string<_CharT, _Traits, _Alloc> >,
> __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
> std::basic_string<_CharT, _Traits, _Alloc> >, _InputIterator,
> _InputIterator) [with _InputIterator = int, _CharT = char, _Traits =
> std::char_traits<char>, _Alloc = std::allocator<char>]'
> /usr/include/c++/3.3.5/bits/basic_string.h:492:   instantiated from
> `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
> _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with
> _InputIterator = int, _CharT = char, _Traits = std::char_traits<char>,
> _Alloc = std::allocator<char>]'
> ../../../Clp/src/unitTest.cpp:1978:   instantiated from here
> /usr/include/c++/3.3.5/bits/stl_iterator_base_types.h:126: error: `int'
> is not
>    a class, struct, or union type
> /usr/include/c++/3.3.5/bits/stl_iterator_base_types.h:127: error: `int'
> is not
> ...etc.

-- 
Michael   hennebry at web.cs.ndsu.NoDak.edu
"Pessimist: The glass is half empty.
Optimist:   The glass is half full.
Engineer:   The glass is twice as big as it needs to be."




More information about the Clp mailing list