[SOLVED] Liblcf-config "version: unknown" when building from source

I’ve been trying to build easyrpg-player 0.8.1 from source on my Gentoo Linux machine, as per the instructions provided in liblcf’s README.md and easyrpg-player’s BUILDING.md. It’s a simple process, but for some reason, whenever it comes time to run cmake . -DCMAKE_BUILD_TYPE=Release when building the latter, it tells me the liblcf config files for cmake are the wrong version…specifically, that they’re an unknown version, somehow, despite clearly stating in the relevant files that it’s v0.8.1 just like it should be.

Proof from /usr/lib/cmake/liblcf/liblcf-config.cmakethat everything is as it should be:

# For "simplicity" reasons depend on pkg-config when liblcf was compiled with autotools

include(CMakeFindDependencyMacro)

find_dependency(PkgConfig REQUIRED QUIET)

pkg_check_modules(liblcf REQUIRED QUIET IMPORTED_TARGET liblcf=0.8.1)

get_property(library_name TARGET PkgConfig::liblcf PROPERTY INTERFACE_LINK_LIBRARIES)

if (library_name MATCHES ".a$")
       list(REMOVE_ITEM liblcf_STATIC_LIBRARIES lcf)
       set_property(TARGET PkgConfig::liblcf APPEND PROPERTY
               INTERFACE_LINK_LIBRARIES "${liblcf_STATIC_LIBRARIES}")
       set_property(TARGET PkgConfig::liblcf APPEND PROPERTY
               INTERFACE_LINK_DIRECTORIES "${liblcf_STATIC_LIBRARY_DIRS}")
endif()

add_library(liblcf::liblcf ALIAS PkgConfig::liblcf)

And the output of cmake . -DCMAKE_BUILD_TYPE=Release, which claims otherwise:

-- The CXX compiler identification is GNU 15.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SDL2: /usr/lib64/cmake/SDL2 (SDL2::SDL2, v2.32.8)
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:1093 (message):
  The following required packages were not found:

   - liblcf=0.8.1

Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPkgConfig.cmake:1166 (_pkg_check_modules_internal)
  /usr/lib/cmake/liblcf/liblcf-config.cmake:7 (pkg_check_modules)
  builds/cmake/Modules/PlayerFindPackage.cmake:66 (find_package)
  CMakeLists.txt:921 (player_find_package)


CMake Error at builds/cmake/Modules/PlayerFindPackage.cmake:66 (find_package):
  Could not find a configuration file for package "liblcf" that is compatible
  with requested version "0.8.1".

  The following configuration files were considered but not accepted:

    /usr/lib/cmake/liblcf/liblcf-config.cmake, version: unknown
      The version found is not compatible with the version requested.
    /lib/cmake/liblcf/liblcf-config.cmake, version: unknown
      The version found is not compatible with the version requested.

Call Stack (most recent call first):
  CMakeLists.txt:921 (player_find_package)


-- Configuring incomplete, errors occurred!

I’ve deleted and recompiled both liblcf and easyrpg-player multiple times, attempted to fudge the versions in the build files themselves, all to no avail. It seems like it should be a simple error somewhere in something, but I have absolutely no idea where or what it is. Has anyone else had this issue recently?

The error says that pkgconfig cannot find the library.

Can you also share the content of the liblcf.pc pkg-config file? Should be in /lib/pkgconfig

Here is an example how it should look like:

https://ci.easyrpg.org/view/liblcf/job/liblcf-linux/ws/build/lib/pkgconfig/liblcf.pc/*view*/

(Another option is compiling liblcf through CMake which does not depend on pkgconfig though I would be curious to know first why it breaks :thinking:)

Huh, the liblcf.pc file looks fine as well:

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: liblcf
Description: Library to handle RPG Maker 2000 and 2003 game data
Version: 0.8.1
URL: https://easyrpg.org/
Requires.private:  icu-i18n expat >= 2.1 inih
Libs: -L${libdir} -llcf
Cflags: -I${includedir}

I did actually try compiling liblcf with cmake earlier, but it gave me this:

dodec@franklin2 ~/liblcf-0.8.1 $ cmake . -DCMAKE_BUILD_TYPE=Release
-- The CXX compiler identification is GNU 15.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at builds/cmake/Modules/MiscUtils.cmake:11 (message):
  In-source builds are disabled.
Call Stack (most recent call first):
  CMakeLists.txt:7 (include)


-- Configuring incomplete, errors occurred!

