1

我正在尝试将 libraw 编译为我的 node.js 项目的依赖项。

我有两个不同的 .gyp 文件:./binding.gyp./vendor/raw.gyp

我已经下载了当前版本的 libraw 和去马赛克包,它们都可以在以下./vendor/文件夹中找到:

LibRaw-0.17.1
LibRaw-demosaic-pack-GPL2-0.17.1
LibRaw-demosaic-pack-GPL3-0.17.1

这是我的两个 gyp 文件:

./binding.gyp

{
  "includes": [ "vendor/raw.gyp" ],
  "targets": [
    {
      "target_name": "node_libraw",
      "sources": [ "node_libraw.cc" ],
      "include_dirs" : [
        "build/Release",
        "vendor/LibRaw-0.17.1",
        "<!(node -e \"require('nan')\")"
      ],
      "libraries": [
        "-lraw",
        "-Wl,-rpath=./build/Release/obj.target/"
      ]
    }
  ],
}

./vendor/raw.gyp

{
  "targets": [
    {
      "default_configuration": "Release",
      "target_name": "raw",
      "type": "static_library",
      "sources": [
        "LibRaw-0.17.1/internal/dcraw_common.cpp",
        "LibRaw-0.17.1/internal/dcraw_fileio.cpp",
        "LibRaw-0.17.1/internal/demosaic_packs.cpp",
        "LibRaw-0.17.1/src/libraw_cxx.cpp",
        "LibRaw-0.17.1/src/libraw_datastream.cpp",
        "LibRaw-0.17.1/src/libraw_c_api.cpp"
      ],
      "include_dirs": [ 
        "./LibRaw-demosaic-pack-GPL2-0.17.1",
        "./LibRaw-demosaic-pack-GPL3-0.17.1",
        "./LibRaw-0.17.1"
      ],
      "libraries": [
        "-ljpeg8"
      ],
      "cflags": [ 
        "-Wdeprecated-declarations",
        "-pthread -w"
      ],
      "cflags_cc": [
        "-pthread -w",
        "-fexceptions",
        "-I./LibRaw-demosaic-pack-GPL2-0.17.1",
        "-DLIBRAW_DEMOSAIC_PACK_GPL2",
        "-I./LibRaw-demosaic-pack-GPL3-0.17.1",
        "-DLIBRAW_DEMOSAIC_PACK_GPL3",
        "-DUSE_JPEG8"
      ]
    }
  ]
}

问题是,当我尝试编译库时,node-gyp configure build最终出现以下错误:

/usr/bin/ld: cannot find -lraw
collect2: error: ld returned 1 exit status
node_libraw.target.mk:124: recipe for target 'Release/obj.target/node_libraw.node' failed

这是完整的输出:

$ node-gyp configure build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.0.3
gyp info using node@4.2.4 | linux | x64
gyp info spawn python2
gyp info spawn args [ '/usr/share/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/node-libraw/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/share/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/nodejs/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args   '-Dnode_gyp_dir=/usr/share/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/node-libraw',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/node-libraw/build'
CXX(target) Release/obj.target/node_libraw/node_libraw.o
In file included from ../vendor/LibRaw-0.17.1/libraw/libraw.h:40:0,
from ../node_libraw.cc:6:
../vendor/LibRaw-0.17.1/libraw/libraw_datastream.h:96:10: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
std::auto_ptr<std::streambuf> f; /* will close() automatically through dtor */
^
In file included from /usr/include/c++/5/memory:81:0,
from ../vendor/LibRaw-0.17.1/libraw/libraw_datastream.h:38,
from ../vendor/LibRaw-0.17.1/libraw/libraw.h:40,
from ../node_libraw.cc:6:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
template<typename> class auto_ptr;
^
In file included from ../vendor/LibRaw-0.17.1/libraw/libraw.h:40:0,
from ../node_libraw.cc:6:
../vendor/LibRaw-0.17.1/libraw/libraw_datastream.h:97:10: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
std::auto_ptr<std::streambuf> saved_f; /* when *f is a subfile, *saved_f is the
^
In file included from /usr/include/c++/5/memory:81:0,
from ../vendor/LibRaw-0.17.1/libraw/libraw_datastream.h:38,
from ../vendor/LibRaw-0.17.1/libraw/libraw.h:40,
from ../node_libraw.cc:6:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
template<typename> class auto_ptr;
^
SOLINK_MODULE(target) Release/obj.target/node_libraw.node
/usr/bin/ld: cannot find -lraw
collect2: error: ld returned 1 exit status
node_libraw.target.mk:124: recipe for target 'Release/obj.target/node_libraw.node' failed
make: *** [Release/obj.target/node_libraw.node] Error 1
make: Leaving directory '/node-libraw/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.3.0-6-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /node-libraw
gyp ERR! node -v v4.2.4
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok

以及项目的网址:https ://github.com/m0g/node-libraw/tree/batteries

谢谢

4

0 回答 0