Comments (7)
I've pushed my currently working one to https://github.com/mnightingale/go-yencode
The main things I needed were set(CMAKE_MACOSX_RPATH OFF)
because otherwise on Mac the install_path was being prefixed with @rpath/
and Go and then couldn't find it.
Then as with the plain Makefile I'm making a shared library and just giving it all the sources.
At some point I want to see how I can make it work for multiple platforms, I'm not sure how at this stage.
Go will find all the .syso files and I believe use their name to determine which to load, so I can have avx2_amd64.syso, avx2_386.syso, avx2_arm.syso, etc.
I haven't tried it yet but I thought maybe I could split it and produce yencoder_avx2_arm.syso etc. with just the encoder/decoder, if that won't work I could just make a single shared library for each platform with all the sources, yencode_amd64.syso, yencode_arm.syso, etc. - I think this is probably simpler.
I haven't had chance to see how fast it is yet but I'm expecting great things!
from node-yencode.
For your build, maybe the dependent objects aren't being included in your library. I don't believe a static library actually does any linking - it just packages up the object files into an archive, so the target_link_libraries
directive might not be doing much.
You can use ar -t [library file]
command to list the contents of your .syso file - it should contain all the compiled objects (a .o file for every .cc file compiled), otherwise you'll be missing symbols during link.
The source files are separated with different options to cater for running a single binary on a variety of systems. If you're just testing and don't need to distribute the compiled binary, it'll be easier to just throw all the source files together with -march=native
compile flag, and forget the other -m*
flags.
If you do want to build a distributable binary, perhaps include all the source files in a single library, but change the compile options for the files specifically (try set_source_files_properties([file] PROPERTIES COMPILE_FLAGS [flags])
).
I'm not sure how Go does it's linking with a static library, but an alternative to having it all in one library, might be to have multiple (like you have now), but explicitly link the Go code to all of them.
do_decode
was meant to be called from C/C++, as it's a simple inlined wrapper around a function pointer. For a library, you'd need to make a small exported function which calls do_decode
.
Enums are effectively labelled numbers, so you can typecast YencDecoderState to/from an int.
I had thought about making a C library out of this at some point, but never got around to it. Maybe it's time...
from node-yencode.
Thanks so much, your comments pointed me in the right direction.
It seems my biggest issue apart from as you suggested that I should be making a shared library was even the times I had CMake setup nearly correctly it was failing to link or compile.
I think it was using gcc instead of g++ or equivalent, I was getting errors like:
Undefined symbols for architecture x86_64:
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for crcutil_interface::CRC in interface.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__si_class_type_info", referenced from:
typeinfo for crcutil_interface::Implementation<crcutil::GenericCrc<crcutil::uint128_sse2, crcutil::uint128_sse2, unsigned long, 4>, crcutil::RollingCrc<crcutil::GenericCrc<crcutil::uint128_sse2, crcutil::uint128_sse2, unsigned long, 4> > > in interface.o
...
For now as suggested I've gone back to basics, made a Makefile in the yencode directory and called g++
with -march=native
and a few of the cflags, added a small wrapper to simplify init and I think so that do_decode is exported and it works!
Result length: 128
Decoded: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Have you any idea what I'd need to make CMake work?
I would like to be able to create distributable package eventually, so instead of a single package ideally I'd create libyencode_sse2_amd64.syso, etc. and it should load them as needed.
from node-yencode.
I've figured out getting cmake to generate a working -march=native library which is good enough for now.
from node-yencode.
Glad you got it working!
Have you any idea what I'd need to make CMake work?
I'll look at writing one up.
from node-yencode.
I knocked together a quick C library: https://github.com/animetosho/rapidyenc
Hopefully the CMake configuration there might be of some help.
from node-yencode.
That's great thanks!
from node-yencode.
Related Issues (12)
- Please Create CRC checksum's HOT 2
- CLI options? HOT 3
- Python bindings HOT 25
- Clarification on `column_offset` parameter for `encode` and `encodeTo` HOT 2
- Critical characters not escaped when they are the last character of the segment HOT 1
- yEnc SSE decode ideas HOT 54
- Build fails with node.js 12.7.0 HOT 3
- Unable to build or install HOT 2
- Errors trying to install yencode HOT 1
- macOS: llvm: yencode 1.1.0: build error: use of undeclared identifier 'aligned_alloc' HOT 5
- Trying to install yencode: "npm WARN saveError ENOENT: no such file or directory, open '/home/sander/package.json'" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-yencode.