(It’s entirely possible that this is due to my own inexperience with cmake, but I…don’t really know where else to build it :downcast_face_with_sweat:)

Strange. What does pkg-config --libs liblcf output? Expected output is -llcf. If this fails it must be a config error on your system (wrong PKG_CONFIG_PATH?). If it returns the correct value I have no idea :confused:


About building with CMake: Ah right. In source builds are discouraged in various projects.

You must use:

cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --target install

Or the preset:

cmake --preset release
cmake --build --preset release --target install

…well, that’s interesting :face_with_raised_eyebrow: At least it’s throwing a different error when I try building with the version compiled with cmake:

dodec@franklin2 ~/easyrpg-player-0.8.1 $ cmake . -DCMAKE_BUILD_TYPE=Release
-- Found SDL2: /usr/lib64/cmake/SDL2 (SDL2::SDL2, v2.32.8)
-- Found inih: /usr/lib64/libinih.so
-- Found ICU: /usr/include (found version "78.2") found components: i18n uc data
CMake Error at builds/cmake/Modules/PlayerFindPackage.cmake:66 (find_package):
  Found package configuration file:

    /usr/local/lib64/cmake/liblcf/liblcf-config.cmake

  but it set liblcf_FOUND to FALSE so package "liblcf" is considered to be
  NOT FOUND.
Call Stack (most recent call first):
  CMakeLists.txt:921 (player_find_package)


-- Configuring incomplete, errors occurred!

It turned out $PKG_CONFIG_PATH was empty so I fixed that, but it’s still giving the same error, even though pkg-config –libs liblcf now returns -L/usr/lib -llcf.

The offending /usr/local/lib64/cmake/liblcf/liblcf-config.cmake:

####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was liblcf-config.cmake.in                            ########

get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

macro(set_and_check _var _file)
  set(${_var} "${_file}")
  if(NOT EXISTS "${_file}")
    message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
  endif()
endmacro()

macro(check_required_components _NAME)
  foreach(comp ${${_NAME}_FIND_COMPONENTS})
    if(NOT ${_NAME}_${comp}_FOUND)
      if(${_NAME}_FIND_REQUIRED_${comp})
        set(${_NAME}_FOUND FALSE)
      endif()
    endif()
  endforeach()
endmacro()

####################################################################################

include(CMakeFindDependencyMacro)

# Required to find our installed Findinih.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

if(1)
        find_dependency(inih REQUIRED)
endif()

if(1 EQUAL 1)
        find_dependency(ICU COMPONENTS i18n uc data REQUIRED)
endif()

if(1 EQUAL 1)
        find_dependency(expat CONFIG REQUIRED)
elseif(1 EQUAL 2)
        # Fallback to old expat detection
        find_dependency(EXPAT REQUIRED)
endif()

## Create aliases for common expat target names
# The config file creates expat::expat
if (TARGET expat::expat AND NOT TARGET EXPAT::EXPAT)
        add_library(EXPAT::EXPAT ALIAS expat::expat)
endif()

# The find module creates EXPAT::EXPAT
if (TARGET EXPAT::EXPAT AND NOT TARGET expat::expat)
        add_library(expat::expat ALIAS EXPAT::EXPAT)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/liblcf-targets.cmake)

You are really the first one who ever had these problems. Is Gentoo so different to other systems? :sweat_smile:

Can you create a trace file and upload it? This file basically contains which code was executed by CMake. So I can compare it to a working run.

cmake . -DCMAKE_BUILD_TYPE=Release --fresh --trace-expand 2> trace.txt

Output is very verbose. Will be redirected to trace.txt. Please zip the file and attach it.

Apparently someone did once make a Gentoo ebuild to make it all work…back in 0.6.0 :upside_down_face:

trace.txt (2.9 MB)

I think it worked?

The trace contains

PlayerFindPackage.cmake(74): message(STATUS Found liblcf: /usr/local/lib64/cmake/liblcf (liblcf::liblcf, v0.8.1) )

Maybe there was some stale data left? Always delete the CMakeCache.txt or use --fresh when reconfiguring.

It…looks like it did, huh, I was able to run a game just fine after all that. Now I have to wonder whether it was compiling liblcf with cmake or fixing $PKG_CONFIG_PATH was what did it :thinking: Marking this as solved, somehow…

The PKG_CONFIG_PATH stuff is only used when you build liblcf with autotools.

So if you really want to retest this you have to delete liblcf again and rebuild with configure xD

(but honestly autotools is only on life support. Nobody wants to touch this anymore)