etc.c.zlib help

Matthew Gamble via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 2 11:05:30 PDT 2015


On Thursday, 2 July 2015 at 12:36:35 UTC, Nicholas Wilson wrote:
> On Thursday, 2 July 2015 at 03:07:43 UTC, Matthew Gamble wrote:
>> I am trying to make the transition from C++ to D. I've hit a 
>> snag with the etc.c.zlib module where any attempt to use this 
>> module to open a file yields an error:
>> Error 42: Symbol Undefined __lseeki64.
>>
>> Here is a simple example of code that gives the error upon 
>> compilation.
>>
>> import std.stdio;
>> import etc.c.zlib;
>>
>> void main(string[] args)
>> {
>> 	char[] fName = "C:\\Users\\Matthew 
>> Gamble\\Documents\\sample.bam\0".dup;
>> 	char[] mode ="r\0".dup;
>> 	gzFile bamFile; //no error here
>> 	bamFile = gzopen(&fName[0],&mode[0]); //this is where the 
>> error hits
>> }
>>
>
> Is that a compiler error or a linker error?
>
>>I'm probably doing something obviously wrong, so have mercy. If 
>>etc.c.zlib
>> is not the preferred way to read from a binary gzipped file 
>> any advice would be appreciated. Thanks.
>
>>char[] fName = "C:\\Users\\Matthew 
>>Gamble\\Documents\\sample.bam\0".dup;
>>bamFile = gzopen(&fName[0],&mode[0]);
>
> would be probably be more easily understood if written as:
> string fName  = "C:\\Users\\Matthew 
> Gamble\\Documents\\sample.bam";
> bamFile = gzopen(fName.ptr,mode.ptr);
>
> as string _literals_ are nul terminated in D ( but not 
> dynamically constructed ones: use .toStringz on them) assuming 
> that gzopen doesn't manipulate it's arguments (I would very 
> much doubt that).
>
> Also if you're trying to do bam parsing/manipulating/whatever 
> try to get a hold of Artem Tarasov who occasionally posts on 
> these forums. He wrote the worlds fastest bam parser in D. He 
> might be able to give you some hints on further questions.

Thanks for the style tips. I will incorporate them in the future.
I was digging through Artem's BAM parser code and it also makes 
use of a stripped down version of etc.c.zlib, so it seems like I 
would have the same problem if I was to compile his parser, but I 
can try that and perhaps alter my program to make use of pipes 
from Sambamba. That's not something I've considered before.

However, I only need the positional and flag information from the 
BAM files and I have previously written a parser in C++ using 
zlib that could do the job. I was just trying to move that parser 
over to D as a learning experience and so that I could easily 
incorporate it with the other programs I will write in D.

Here is the full output upon building the program in VS2013 with 
Visual D:

------ Build started: Project: zlibTest, Configuration: Release 
Win32 ------
Building Release\zlibTest.exe...
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\D\dmd2\windows\bin\..\lib\phobos.lib(gzlib)
  Error 42: Symbol Undefined __lseeki64
Building Release\zlibTest.exe failed!
Details saved as "file://C:\Users\Matthew Gamble\documents\visual 
studio 
2013\Projects\file_readers\ConsoleApp1\Release\zlibTest.buildlog.html"
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped 
==========

Seems like a linking issue. I tried adding 
"C:\D\dmd2\windows\lib" to the lib search path in the linker 
properties in VS, But that did not help.

I would have thought that linking to a module in phobos would be 
automatic, like for std.stdio. Is that not the case?

Any advice or tips would be appreciated.

Thanks,

Matt


More information about the Digitalmars-d-learn mailing list