Problems in compiling the CharLS from latest chnage set

Feb 1, 2012 at 5:06 PM

I got the following errors when I tried to compile CharLS from the latest change set i.e. charls-72278.

Can anyone comment on these errors. Sorry for the long list of errors.

khursheed@khursheed-desktop:~/charls-72278/trunk/charls$ make
Scanning dependencies of target CharLS
[ 10%] Building CXX object CMakeFiles/CharLS.dir/header.cpp.o
[ 20%] Building CXX object CMakeFiles/CharLS.dir/interface.cpp.o
[ 30%] Building CXX object CMakeFiles/CharLS.dir/jpegls.cpp.o
Linking CXX static library libCharLS.a
[ 30%] Built target CharLS
Scanning dependencies of target charlstest
[ 40%] Building CXX object CMakeFiles/charlstest.dir/test/main.cpp.o
/home/khursheed/charls-72278/trunk/charls/test/main.cpp: In function ‘bool ScanFile(const char*, std::vector<unsigned char, std::allocator<unsigned char> >*, JlsParameters*)’:
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:36: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:36: error:   initializing argument 2 of ‘std::basic_filebuf<_CharT, _Traits>* std::basic_filebuf<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp: In function ‘void TestEncodeFromStream(char*, int, int, int, int, int, int, size_t)’:
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:230: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:230: error:   initializing argument 2 of ‘std::basic_filebuf<_CharT, _Traits>* std::basic_filebuf<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp: In function ‘void TestDecodeFromStream(char*)’:
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:330: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:330: error:   initializing argument 2 of ‘std::basic_filebuf<_CharT, _Traits>* std::basic_filebuf<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp: In function ‘JLS_ERROR DecodeRaw(char*, char*)’:
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:352: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:352: error:   initializing argument 2 of ‘std::basic_fstream<_CharT, _Traits>::basic_fstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:355: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:355: error:   initializing argument 2 of ‘std::basic_fstream<_CharT, _Traits>::basic_fstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp: In function ‘void TestEncodeFromStream()’:
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:369: warning: deprecated conversion from string constant to ‘char*’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:371: warning: deprecated conversion from string constant to ‘char*’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:372: warning: deprecated conversion from string constant to ‘char*’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp: In function ‘int main(int, char**)’:
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:452: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:452: error:   initializing argument 2 of ‘std::basic_fstream<_CharT, _Traits>::basic_fstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:453: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:453: error:   initializing argument 2 of ‘std::basic_fstream<_CharT, _Traits>::basic_fstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:465: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:465: error:   initializing argument 2 of ‘std::basic_fstream<_CharT, _Traits>::basic_fstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:466: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’
/home/khursheed/charls-72278/trunk/charls/test/main.cpp:466: error:   initializing argument 2 of ‘std::basic_fstream<_CharT, _Traits>::basic_fstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]’
make[2]: *** [CMakeFiles/charlstest.dir/test/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/charlstest.dir/all] Error 2
make: *** [all] Error 2

Mar 28, 2012 at 2:57 PM
<!-- p { margin-bottom: 2.12mm; } -->

I had a similar problem and I overcame it by fixing the declaration of the mode_input and mode_output constants in test/main.cpp:

--- charls-72278.org/trunk/charls/test/main.cpp 2012-01-20 09:36:16.000000000 +0100
+++ charls-72278/trunk/charls/test/main.cpp     2012-03-28 10:27:43.000000000 +0200
@@ -22,8 +22,8 @@
 
 typedef const char* SZC;
 
-const std::ios_base::open_mode mode_input  = std::ios_base::in  | std::ios::binary;
-const std::ios_base::open_mode mode_output = std::ios_base::out | std::ios::binary;
+const std::ios_base::openmode mode_input  = std::ios_base::in  | std::ios::binary;
+const std::ios_base::openmode mode_output = std::ios_base::out | std::ios::binary;
 
 bool ScanFile(SZC strNameEncoded, std::vector* rgbyteFile, JlsParameters* info)
 {

The correct standard type is ios_base::openmode without underscore. For confirmation see here:

http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/9dba0175a6852c81

Apr 3, 2012 at 7:53 PM

@danib: thanks, will incorporate this.

Marked as answer by vbaderks on 1/14/2014 at 3:18 AM