bug-ddrescue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-ddrescue] Compiling ddrescue 1.1 on Windows with Cygwin


From: DePriest, Jason R.
Subject: [Bug-ddrescue] Compiling ddrescue 1.1 on Windows with Cygwin
Date: Thu, 5 Jan 2006 20:01:16 +0000

I know you have no plans to support ddrescue on any platform other
than GNU/Linux platforms.

I was able to get ddrescue compiled under Cygwin by making a couple of
adjustments.  I thought some of the other readers of this list might
find this information helpful.

I used these list message as a starting point:
http://lists.gnu.org/archive/html/bug-ddrescue/2005-08/msg00001.html
http://lists.gnu.org/archive/html/bug-ddrescue/2005-01/msg00001.html

Basically, you take most of the std::snprintf and std::llabs entries
and drop the 'std::' prefix.  I do not know why it works, but it does.

Here is what patches for this would look like.

ddrescue.cc.patch
178c178
<   for( int i = 0; i < 8 && std::llabs( num ) > std::llabs( max ); ++i )
---
>   for( int i = 0; i < 8 && llabs( num ) > llabs( max ); ++i )
180c180
<   std::snprintf( buf, sizeof( buf ), "%lld %s", num, p );
---
>   snprintf( buf, sizeof( buf ), "%lld %s", num, p );

logbook.cc.patch
167c167
<   std::snprintf( buf, sizeof( buf ), "error in logfile %s, line %d\n",
---
>   snprintf( buf, sizeof( buf ), "error in logfile %s, line %d\n",
191c191
<     std::snprintf( buf, sizeof( buf ), "error opening logfile %s for
writing", filename );
---
>     snprintf( buf, sizeof( buf ), "error opening logfile %s for writing", 
> filename );
209c209
<     std::snprintf( buf, sizeof( buf ), "error writing logfile %s", filename );
---
>     snprintf( buf, sizeof( buf ), "error writing logfile %s", filename );
230c230
<       std::snprintf( buf, sizeof( buf ), "can't start reading at pos %lld",
---
>       snprintf( buf, sizeof( buf ), "can't start reading at pos %lld",
232c232
<       std::snprintf( buf, sizeof( buf ), "input file is only %lld bytes long",
---
>       snprintf( buf, sizeof( buf ), "input file is only %lld bytes long",
389c389
<       std::snprintf( msgbuf + msglen, sizeof( msgbuf ) - msglen,
"%d", retry );
---
>       snprintf( msgbuf + msglen, sizeof( msgbuf ) - msglen, "%d", retry );

main.cc.patch
92c92
<   long long result = std::strtoll( ptr, &tail, 0 );
---
>   long long result = strtoll( ptr, &tail, 0 );
125c125
<       if( LONG_LONG_MAX / factor >= std::llabs( result ) ) result *= factor;
---
>       if( LONG_LONG_MAX / factor >= llabs( result ) ) result *= factor;
150c150
<   std::snprintf( buf, sizeof( buf ), "internal error: %s.\n", msg );
---
>   snprintf( buf, sizeof( buf ), "internal error: %s.\n", msg );

And to help folks searching, here are the error messages you'll get
under Cygwin if you don't make these changes:
g++  -Wall -W -O2 -c -o ddrescue.o ddrescue.cc
ddrescue.cc: In function `const char* format_num(long long int, long
long int, int)':
ddrescue.cc:178: error: `llabs' is not a member of `std'
ddrescue.cc:178: error: `llabs' is not a member of `std'
ddrescue.cc:180: error: `snprintf' is not a member of `std'
make: *** [ddrescue.o] Error 1

g++  -Wall -W -O2 -c -o logbook.o logbook.cc
logbook.cc: In function `void <unnamed>::logfile_error(const char*, int)':
logbook.cc:167: error: `snprintf' is not a member of `std'
logbook.cc: In function `bool <unnamed>::update_logfile(const
std::vector<Sblock, std::allocator<Sblock> >&, const char*, int,
bool)':
logbook.cc:191: error: `snprintf' is not a member of `std'
logbook.cc:209: error: `snprintf' is not a member of `std'
logbook.cc: In member function `void Logbook::set_rescue_domain(long
long int, long long int, long long int, long long int)':
logbook.cc:230: error: `snprintf' is not a member of `std'
logbook.cc:232: error: `snprintf' is not a member of `std'
logbook.cc: In member function `int Logbook::copy_errors()':
logbook.cc:389: error: `snprintf' is not a member of `std'
make: *** [logbook.o] Error 1

g++  -Wall -W -O2 -c -o main.o main.cc
main.cc: In function `long long int <unnamed>::getnum(const char*,
int, long long int, long long int)':
main.cc:92: error: `strtoll' is not a member of `std'
main.cc:125: error: `llabs' is not a member of `std'
main.cc: In function `void internal_error(const char*)':
main.cc:150: error: `snprintf' is not a member of `std'
make: *** [main.o] Error 1

You also have to edit the resultant Makefile since Cygwin sticks a
'.exe' on the end of binary files to appease its Windows overlord.

Makefile.patch
57c57
<       $(INSTALL_PROGRAM) ./ddrescue $(DESTDIR)$(bindir)/ddrescue
---
>       $(INSTALL_PROGRAM) ./ddrescue.exe $(DESTDIR)$(bindir)/ddrescue.exe
72c72
<       -rm -f $(DESTDIR)$(bindir)/ddrescue
---
>       -rm -f $(DESTDIR)$(bindir)/ddrescue.exe

Or you get something like this:
install: cannot set time stamps for `/usr/local/bin/ddrescue': No such
file or directory
make: *** [install] Error 1

Enjoy!

-Jason

PS - Right before I went on vacation for the holidays, I hosed my work
Debian GNU/Linux system, so I have to rely on Cygwin until I have time
to rebuild it.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]