Open John-Nagle opened 2 years ago
Underlying problem is due to a change in GCC:
Hi,
I installed it manually following INSTALL guide:
$ git clone https://github.com/GrokImageCompression/grok.git $ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_THIRDPARTY:BOOL=ON . $ sudo make install $ sudo ldconfig
For the GCC issue use https://ducciogasparri.it/2020/07/30/installing-c17-and-c20-on-ubuntu-and-amazon-linux/ steps.
use grokj2k_sys::*;
use std::convert::TryInto;
use std::ffi::{CString, CStr};
use std::mem;
use std::os::raw::c_char;
pub mod errors;
use errors::GrokError;
// Bisect with only feasible truncation points
const GRK_RATE_CONTROL_PCRD_OPT: u32 = 1;
fn str_to_slice(src: &str) -> Result<[c_char; 4096], GrokError> {
let inn: Vec<c_char> = match CString::new(src) {
Ok(t) => t
.into_bytes_with_nul()
.into_iter()
.map(|x| x as c_char)
.collect(),
Err(err) => return Err(GrokError::NullError(err)),
};
let mut out = vec![Default::default(); 4096];
out[..inn.len()].clone_from_slice(&inn);
match out.try_into() {
Ok(t) => Ok(t),
Err(err) => Err(GrokError::TryInto(err)),
}
}
/// Remove all from memory
fn cleanup(grk_cparameters: *mut _grk_cparameters) {
unsafe {
grk_deinitialize();
libc::free(grk_cparameters as *mut libc::c_void);
}
}
fn lib() -> Result<(), GrokError> {
let infile = str_to_slice("infile.raw")?;
let outfile = str_to_slice("outfile.j2k")?;
unsafe {
// Version
let version = CStr::from_ptr(grk_version());
println!("Grok {}", version.to_str().unwrap());
// Allocate Grok compress parameters
let grk_cparameters: *mut _grk_cparameters =
libc::malloc(mem::size_of::<_grk_cparameters>()) as *mut _grk_cparameters;
// Set compressing parameters to default values
grk_compress_set_default_params(grk_cparameters);
(*grk_cparameters).mct = 255;
(*grk_cparameters).rateControlAlgorithm = GRK_RATE_CONTROL_PCRD_OPT;
(*grk_cparameters).verbose = true;
// Setup
(*grk_cparameters).decod_format = GRK_RAWL_FMT;
(*grk_cparameters).infile = infile;
(*grk_cparameters).cod_format = GRK_J2K_FMT;
(*grk_cparameters).outfile = outfile;
// load plugin but do not actually create codec
if !grk_initialize(0 as *const c_char, (*grk_cparameters).numThreads) {
cleanup(grk_cparameters);
return Err(GrokError::Initialize);
}
//.... REST OF CODE IN PROGRESS, NEED TO FIX GRK_INITIALIZE
cleanup(grk_cparameters);
}
Ok(())
}
fn main() {
if let Err(err) = lib() {
println!("{}", err);
}
}
I can display Grok version correctly, the library is working but I cannot make it initialize. There is an example? I try to copy the compress library, but something is missing..
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running target/debug/grok
Grok 9.5.0
Error initializing Grok library.
I know that i can install it manually. But that doesn't make it useful in something that is built by others from Rust using Cargo.
When will it be a standard Ubuntu package again.
I just asked in the Ubuntu libgrokj2k packages site, if they are planning to make it available again with 20.04 LTS. I will keep you informed.
Good. Thanks very much.
There is no plan to make a libgrokj2k for 20.04 LTS.
Ubuntu support chat: https://answers.launchpad.net/ubuntu/+source/libgrokj2k/+question/699388
After the comment back in 2021 that it was not going to be made compatible with 20.04 LTS, I waited for 22.04 LTS. It doesn't work there, either, but for a different reason. Apparently it did work, briefly, in some Ubuntu 21.xx versions, but never in an LTS version.
The underlying problem is documented here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015014 Apparently a dependency on Google's "Highway" vector math package is causing problems on some less-supported platforms.
Highway has reached version 1.0 and Google's comments in the repository indicate willingness to make this work on more platforms if needed, since Google wants to make this a de-facto standard. They even cite it working with GrokJ2K.
So, what can be done to get this package working again?
Build failed. Needs a "grok" package that Ubuntu 20.04 LTS does not have. A build bug caused Debian to drop the Grok library from testing last August.
So, now there's a dependency problem. Who fixes this?
Rust build failure:
Trying the obvious: