실제로 저는 win32 플랫폼에서 MSYS/MinGW를 사용하여 Devil 라이브러리를 현지화하는 CMake 스크립트를 만듭니다. 악마 .dll 파일이 빈 하위 폴더에 배치됩니다 lib 디렉토리에서의 DevIL.lib 및 DevIL.a 파일을DevMS 이미지 라이브러리를 사용하여 dll 파일을 연결하는 MSYS/MinGW에서 CMAKE를 사용할 때의 문제
project (DevILTest)
cmake_minimum_required(VERSION 2.6)
FIND_PACKAGE(OpenGL)
IF(OPENGL_FOUND)
MESSAGE(STATUS "OpenGL render API found.")
MESSAGE(STATUS "Detected OpenGL path is : ${OPENGL_LIBRARIES}")
ENDIF(OPENGL_FOUND)
#Determine DevIL specific header file
FIND_PATH(IL_INCLUDE_DIR il.h
PATH_SUFFIXES include/IL
PATHS c:/mingw
DOC "The path the the directory that contains il.h"
)
MESSAGE("Found DevIL includes at: ${IL_INCLUDE_DIR}")
#Determine DevIL library
FIND_LIBRARY(IL_LIBRARY NAMES DEVIL
PATH_SUFFIXES lib
PATHS c:/mingw
DOC "The file that corresponds to the base il library."
)
MESSAGE("Found DevIL library at: ${IL_LIBRARY}")
SET (Sources
winmain.cpp
)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(IL_INCLUDE_DIR /c/binrev/development/mingw/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${IL_INCLUDE_DIR}
/usr/include
/usr/local/include
)
add_executable (DevILTest ${Sources})
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR})
TARGET_LINK_LIBRARIES(DevILTest ${OPENGL_LIBRARIES} ${IL_LIBRARY})
: 나는 때 악마를 찾는 시도는 MinGW 루트를 생각하는 기원 FindDevIL CMake 스크립트를 확장했습니다 MinGW 루트 (c :/mingw)의 하위 폴더. find_library()를 사용하여 라이브러리가 있는지 확인합니다.
-- OpenGL render API found.
-- Detected OpenGL path is : glu32;opengl32
-- Found DevIL includes at: C:/mingw/include/IL
-- Found DevIL library at: C:/mingw/bin/DevIL.dll
Find_libary은()에 allways는 DLL 파일의 경로를 반환합니다 -하지만 난는 MinGW 사용이 라이브러리에 링크 할 수 없습니다 : 내가 dll 파일을 제거하면
Linking CXX executable DevILTest.exe
/C/binrev/development/mingw/bin/g++.exe "CMakeFiles/DevILTest.dir /winmain.cpp.obj" -o DevILTest.exe -Wl,--out-implib,libDevILTest.dll.a -Wl,--ma
32 -lopengl32 DevIL.dll -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
CMakeFiles/DevILTest.dir/winmain.cpp.obj:winmain.cpp:(.text+0xcc8): undefined reference to `[email protected]'
CMakeFiles/DevILTest.dir/winmain.cpp.obj:winmain.cpp:(.text+0xce0): undefined reference to `[email protected]'
CMakeFiles/DevILTest.dir/winmain.cpp.obj:winmain.cpp:(.text+0xcf9): undefined reference to `[email protected]'
와 가량이 스크립트 cmake를 실행 DevIL.lib 라이브러리는 제대로 지역화되고 난 더 링커 오류를 갈 다음 dll 파일 누락 동안
-- Detected OpenGL path is : glu32;opengl32
-- Found DevIL includes at: C:/mingw/include/IL
-- Found DevIL library at: C:/mingw/lib/DevIL.lib
그러나 때이 경우 APPLICATION 응용 충돌에가 시작합니다. 다시 mingw 또는 응용 프로그램 루트에 다시 추가하면 응용 프로그램이 실행되지만 .lib 대신 dll 파일을 현지화하는 동안 cmake 실행시 다시 실패합니다.
이 문제를 해결할 수있는 방법이 누구에게 있습니까? 나는 어떤 힌트라도 깊게 감사 할 것이다. 감사합니다, 기독교
아니요! CMake의 주요 포인트 중 하나는 크로스 플랫폼 개발이며, lib를 추가하면 분명히 그것을 깨뜨린다. 이 모든 것이 나를 위해 cmake의 버그처럼 보입니다. mingw 생성기 생성기를 사용하는 경우에도 lib 파일을 검색해야합니다. – Slava