cburstedde / p4est

The "p4est" forest-of-octrees library

Home Page:www.p4est.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fail without jansson

mkirilin opened this issue · comments

Description
Build with cmkae fails on a system without jansson library.

To Reproduce

  1. p4est repository is on 2e44 commit. sc repository is on 83bd.
  2. Configure and build sc in debug mode and with mpi.
  3. Configure and build p4est in debug and with mpi.

p4est configure output: -- Could NOT find jansson (missing: jansson_DIR)
p4est build output:

/opt/software/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: ../local/lib/libsc.a(sc_options.c.o): in function `sc_options_json_lookup':
sc_options.c:(.text+0x95): undefined reference to `json_object_get'
/opt/software/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: sc_options.c:(.text+0x105): undefined reference to `json_object_get'

etc...

Hi @mkirilin

Could you provide the full commit hash (at least first 7 characters) because I was not able to identify 2e44 in p4est repository, while I found 83bd019 in libsc (current master) ?

I tried to build both current p4est develop branch and master branch on a system where libjansson is not available; I didn't encounter any problem, it builds fine.

Hi @pkestene

the relevant commit is on eb24772.
Some more details: compiler version is GCC 11.3.0. CMake version is 3.23.1 compiled with GCC 11.3.0.

@mkirilin
Please re-check on your side.

eb24772 is current master of p4est.
This commit builds fine for me.

Make sure that libsc submodule is up-to-date inside your p4est clone (it should be on master too).

@pkestene
I double checked current commit states: both p4est and sc are on master.

The problem appears when jansson is not found via find_package() but is found via PkgConfig:

-- Could NOT find jansson (missing: jansson_DIR)
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- jansson library found via pkg-config

@mkirilin

Ok. I understand now and I can reproduce. This is a bug.
I'll push a fix shortly.

there are actually two bugs (not directly related):

  1. at p4est level, linking to lib jansson is enabled when SC_HAVE_JSON is true, but here SC_HAVE_JSON was not defined even though cmake/jansson.cmake was included
  2. when using an installed version of libsc, installed SC-targets.cmake is referencing library PkgConfig::LIBSC_JANSSON instead of jansson::jansson (as it is the case when jansson is detected via find_package. This will be fixed in libsc

@pkestene
With p4est HEAD on 31aeaf2 and libsc on both cburstedde/libsc@f622a4c and cburstedde/libsc@116a91b the problem persists.

@mkirilin I'm really sorry for the trouble
I made a silly copy paste error while working on a working branch; thanks for being persevering

https://github.com/cburstedde/p4est/blob/develop/cmake/jansson.cmake#L24 and https://github.com/cburstedde/p4est/blob/develop/cmake/jansson.cmake#L25 should use prefix P4EST and not LIBSC

@cburstedde would you prefer cancelling PR #229 and re-open a new PR (I've updated my fork with the new fix), or consider an additional PR ? sorry about that silly mistake.

No worries @pkestener, thanks for your contributions! We have already merged PR #229. You may start a new PR no problem.

@pkestene With p4est HEAD on 31aeaf2 and libsc on both cburstedde/libsc@f622a4c and cburstedde/libsc@116a91b the problem persists.

Thanks for double-checking!

Thanks for the fix. It builds well now on my machine.