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

Needs libs not available on Ubuntu 20.04 LTS. #3

Open
John-Nagle opened this issue Oct 19, 2021 · 7 comments
Open

Needs libs not available on Ubuntu 20.04 LTS. #3

John-Nagle opened this issue Oct 19, 2021 · 7 comments

Comments

@John-Nagle
Copy link

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:

$ cargo build
   Compiling grokj2k-sys v0.1.1 (/home/john/projects/grokj2k-sys)
error: failed to run custom build command for `grokj2k-sys v0.1.1 (/home/john/projects/grokj2k-sys)`

Caused by:
  process didn't exit successfully: `/home/john/projects/grokj2k-sys/target/debug/build/grokj2k-sys-a29702fdcb26639c/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBGROKJ2K_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBGROKJ2K_STATIC
  cargo:rerun-if-env-changed=LIBGROKJ2K_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libgrokj2k\" \"libgrokj2k >= 9.2.0\"", output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "Package libgrokj2k was not found in the pkg-config search path.\nPerhaps you should add the directory containing `libgrokj2k.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'libgrokj2k' found\nPackage libgrokj2k was not found in the pkg-config search path.\nPerhaps you should add the directory containing `libgrokj2k.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'libgrokj2k' found\n" } }', build.rs:8:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Trying the obvious:

$ sudo apt-get install  libgrokj2k
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libgrokj2k
$ sudo apt-get install  libgrokj2k-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libgrokj2k-dev
@John-Nagle
Copy link
Author

Underlying problem is due to a change in GCC:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984111

@tkenda
Copy link

tkenda commented Nov 7, 2021

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.

@John-Nagle
Copy link
Author

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.

@tkenda
Copy link

tkenda commented Nov 7, 2021

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.

@John-Nagle
Copy link
Author

Good. Thanks very much.

@tkenda
Copy link

tkenda commented Nov 8, 2021

There is no plan to make a libgrokj2k for 20.04 LTS.

Ubuntu support chat: https://answers.launchpad.net/ubuntu/+source/libgrokj2k/+question/699388

@John-Nagle
Copy link
Author

John-Nagle commented Aug 16, 2022

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?

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