none
CMake project do not find a library RRS feed

  • Question

  • Hello!

    I have 0 experience with CMake but it is what visual studio supports, so... I have not worked with VS C++ either, just C projects in linux with make. (and C# and PHP and...)

    I want to add a library called gclib. I have the binaries, sources, etc. Just I do not know the way (nor best way) to add it to my project.

    Now I am studing CMake, etc.

    If someone could give me a hint or something I would be pretty thankful.

    I have been messing around, here you are how I am now:

    ------------------------------------------------------

    I have the next CMakeList.txt:

    project(multiDimIndex)
    cmake_minimum_required (VERSION 3.8)
    message(STATUS "testing")
    # Add source to this project's executable.
    add_executable (multiDimIndex "multiDimIndex.cpp" "multiDimIndex.h" ) #"../PruebaGC/include/gc.h")
    
    
    add_definitions(-DHAVE_GC=1)
    
    find_path(GC_INCLUDE_DIR gc)
    find_library(GC_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/gc-lib.lib)
    set(PROJECT_LIB gc-lib.lib)
    
    include_directories(${CMAKE_CURRENT_SOURCE_DIR})
    add_library(gclib UNKNOWN IMPORTED)
    
    set_property(TARGET gclib PROPERTY IMPORTED_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_LIB})
    
    include_directories(${CMAKE_CURRENT_SOURCE_DIR})
    
    add_library(format format.cpp)
    
    #target_link_libraries(multiDimIndex ${YOUR_LIBRARIES})
    target_link_libraries(multiDimIndex gc-lib format)

    When I save the CMakeList.txt the output ends with:

    1> [CMake] -- Configuring done
    1> [CMake] -- Generating done
    1> [CMake] -- Build files have been written to: C:/Users/OrlandoJosé/Desktop/Equipo/drive/Varios/prototipoAlgoritmoIndiceMD/multiDimIndex/out/build/x64-Debug
    1> [CMake] 
    1> Extracted includes paths.
    1> Extracted CMake variables.
    1> Extracted source files and headers.
    1> Extracted code model.
    1> CMake generation finished.

    When I try to debug I obtain the next error:

    fatal error LNK1104: cannot open file 'gc-lib.lib'

    My CMakeList.txt is a mess. Currently have many commented things and such> I got this project working like one year ago but I had to use it in another computer and... it does not work. I am not sure what I have changed since it worked either.

    I am not sure, but I think that CMake does not tell me if he is finding the files or not, but as the syntax is (I think) correct, there are no errors, but the files are not being copied to the output folder either.

    Copying the files manually it has worked but now it lacks some symbol definitions where all the gclib files are.

    Please tell me how I should link the gc-lib so it works. Thanks you in advance!


    Monday, February 3, 2020 1:53 PM

All replies

  • I am trying to learn the basics of CMake, CMake in VS and such. If you have an URL for a nice tutorial, please tell me :)

    I will be researching and reading until I fix this... argh!

    Thanks

    Monday, February 3, 2020 3:23 PM
  • Hi,

    Thank you for posting here.

    >>CMake project do not find a library

    This forum is about visual c++ development. For your case which is more related to CMake , I suggest you should ask it in a CMake forum for better help. And this thread will be moved to Off-Topic Posts.

    Best Regards,

    Jeanine Zhang

    Tuesday, February 4, 2020 3:24 AM