Bennis Welt

Pirat, Physiker, Free Software Nerd

Compiling your own dcraw binaries

with 14 comments

As I moved almost completely to Linux I don’t update the binaries on a regular basis. So I decided to write a quick guide to let everybody build their own when in a hurry.

1. Answer the questions of the zip-picker, download all the necessary files and read the instructions on the page:

If you don’t want to create zip files, skip the next step

2. Download 7-zip and extract 7za.exe to C:\

3. Create a batch file using mine (rename to .bat !) as example and modify it to fit your needs.

Happy compiling 😀

edit: I forgot to add that if you don’t have jpeglib.h available, you have to change your dcraw.c and add ‚#define NO_JPEG‘ in line 26. If you don’t, there may be compiling errors! It should look the following way:

#define NO_JPEG
#define _GNU_SOURCE

Written by benniswelt

August 28, 2005 um 10:37

Veröffentlicht in Uncategorized

Tagged with

14 Antworten

Subscribe to comments with RSS.

  1. Hi, Thanks for the advice for compiling the latest dcraw. I tried but go this error on windows XP with GCC

    Any ideas or pointers would be cool, I am not a c/c++ programmer 😦

    C:\Dev-Cpp\bin>gcc dcraw.c -ljpeg -lm -o dcraw.exe

    dcraw.c: In function `read_shorts‘:
    dcraw.c:247: warning: passing arg 1 of `swab‘ from incompatible pointer type
    dcraw.c:247: warning: passing arg 2 of `swab‘ from incompatible pointer type
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x271):dcraw.c: undefined
    reference to `ntohs@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x6dcb):dcraw.c: undefined
    reference to `htonl@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x700e):dcraw.c: undefined
    reference to `ntohs@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x7051):dcraw.c: undefined
    reference to `ntohs@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x14af9):dcraw.c: undefine
    d reference to `ntohl@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x1861a):dcraw.c: undefine
    d reference to `htonl@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x18637):dcraw.c: undefine
    d reference to `htonl@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x18741):dcraw.c: undefine
    d reference to `htons@4′
    C:\DOCUME~1\ANDY~1.QCO\LOCALS~1\Temp/ccEvbaaa.o(.text+0x188a9):dcraw.c: undefine
    d reference to `htons@4′
    collect2: ld returned 1 exit status


    September 12, 2005 at 00:20

  2. you have to modify dcraw.c and add a #define NO_JPEG in line 26. I’ll add this ASAP to the guide. Thanks. Hopefully this will fix your problem.


    September 12, 2005 at 09:58

  3. Hi, thanks for the reply, I tried the above exclude of JPEG, but the results were the same as in my first post, I also installed the JPEG lib package the specific jpeg compile errors do not occur either way, but the above errors still do. I am using the latest Bloodshed Dev C/C++ to compile which inludes GCC 3.4.2 mingw special. I also tried the latest DJGPP, but this produced the exact same errors.


    September 12, 2005 at 22:19

  4. Sorry I couldn’t help. Maybe you should ask Dave.


    September 13, 2005 at 09:21

  5. Hi everybody,

    This is for Andy:
    I had exactly the same problem with dev-cpp, then I switched to DJGPP and finally I could compile dcraw.
    The compiler shows a lot of warnings about the signedness of some arguments but no errors, and the resulting binaries seem to work fine.
    I followed the instructions on readme.1st for winxp. I did not edit the source code, but added -DNO_JPEG to the arguments.
    hope this helps, I can provide more details on the setup if you are interested.


    Oktober 5, 2005 at 20:10

  6. I use with Dev-Cpp (mingw32):
    set Path=C:\Dev-Cpp\bin;%PATH%
    gcc -DNO_JPEG -O3 dcraw.c -o dcraw.exe -lm -lws2_32

    Serge Petrov

    Oktober 6, 2005 at 01:53

  7. What about support for othe camera models ? I have unlocked an Olympus C-3030 for RAW-Support. What can I do to use dcraw for my Oly 3030 RAW files ? The lates build denies the conversion of my RAW files.

    Mustafa Görmezer

    November 24, 2005 at 23:39

  8. I’ll get the exact error as Andy when I try to compile dcraw.c. This happens using gcc from MinGW. Only thing I get to compile without any errors is dcraw.c with cygwin. Any ideas because I would like to use gcc from my MinGW installation?


    Februar 17, 2007 at 01:41

  9. Anyone found the solution to Andy’s problem??

    DJGpp throws the same errors on my end..
    C:\DCRAW>gcc dcraw.c -DNO_LCMS -lm -o dcraw.exe
    dcraw.c: In function ‚main‘:
    dcraw.c:8253: warning: incompatible implicit declaration of built-in function ’snprintf‘
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x683): undefined reference to `_getc_unlocked‘
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x6a9): undefined reference to `_getc_unlocked‘
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x1ce4): undefined reference to `_getc_unlocked‘
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x1d15): undefined reference to `_getc_unlocked‘
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x2609): undefined reference to `_getc_unlocked‘
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x2d45): more undefined references to `_getc_unlocked‘ follow
    c:/djgpp/tmp/cc3scQQB.o:dcraw.c:(.text+0x2bf2a): undefined reference to `_snprintf‘
    collect2: ld returned 1 exit status

    I think it has to do with improper linking of the libs.. but how to get rid of this ?? lets hope that the author creates the new binaries for us and hopefully share his experiences with us :}

    Winxp SP2+DJGPP -> shows many errors.. disabling options such as -DNO_JPEG and -DNO_LCMS even is not enough for it to compile correctly.. andy please save us :}


    November 30, 2007 at 11:39

  10. As I converted to cygwin I can’t help, sorry!


    November 30, 2007 at 19:31

  11. Hello all. I would like to share my experiences with people who are finding problems in compiling the latest source of DCraw (1.396).

    Compiler/IDE used : DJGPP (GCC, RHIDE etc) See the link above for gettin hands on this baby.
    Compiled on : Winxp SP2
    Reason for compilation : Porting the source to other appications.

    Command Line for compilation : C:\DCRAW>gcc dcraw.c -DNO_LCMS -DNO_JPEG -lm -o dcraw.exe

    – Changes made in the source
    #define fgetc getc_unlocked
    #define snprintf _snprintf
    The above lines were commented.. ie. disabled (Thanks for Dave for taking the time out to reply to my queries)

    Also the lines :
    if (multi_out)
    sprintf (ofname+strlen(ofname), „_%0*d“, /*snprintf(0,0,“%d“,*/(is_raw-1)/*)*/, shot_select);

    Are edited to avoid snprintf function. Actually i tried compiling by disabling the complete line and it compiled correctly. I dont know the hazardous effect of this line but i have contacted dave to give some pointers on this. If i get some reply ill update it here.

    Some more info : lcms.h = required header for adding the functionality of Embedding and applying ICC profiles to RAW Images. These may be useful for some people and they can get more info from here :

    According to Dave :
    „Dcraw uses libjpeg only to decode compressed Kodak
    DC120 images…“

    I know most of these options and infos are already known by some or many. But i thought it would be useful for starters like me.

    Thanks to Benni n Dave.
    – mevicks 🙂


    Dezember 3, 2007 at 05:44

  12. Hi Benjamin,

    You’re right with your Options for Dev-CPP but there’s something left to do as follows…

    in Linker Parameter add…

    in Compiler-Parameter add..


    That’s it!
    You get only one warning to „swab“ which is to ignore without problems.

    MinGW has a different declaration of swab than other Compilers and you can fix this too with…

    #ifdef __MINGW32__
    #define swab(s,t,u) swab((const char*)s,(char*)t,(size_t)u)

    But this definition you can’t pass by linker-options in Dev-CPP. It has to be defined later than the include of in source-code to acoid heavy errors at linking time of string.h.

    When you don’t use the LCMS option, you don’t need any additional dll for dcRaw.exe.

    If you want to use LCMS you need to link a „liblcms.dll.a“ in Linker options like the „-lwsock32“ and a „liblcms-1.dll“ in the same folder as dcRaw.exe.
    I think the needed Files are present in the Gimp Project. It’s an older version of lcms. v1.11 instead of actual 1.17. But this one works with Dev-CPP.

    But you have to change „lcms.h“ for MinGW. Add following…

    #ifdef __MINGW32__
    #define unlink remove
    #define LCMSAPI __cdecl
    #define LCMSEXPORT __cdecl
    #define cdecl __cdecl

    MinGW is limited to only support C-type calling convention to external Dll. „__stdcall“ or „__declspec“ calls do not work in MinGW.

    At compiling time there will be errors of redefinition of this defines in an MS-VC section of the code. Comment out this redefinitions for Microsoft-Compilers. Now you can compile without any errors.

    But then dcRAW.exe doesn`t work without the lcms-1.dll in the same directory.
    And for my self I don’t really like the Images when directly applied a profile from lcms.
    I prefer piping the Output of dcraw direct as input to „convert.exe“ from the Imagmagick-Project.

    dcRAW -o 0 -c | convert.exe – -v +gamma 0.45 -intent perceptual -profile %your_icm_file% -gamma 1.86

    Seems to look better for me.

    best regards


    Klaus Homeister

    September 27, 2008 at 15:54

  13. Hi Benjamin!
    Your batch file does not exist any more. Could you please upload it again? Thanks.


    Dezember 28, 2009 at 01:43

  14. I’ll see what I can do when I get home to my parents again


    Dezember 30, 2009 at 20:31

Schreibe eine Antwort zu Benni Antwort abbrechen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )

Google Foto

Du kommentierst mit Deinem Google-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

%d Bloggern gefällt das: