c++ - FreeType not linking with CMake after explicit path to library given. -


i have issue linking freetype project. have libs in separate folder, {project}/lib, libfreetype.a located. compiler mingw-64 4.8.3 x86_64-posix-seh-rev2, , built libfreetype.a source using compiler. cmake file looks following:

set(cmake_runtime_output_directory "${project_source_dir}/build/debug") set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11 -lmingw32") set(cmake_exe_linker_flags "-static-libgcc -static-libstdc++") set(cmake_module_path ${project_source_dir}/cmake)  include_directories(${project_source_dir}/include)  link_directories(${project_source_dir}/lib)  set(freetype_include_dirs ${project_source_dir}/include/) set(freetype_library ${project_source_dir}/lib/libfreetype.a) find_package(freetype required) set(source_files main.cpp ...)  add_executable(wahoo ${source_files}) target_link_libraries(test freetype) 

running cause linker fail undefined references '__imp_ft_init_freetype'. removing the libfreetype.a causes cmake cannot find -lfreetype (as expected), including libfreetype.a cause linker errors.

i have change answer, because tried on own , bullshit.

i think, have change last line into

target_link_libraries(test ${freetype_library})