I'm trying to build a simple application
using the freetype library on  Windows 64.
Freetype lib was compiled from src on windows 64

simple programm

    #include <ft2build.h>
    #include FT_FREETYPE_H

    int main (int argc, char** argv) {

    FT_Library ft;
      if (FT_Init_FreeType(&ft) != 0) {
        //err
      }
    }

Added environment variable FREETYPE_DIR
and cmake script


    cmake_minimum_required(VERSION 3.22)

    cmake_path(CONVERT $ENV{COMPILER} TO_CMAKE_PATH_LIST COMPILER)
    set(CMAKE_CXX_COMPILER "${COMPILER}/clang++.exe")
    set(CMAKE_C_COMPILER "${COMPILER}/clang.exe")
    set(CMAKE_RC_COMPILER "${COMPILER}/llvm-rc.exe")

    set(CMAKE_BUILD_TYPE Release)
    set(EXECUTABLE_OUTPUT_PATH "../bin")

    project (text)
    file(GLOB SRC
    "./src/main.cpp"
    )

    find_package(Freetype MODULE REQUIRED)

    add_executable (${PROJECT_NAME} ${SRC})

    target_include_directories(${PROJECT_NAME}
      PRIVATE "./include"
      PRIVATE ${FREETYPE_INCLUDE_DIRS}
    )

    target_link_libraries(${PROJECT_NAME}

     Freetype::Freetype
    )
 but I'm stuck, get a linker error, although freetype library is linked

    ninja: Entering directory `./build'
    [1/1] cmd.exe /C "cd . &&
    C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\Llvm\x64\bin\CLANG_~1.EXE
-fuse-ld=lld-link
    -nostartfiles -nostdlib -O3 -DNDEBUG -D_DLL -D_MT -Xclang
--dependent-lib=msvcrt -
    Xlinker /subsystem:console CMakeFiles/text.dir/src/main.cpp.obj -o
    D:\git\cpp\opengl\drawtext\bin\text.exe -Xlinker /MANIFEST:EMBED
-Xlinker
    /implib:D:\git\cpp\opengl\drawtext\bin\text.lib -Xlinker
    /pdb:D:\git\cpp\opengl\drawtext\bin\text.pdb -Xlinker /version:0.0
D:/source/freetype-
    2.12.1/build/x86_64/Release/lib/freetype.lib  -lkernel32 -luser32
-lgdi32 -lwinspool -
    lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  &&
cd ."
    FAILED: D:/git/cpp/opengl/drawtext/bin/text.exe
    cmd.exe /C "cd . &&
    C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\Llvm\x64\bin\CLANG_~1.EXE
-fuse-ld=lld-link
    -nostartfiles -nostdlib -O3 -DNDEBUG -D_DLL -D_MT -Xclang
--dependent-lib=msvcrt -
    Xlinker /subsystem:console CMakeFiles/text.dir/src/main.cpp.obj -o
    D:\git\cpp\opengl\drawtext\bin\text.exe -Xlinker /MANIFEST:EMBED
-Xlinker
    /implib:D:\git\cpp\opengl\drawtext\bin\text.lib -Xlinker
    /pdb:D:\git\cpp\opengl\drawtext\bin\text.pdb -Xlinker /version:0.0
D:/source/freetype-
    2.12.1/build/x86_64/Release/lib/freetype.lib  -lkernel32 -luser32
-lgdi32 -lwinspool -
    lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  &&
cd ."
    lld-link: error: undefined symbol: FT_Init_FreeType
    >>> referenced by CMakeFiles/text.dir/src/main.cpp.obj:(main)
    clang++: error: linker command failed with exit code 1 (use -v to see
invocation)
    ninja: build stopped: subcommand failed.

Reply via email to