melchor629 / node-flac-bindings

Nodejs bindings to libFLAC
ISC License
17 stars 1 forks source link

Windows build errors #4

Closed dmooney65 closed 6 years ago

dmooney65 commented 6 years ago

Hi,

Have the library running well on Linux but am having issues building for Windows. I have cloned and successfully built flac libs from https://github.com/xiph/flac and can compile the "other" node-flac binding module successfully on Windows so am confident everything is available.

The compile works without including any external headers in the project but then fails at the linking stage. If I add the include headers to the project then the compile fails.

Does this project expect any locations or names for DLLs libs etc?

melchor629 commented 6 years ago

Hi. Good to know that you are trying to get this library working on Windows. I didn't try anything on Windows so probably the DLL loading is not working because is not coded for windows yet. Sorry for that. I will try to test some stuff as soon as I can.

You said that you modified my code to allow the compilation on Windows. So, could you send me a pull request with the code so I could test on Windows?

Thanks for filling the issue.

dmooney65 commented 6 years ago

I've tried a few things out but haven't had any luck. When I run "npm install" without any mods it fails:



> flac-bindings@1.2.1 install C:\Users\domin\source\repos\node-flac-bindings
> prebuild-install || node-gyp rebuild

prebuild-install info begin Prebuild-install version 2.3.0
prebuild-install info install installing standalone, skipping download.

C:\Users\domin\source\repos\node-flac-bindings>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_mo
dules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  index.cpp
  encoder.cpp
  decoder.cpp
  format.cpp
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\decoder.cpp) [C:\Users\domin\source\rep
os\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\decoder.cpp(77): note: see reference to function template instantiation 'v8::Local<v8::Number> Nan::New<v8::Nu
  mber,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\encoder.cpp) [C:\Users\domin\source\rep
os\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\encoder.cpp(82): note: see reference to function template instantiation 'v8::Local<v8::Number> Nan::New<v8::Nu
  mber,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
  metadata0.cpp
  metadata1.cpp
  metadata2.cpp
  metadata.cpp
  frame.cpp
  streammetadata.cpp
  streammetadata_application.cpp
  streammetadata_cuesheet.cpp
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\mappings\frame.cpp) [C:\Users\domin\sou
rce\repos\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\mappings\frame.cpp(21): note: see reference to function template instantiation 'v8::Local<v8::Number> Nan::New
  <v8::Number,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\mappings\streammetadata_cuesheet.cpp) [
C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\mappings\streammetadata_cuesheet.cpp(27): note: see reference to function template instantiation 'v8::Local<v8
  ::Number> Nan::New<v8::Number,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
  streammetadata_padding.cpp
  streammetadata_picture.cpp
  streammetadata_seektable.cpp
  streammetadata_streaminfo.cpp
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\mappings\streammetadata_streaminfo.cpp)
 [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\mappings\streammetadata_streaminfo.cpp(112): note: see reference to function template instantiation 'v8::Local
  <v8::Number> Nan::New<v8::Number,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
  streammetadata_unknown.cpp
  streammetadata_vorbiscomment.cpp
  streammetadata_seekpoint.cpp
  streammetadata_cuesheet_track.cpp
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\mappings\streammetadata_seekpoint.cpp)
[C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\mappings\streammetadata_seekpoint.cpp(7): note: see reference to function template instantiation 'v8::Local<v8
  ::Number> Nan::New<v8::Number,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\mappings\streammetadata_cuesheet_track.
cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\mappings\streammetadata_cuesheet_track.cpp(7): note: see reference to function template instantiation 'v8::Loc
  al<v8::Number> Nan::New<v8::Number,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
  streammetadata_cuesheet_index.cpp
  win_delay_load_hook.cc
c:\users\domin\source\repos\node-flac-bindings\node_modules\nan\nan_new.h(208): warning C4244: 'argument': conversion f
rom 'uint64_t' to 'double', possible loss of data (compiling source file ..\src\mappings\streammetadata_cuesheet_index.
cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
  ..\src\mappings\streammetadata_cuesheet_index.cpp(7): note: see reference to function template instantiation 'v8::Loc
  al<v8::Number> Nan::New<v8::Number,uint64_t>(A0)' being compiled
          with
          [
              A0=uint64_t
          ]
     Creating library C:\Users\domin\source\repos\node-flac-bindings\build\Release\flac-bindings.lib and object C:\User
  s\domin\source\repos\node-flac-bindings\build\Release\flac-bindings.exp
format.obj : error LNK2001: unresolved external symbol "void __cdecl flac_bindings::structToJs<struct FLAC__StreamMetad
ata_SeekTable *>(struct FLAC__StreamMetadata_SeekTable * const *,class v8::Local<class v8::Object> &)" (??$structToJs@P
EAUFLAC__StreamMetadata_SeekTable@@@flac_bindings@@YAXPEBQEAUFLAC__StreamMetadata_SeekTable@@AEAV?$Local@VObject@v8@@@v
8@@@Z) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
metadata0.obj : error LNK2001: unresolved external symbol "void __cdecl flac_bindings::structToJs<struct FLAC__StreamMe
tadata *>(struct FLAC__StreamMetadata * const *,class v8::Local<class v8::Object> &)" (??$structToJs@PEAUFLAC__StreamMe
tadata@@@flac_bindings@@YAXPEBQEAUFLAC__StreamMetadata@@AEAV?$Local@VObject@v8@@@v8@@@Z) [C:\Users\domin\source\repos\n
ode-flac-bindings\build\flac-bindings.vcxproj]
C:\Users\domin\source\repos\node-flac-bindings\build\Release\flac-bindings.node : fatal error LNK1120: 2 unresolved ext
ernals [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1```
dmooney65 commented 6 years ago

The mods I made were:

  1. Hack in FLAC include files by copying them to FLAC subdir in top level and modifying binding.gyp
"include_dirs": [
            "<!(node -e \"require('nan')\")","./FLAC/"
        ],

This blows up badly - here's a tiny snippet:

PS C:\Users\domin\source\repos\node-flac-bindings> npm install

> flac-bindings@1.2.1 install C:\Users\domin\source\repos\node-flac-bindings
> prebuild-install || node-gyp rebuild

prebuild-install info begin Prebuild-install version 2.3.0
prebuild-install info install installing standalone, skipping download.

C:\Users\domin\source\repos\node-flac-bindings>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_mo
dules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  index.cpp
  encoder.cpp
  decoder.cpp
  format.cpp
C:\Users\domin\.node-gyp\6.11.4\include\node\node.h(322): error C3861: 'assert': identifier not found (compiling source
 file ..\src\index.cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
C:\Users\domin\.node-gyp\6.11.4\include\node\node.h(322): error C3861: 'assert': identifier not found (compiling source
 file ..\src\encoder.cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
C:\Users\domin\.node-gyp\6.11.4\include\node\node_object_wrap.h(20): error C3861: 'assert': identifier not found (compi
ling source file ..\src\index.cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
C:\Users\domin\.node-gyp\6.11.4\include\node\node_object_wrap.h(20): error C3861: 'assert': identifier not found (compi
ling source file ..\src\encoder.cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
C:\Users\domin\.node-gyp\6.11.4\include\node\node_object_wrap.h(55): error C3861: 'assert': identifier not found (compi
ling source file ..\src\index.cpp) [C:\Users\domin\source\repos\node-flac-bindings\build\flac-bindings.vcxproj]
dmooney65 commented 6 years ago
  1. Attempt to point to libFLAC_dynamic.lib to cure the linking error by adding "libraries": ["../libs/libFLAC_dynamic.lib",], into binding.gyp after copying files. Made no difference.
melchor629 commented 6 years ago

Hi, I'm trying to fix the errors right now. I managed to fix the compilation errors when using npm install (without any modifications of the binding.gyp) that's good for me :)

I will keep trying to fix the errors on Windows.

One thing that I didn't tell you is that the bindings doesn't require to have installed the FLAC headers anywhere. But to make it work, the FLAC library (.dll) needs to be available in the PATH variable or manually tell my library where to find it. That last is what I'm testing now.

Edit: It is also available to use FLAC_LIBRARY env variable to tell where is the library.

dmooney65 commented 6 years ago

OK so no need for header files - that is good news. Providing the .dll won't be a problem.

Thanks a lot and good luck with the fixes.

dmooney65 commented 6 years ago

Oops cloded in error! So no need for flac headers - good news.

Thanks a lot!

melchor629 commented 6 years ago

Reopening, until it's all tested and fixed :)

melchor629 commented 6 years ago

https://github.com/melchor629/node-flac-bindings/commit/76c34673325fcbecb97bed1886cebb15f29c0c00 That commit fixed the compilation errors.

I uploaded a new version of the package, try with that new version and tell me if it's all OK.

dmooney65 commented 6 years ago

Superb - have tested FileEncoder and StreamEncoder and both are working perfectly. I just had to put FLAC.dll in the app root dir and all worked.

Thanks a lot

melchor629 commented 6 years ago

Good to know then :)

Issue fixed, so I'm closing it.