I have never dealed with C or C++ before, so please be gentile with me :) I want to use this C Code from this Repo as a Node Module:
https://github.com/torvalds/pesconvert
I read that this can be done with Node.Js Native Addons, but all Examples I could find were about integrating C++ Code.
I have installed node-gyp and windows-build-tools for compiling the code, but because I am using windows, the required png.h library isn't installed natively. I downloaded libpng V1.6.37 and copied it into my project in the directory lib/lpng1637
.
Now I have to write the binding.gyp file but I can't figure out how to write it so that the library is included correctly.
'targets': [
{
'target_name': 'pesconvert',
'sources': [ 'pes.c',
'png.c',
'svg.c',
'main.c',
'cairo.c',
'pes.h'
],
'include_dirs' : ['lib/lpng1637'],
'dependencies' : ['libpng'],
'libraries': ['-L/lib/lpng1637/libpng.a']
},
{
'target_name': 'libpng',
'type': 'static_library',
'sources': [ 'png.h', 'pngconf.h', 'pngdebug.h', 'pnginfo.h', 'pngpriv.h', 'pngstruct.h', 'example.h', 'png.c', 'pngerror.c', 'pngget.c',
'pngmem.c', 'pngpread.c', 'pngread.c', 'pngrio.c', 'pngrtran.c', 'pngrutil.c', 'pngset.c', 'pngtest.c', 'pngtrans.c', 'pngwio.c', 'pngwrite.c',
'pngwtran.c', 'pngwutil.c'
],
'include_dirs' : ['lib/lpng1637']
}
]
}
I tried so many variations and this is my latest masterpeace... :D I read that the reference in 'libraries' has to point to an .a file in case of a static library, but there isn't even an .a file in the directory. So my key-question is: What do I have to write in my binding.gyp file to refer to the libpng-Library correctly?
I would be happy about every kind of hint or additional information!