在网上四处看看我看到了很多这样的代码:
include(FindPkgConfig)
pkg_search_module(SDL2 REQUIRED sdl2)
target_include_directories(app SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS}
target_link_libraries(app ${SDL2_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
然而,这似乎是错误的方式,因为它只使用包含目录和库,但忽略了定义,库路径和可能返回的其他标志pkg-config.
这样做的正确方法是什么,并确保编译后pkg-config使用的所有编译和链接标志都被使用app?是否有一个命令来实现这一点,即类似的东西target_use(app SDL2)?
我正在尝试这样做,但我能得到的是一些我不知道如何处理的源代码我从http://pkgconfig.freedesktop.org/releases/下载.
有帮助吗?
我已使用https://help.ubuntu.com/community/OpenCV中的说明安装了OpenCV
$ sudo su
$ sudo apt-get install build-essential
$ sudo apt-get install libavformat-dev
$ sudo apt-get install ffmpeg
$ sudo apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev
Run Code Online (Sandbox Code Playgroud)
现在,当我执行"pkg-config --cflags --libs opencv"时,我收到此错误:
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
------- -------更新
好的,我想出了如何解决问题......
我创建了一个名为"opencv.pc"的文件并将其复制到"/ usr/local/lib/pkgconfig"然后我将这两行添加到".bashrc":
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
Run Code Online (Sandbox Code Playgroud)
而已!现在一切都好.
该文件的内容是:
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Ubuntu 10.4 LTS上安装Lsyncd但我收到一些错误:
> checking for LUA... no checking for
> LUA... no checking for LUA...
> configure: error: Package requirements
> (lua >= 5.1.3) were not met:
>
> No package 'lua' found
>
> Consider adjusting the PKG_CONFIG_PATH
> environment variable if you installed
> software in a non-standard prefix.
>
> Alternatively, you may set the
> environment variables LUA_CFLAGS and
> LUA_LIBS to avoid the need to call
> pkg-config. See the …Run Code Online (Sandbox Code Playgroud) 我试图让pygobject-2.28.6在cygwin中编译(存储库中的版本是2.28.4,这有一些问题).这是./configure的尾部:
checking for GLIB - version >= 2.24.0... yes (version 2.34.3)
checking for ffi... checking for FFI... yes
checking for GIO... yes
checking for GIOUNIX... yes
checking for GI... no
configure: error: Package requirements (glib-2.0 >= 2.24.0
gobject-introspection-1.0 >= 0.10.2
) were not met:
No package 'gobject-introspection-1.0' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables GI_CFLAGS
and GI_LIBS to avoid the need to call pkg-config.
See …Run Code Online (Sandbox Code Playgroud) 当我尝试交叉编译一些 Rust 时,出现此错误;有谁知道我应该做什么?
当我运行 Cargo build --target aarch64 时会发生这种情况,我得到:
Compiling glib-sys v0.10.1
error: failed to run custom build command for `glib-sys v0.10.1`
...
pkg-config has not been configured to support cross-compilation.
Install a sysroot for the target platform and configure it via
PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
cross-compiling wrapper for pkg-config and set it via
PKG_CONFIG environment variable.
Run Code Online (Sandbox Code Playgroud)
我可能在一年前就问过这个问题,但无论如何我找不到任何答案。我尝试在 Cargo.toml 中添加各种行,但似乎没有任何帮助。
Cargo.toml 的相关部分有:
[target.'cfg(target_os = "android")'.dependencies]
cairo = "0.0.4"
freetype = "0.7.0"
glib = "0.14.2"
openssl = "0.10.36"
openssl-sys …Run Code Online (Sandbox Code Playgroud) 我尝试安装udev.而udev在这期间给了我一个错误./configure
--exists: command not found configure: error:
pkg-config and "glib-2.0 >= 2.16" not found, please set GLIB_CFLAGS and GLIB_LIBS
to the correct values or pass --with-internal-glib to configure
Run Code Online (Sandbox Code Playgroud)
好的,缺少pkg-config和glib-2.0.
起初我尝试安装pkg-config.我收到了这条消息:
checking whether to list both direct and indirect dependencies... no
checking for Win32... no
checking if internal glib should be used... no
checking for pkg-config... no
./configure: line 13557: --exists: command not found
configure: error: pkg-config and "glib-2.0 >= 2.16" not found,
please set GLIB_CFLAGS and GLIB_LIBS to the …Run Code Online (Sandbox Code Playgroud) 各种开发人员不鼓励使用PKG_CHECK_MODULES(例如,在这个答案中),但就我所寻找的原因,没有明确,全面的解释其原因.所以,我问:
PKG_CHECK_MODULES有害?我是一个人,今天第一次使用它.我发现它非常有用,特别是用于处理相当复杂的库集,例如GTK +,我拥有所有这些依赖项:
-I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0
-I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0
-I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1
-I/usr/include/freetype2 -I/usr/include/libpng12
-lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0
-lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0
-lgthread-2.0 -lrt -lglib-2.0
Run Code Online (Sandbox Code Playgroud) Warning: Could not link pkg-config. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link pkg-config`??????
Run Code Online (Sandbox Code Playgroud) 我在OSX中用homebrew安装了pkg-config.我不确定我应该将PKG_CONFIG_PATH设置为什么?它应该是/ usr/include和/ usr/local/include的组合吗?即使我使用其中一个,我得到一个错误,关于没有任何.pc文件,我认为它将包含pkg-config使用的信息?不知道我做错了什么.帮助赞赏.
__CODE__
更新:也许我问两个不同的问题.我只是卷曲了gsl并浏览了./configure && make && sudo make install.有了一个空的$ PKG_CONFIG_PATH我实际上得到了一个命中:
__CODE__
但是列出/ usr/local/lib显示了gsl libs但没有显示.pc文件.为什么pkg-config适用于OSX中的自定义安装包但不是默认安装的?