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

libjxl: find_library imports unusable library with x64-windows-static triplet #34330

Closed
HappySeaFox opened this issue Oct 7, 2023 · 7 comments
Assignees
Labels
depends:upstream-changes Waiting on a change to the upstream project Stale

Comments

@HappySeaFox
Copy link
Contributor

Describe the bug

Install libjxl with x64-windows-static triplet:

vcpkg install libjxl --triplet x64-windows-static

Client application:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)

project(libjxl-test)

add_executable(libjxl-test main.c)

find_library(JXL_LIBRARY NAMES jxl jxl-static REQUIRED)
find_path(JXL_INCLUDE_DIRS jxl/decode.h REQUIRED)

target_include_directories(libjxl-test PRIVATE ${JXL_INCLUDE_DIRS})
target_link_libraries(libjxl-test PRIVATE ${JXL_LIBRARY})

main.c:

#include <jxl/decode.h>

int main(int argc, char *argv[])
{
    JxlDecoder *decoder = JxlDecoderCreate(NULL);

    return 0;
}

Environment

  • OS: Windows 7 x64
  • Compiler: MSVC 2019

Result:

main.obj : error LNK2019: ссылка на неразрешенный внешний символ __imp_JxlDecoderCreate в функции main.
[F:\projects\git.libjxl.vcpkg-test\build\libjxl-test.vcxproj]
F:\projects\git.libjxl.vcpkg-test\build\Release\libjxl-test.exe : fatal error LNK1120: неразрешенных вне
шних элементов: 1 [F:\projects\git.libjxl.vcpkg-test\build\libjxl-test.vcxproj]

LNK2019 = unresolved external symbol

Compilation Log Microsoft (R) Build Engine версии 16.11.2+f32259642 для .NET Framework (C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.

Поиск библиотек
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\kernel32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\user32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\gdi32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\winspool.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\shell32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\ole32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\oleaut32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\comdlg32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\advapi32.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\OLDNAMES.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\vcruntime.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64\ucrt.lib:
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\kernel32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\user32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\gdi32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\winspool.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\shell32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\ole32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\oleaut32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\comdlg32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\advapi32.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\OLDNAMES.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\vcruntime.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64\ucrt.lib:
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:

Поиск библиотек завершен

Поиск библиотек
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\kernel32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\user32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\gdi32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\winspool.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\shell32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\ole32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\oleaut32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\comdlg32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\advapi32.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\OLDNAMES.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\vcruntime.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64\ucrt.lib:

Поиск библиотек завершен

Поиск библиотек
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\kernel32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\user32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\gdi32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\winspool.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\shell32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\ole32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\oleaut32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\comdlg32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\advapi32.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\OLDNAMES.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\vcruntime.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64\ucrt.lib:

Поиск библиотек завершен

Поиск библиотек
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\kernel32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\user32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\gdi32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\winspool.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\shell32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\ole32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\oleaut32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\comdlg32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\advapi32.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\OLDNAMES.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\vcruntime.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64\ucrt.lib:

Поиск библиотек завершен

Поиск библиотек
Поиск F:\projects\git.vcpkg\installed\x64-windows-static\lib\jxl-static.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\kernel32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\user32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\gdi32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\winspool.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\shell32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\ole32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\oleaut32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\uuid.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\comdlg32.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64\advapi32.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\MSVCRT.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\OLDNAMES.lib:
Поиск C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64\vcruntime.lib:
Поиск C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64\ucrt.lib:

Поиск библиотек завершен
main.obj : error LNK2019: ссылка на неразрешенный внешний символ __imp_JxlDecoderCreate в функции main. [F:\projects\git.libjxl.vcpkg-test\build\libjxl-test.vcxproj]
F:\projects\git.libjxl.vcpkg-test\build\Release\libjxl-test.exe : fatal error LNK1120: неразрешенных внешних элементов: 1 [F:\projects\git.libjxl.vcpkg-test\build\libjxl-test.vcxproj]

Pkg-config notice

There are pkg-config files for libjxl, but I don't use pkg-config and have no plans to use it for technical reasons.

Question

Am I missing something? Is there a way to import libjxl with find_library only?

@HappySeaFox
Copy link
Contributor Author

libjxl/libjxl#2851

@dg0yt
Copy link
Contributor

dg0yt commented Oct 7, 2023

_imp_JxlDecoderCreate

This shouldn't occur for x64-windows-static.

@HappySeaFox
Copy link
Contributor Author

HappySeaFox commented Oct 7, 2023

The issue is a little bit more complicated. See libjxl/libjxl#2851. I'm not sure if it's could be fixed on the vcpkg side. The problem is that I need to define JXL_STATIC_DEFINE in the client app. But even if I define it, the link process fails with missing dependencies like hwy or brotli.

@LilyWangLL LilyWangLL added the depends:upstream-changes Waiting on a change to the upstream project label Oct 8, 2023
@xiaozhuai
Copy link
Contributor

xiaozhuai commented Oct 10, 2023

The issue is a little bit more complicated. See libjxl/libjxl#2851. I'm not sure if it's could be fixed on the vcpkg side.

@HappySeaFox

Option 1

We can fix it on vcpkg side by provide an unofficial cmake config.
Then we can use it like (No need to define JXL_STATIC_DEFINE )

find_package(unofficial-libjxl CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::libjxl::libjxl)
# And for libjxl_threads
target_link_libraries(main PRIVATE unofficial::libjxl::libjxl_threads)

You can refer to brotli port to see how to achieve this. Only if you are willing to contribute it : )

Option 2

This port has a pc file

prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libjxl
Description: Loads and saves JPEG XL files
Version: 0.8.2

Libs: "-L${libdir}" -ljxl -lm
Requires: libhwy libbrotlicommon libbrotlienc libbrotlidec lcms2
Cflags: "-I${includedir}" -DJXL_STATIC_DEFINE

Which allow the following usage, and in this way, you don't need to define JXL_STATIC_DEFINE

find_package(PkgConfig REQUIRED)
pkg_check_modules(libjxl REQUIRED IMPORTED_TARGET libjxl)
target_link_libraries(main PRIVATE PkgConfig::libjxl)
# And for libjxl_threads
pkg_check_modules(libjxl_threads REQUIRED IMPORTED_TARGET libjxl_threads)
target_link_libraries(main PRIVATE PkgConfig::libjxl_threads)

Update:
It seems there was a bug in pc file. Forget it.

@xiaozhuai
Copy link
Contributor

See also #33422 #33390 and libjxl/libjxl#2754

Copy link

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

Copy link

github-actions bot commented Oct 8, 2024

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

@github-actions github-actions bot added the Stale label Oct 8, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
depends:upstream-changes Waiting on a change to the upstream project Stale
Projects
None yet
Development

No branches or pull requests

4 participants