Project

General

Profile

Bug #1150

Unable to build for Mac OSX 10.6

Added by Max Pozdeev almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
build
Target version:
Start date:
09 Jan 2016
Due date:
% Done:

100%

Estimated time:
2.00 h

Description

I can not build the library from latest revision for the Mac OSX 10.6.
I'm using a Mac with OSX 10.10 64bit, so I put the line "-stdlib=libstdc++ -mmacosx-version-min=10.6" into CPPFLAGS, LDFLAGS, etc.
The error:

actions.cpp:1973:26: error: no viable conversion from 'const std::string' (aka 'const basic_string<char>')
      to 'const char *'
                fb.open (target,std::ios::out);
                         ^~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/fstream:286:24: note: 
      passing argument to parameter '__s' here
      open(const char* __s, ios_base::openmode __mode);
                       ^


Related issues

Related to Exiv2 - Feature #1149: Support for metadata in FLIR One thermal images (jpeg)New09 Jan 2016

Actions

Associated revisions

Revision 4177 (diff)
Added by Robin Mills almost 6 years ago

#1150. Fixed build breaker on elderly Macs (10.6 and earlier).

History

#1

Updated by Robin Mills almost 6 years ago

  • Category set to build
  • Status changed from New to Assigned
  • Assignee set to Robin Mills
  • Target version set to 0.26
  • % Done changed from 0 to 50
  • Estimated time set to 2.00 h

Max. Thanks for letting me know about this. I was very surprised by this because I obtained that code from a very credible source: http://www.cplusplus.com/reference/ostream/ostream/ostream/

The quick fix is to change:

fb.open (target,std::ios::out);
to:
fb.open (target.c_str(),std::ios::out);
However, I'm uneasy about that. c_str() is a legacy thing and should be avoided. I'll have a proper look at this on Sunday.

#2

Updated by Robin Mills almost 6 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 50 to 100

Fix submitted: r4177

Good News, this code was broken on the buildsever. I submitted the code and went to the movies. It had only been on the trunk for an hour when you raised this matter. So, I would have discovered this when I got home from the movies!

I've replaced the filebuf code in src/actions.cpp:

// http://www.cplusplus.com/reference/ostream/ostream/ostream/
std::filebuf fb;
fb.open (target.c_str(),std::ios::out);
std::ostream os(&fb);
sourceImage->printStructure(os,Exiv2::kpsXMP);
fb.close();
with:
// http://www.cplusplus.com/doc/tutorial/files/
std::ofstream os;
os.open(target.c_str());
sourceImage->printStructure(os,Exiv2::kpsXMP);
os.close();
Which is shorter and more obvious. I need the c_str() on Tiger and Cygwin. It may be possible to detect the version of STL and only include the c_str() when essential, however I'll investigate that possibility if a bug is reported which implicates this code. For the moment it builds and passes the test suite on our supported platforms. http://exiv2.dyndns.org:8080/job/Exiv2-trunk/2348/

#3

Updated by Max Pozdeev almost 6 years ago

Thank you, it works.

#4

Updated by Robin Mills almost 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF