Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to build lzma as a static library #101

Open
baparham opened this issue Jan 28, 2021 · 5 comments
Open

Question: How to build lzma as a static library #101

baparham opened this issue Jan 28, 2021 · 5 comments

Comments

@baparham
Copy link

Do you have any documentation or advice on how I might rebuild lzma-native with node-gyp but as a static library?

It seems to me, at some basic digging, that I'd need to update "libraries: ['-llzma'] in the binding.gyp file to point to a full path to the lzma.a library, but I am having trouble determining where that might be.

Thanks for the help!

@baparham
Copy link
Author

I may have jumped the gun, for some reason I didn't see the <(module_root_dir)/build/liblzma/build/lib/liblzma.a up in the lines above. However, I think that's not my problem, since running ldd lzma-native.node points to a few other libs that it must dynamically load, like libc and libstdc++. those are the libs I'm trying to link in statically I suppose.

@baparham
Copy link
Author

I attempted to set "type": "static_library", in the lzma_native target section of binding.gyp, but this then resulted in another error:

  TOUCH Release/obj.target/liblzma.stamp
  CXX(target) Release/obj.target/lzma_native/src/util.o
  CXX(target) Release/obj.target/lzma_native/src/liblzma-functions.o
  CXX(target) Release/obj.target/lzma_native/src/filter-array.o
  CXX(target) Release/obj.target/lzma_native/src/lzma-stream.o
  CXX(target) Release/obj.target/lzma_native/src/module.o
  CXX(target) Release/obj.target/lzma_native/src/mt-options.o
  CXX(target) Release/obj.target/lzma_native/src/index-parser.o
../src/index-parser.cpp: In function 'lzma_ret lzma::my_lzma_parse_indexes_from_file(lzma::lzma_index_parser_data*)':
../src/index-parser.cpp:106:11: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
  lzma_ret ret;
           ^~~

I suspect this should be the right way to have node-gype build the library statically, but the compilation warning is a blocker. I'll continue debugging.

@addaleax
Copy link
Owner

@baparham Can I ask why the compilation warning is a blocker? In any case, if it is, then I’m not sure how to help with that particular problem (the code in question was lifted from the libzma library itself)

@baparham
Copy link
Author

It seems to stop node-gyp from compiling. If I initialize lzma_ret = LZMA_OK on the failing line and then node gyp seems to get past that part and fails for another reason, i believe that there was no make target for Release/lzma_native.node (of the top of my head)

I've began to explore other ways of meeting my requirements without a statically compiled lzma, but I think this still would be nice to get figured out.

@addaleax
Copy link
Owner

@baparham Yeah, it’s a warning, not an error, it shouldn’t affect the compilation process.

If you can give me exact steps to reproduce what you’re running into, I’m happy to help, but I don’t think the information here is actionable right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants