Bug #1150

Unable to build for Mac OSX 10.6

Added by Max Pozdeev over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:09 Jan 2016
Priority:NormalDue date:
Assignee:Robin Mills% Done:

100%

Category:buildEstimated time:2.00 hours
Target version:0.26

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) New 09 Jan 2016

Associated revisions

Revision 4177
Added by Robin Mills over 1 year ago

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

History

#1 Updated by Robin Mills over 1 year 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

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 over 1 year 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 over 1 year ago

Thank you, it works.

#4 Updated by Robin Mills over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux