C++ CmakeLists build error "/usr/bin/ld: cannot find -lglfw"

Discussion in 'Simulation' started by Ilija Stanojkovic, Apr 9, 2019.

  1. Hi all,

    I'm trying to build my project which uses mujoco with cmake, and I'm getting the error:
    Code:
    ~ /usr/bin/ld: cannot find -lglfw
    I've searched around the forum and internet overall, and found cmake examples:
    Although my cmake files match these ones, I still have a problem with lglfw for some reason. I include relevant snippets from my CmakeLists.txt
    Code:
    ######################################################
    # define the include directory of all ${CATKIN_PKGS} #
    ######################################################
    include_directories(
        ${PROJECT_SOURCE_DIR}/include
        ${catkin_INCLUDE_DIRS}
        ${Eigen_INCLUDE_DIRS}
        $ENV{MUJOCO_PATH}/include
    )
    
    ########################################################
    # manage the creation of the libraries and executables #
    ########################################################
    set(USE_GL 1)
    
    link_directories($ENV{MUJOCO_PATH}/bin)
    
    #Finding main mujoco library
    if(${USE_GL})
        file(GLOB LIB_MUJOCO $ENV{MUJOCO_PATH}/bin/libmujoco[0-9][0-9][0-9].so)
    else()
        file(GLOB LIB_MUJOCO $ENV{MUJOCO_PATH}/bin/libmujoco[0-9][0-9][0-9]nogl.so)
    endif()
    #Showing mujoco library found
    message(STATUS "MuJoCo lib: " ${LIB_MUJOCO})
    
    add_subdirectory(src)
    
    And from src/CmakeLists.txt:
    Code:
    set(BIN_NAME mujoco_finger_test)
    
    add_executable(${BIN_NAME} ${BIN_NAME}.cpp)
    target_link_libraries(${BIN_NAME} ${LIB_MUJOCO})
    
    # Standard libraries for GL
    target_link_libraries(${BIN_NAME} GL GLU glut )
    
    # Additional libraries from mujoco package
    target_link_libraries(${BIN_NAME} libglew.so libglfw.so.3 libglewegl.so libglewosmesa.so)
    
    Does anyone see what is missing, or is incorrect? Any idea why the error is thrown?

    Thanks!
     
  2. I got an answer on stack owerflow: https://stackoverflow.com/a/55608420/5576434