【发布时间】:2016-09-25 14:09:44
【问题描述】:
这个has been asked on SO before,甚至还有a related bug on this in CMAKE。但是,我的问题是一个变体,答案并不明确。
我的问题是我正在使用 MinGW 为 Linux 上的 Windows 进行交叉编译。静态库的命名如下:libGLESv2.dll.a 和 libiconv.dll.a,DLL 分别为 libGLESv2.dll 和 iconv.dll。
例子:
find_library(FOUND_LIB_X NAMES "zlib1.dll" PATHS ${CMAKE_FIND_ROOT_PATH}/bin/)
finds this: zlib1.dll
find_library(FOUND_LIB_Y NAMES "libGLESv2.dll" PATHS ${CMAKE_FIND_ROOT_PATH}/bin/)
finds this: libGLESv2.dll.a
find_library(FOUND_LIB_Y NAMES "iconv.dll" PATHS ${CMAKE_FIND_ROOT_PATH}/bin/)
finds this: libiconv.dll.a
The CMAKE bug 似乎指的是静态库被命名为 blah.lib (Windows) 或 blah.a (Linux) 的传统情况。在 Linux 上使用 mingw 的这种交叉编译器情况下,它们被命名为 blah.dll.a
我需要它来查找字面上称为iconv.dll 的文件,仅此而已。如果它没有从字面上找到,那么中止。我是否使用了错误的 CMAKE 功能? (不要使用find_library()?)
【问题讨论】:
-
奇怪。根据documentation,
Each library name given to the NAMES option is first considered as a library file name and then considered with platform-specific prefixes (e.g. lib) and suffixes (e.g. .so).。你确定它找到了libiconv.dll.a在同一目录中,其中包含iconv.dll?最后,您可以在调用find_library之前清理变量CMAKE_FIND_LIBRARY_PREFIXES或CMAKE_FIND_LIBRARY_SUFFIXES。 -
顺便说一句,您在每次重新配置之前清理 CMake 缓存以允许
find_library找到新的,不是吗? -
@Tsyvarev -- 一个字面上称为 iconv.dll 的文件位于 PATHS 参数中指定的 /bin 文件夹中。另一个名为 libiconv.dll.a 的文件位于与 /bin 平行的 /lib 中。是的,我清除了缓存。