Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

clang++ library not found even when providing library path

I was trying to create a new OpenGL project with glfw and glad using vs code on an m1 Mac, and setup the files such that I have the include folder and lib folder which contains the necessary headers and library (libglfw3.a) files and the src folder that contains the glad.c and main.cpp, all in my workspace folder.

I have modified the tasks.json file like such:

{
"version": "2.0.0",
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: clang++ build active file",
        "command": "/usr/bin/clang++",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "-std=c++17",
            "-I${workspaceFolder}/include",
            "-L${workspaceFolder}/lib",
            "${workspaceFolder}/src/*.cpp",
            "${workspaceFolder}/src/glad.c",
            "-llibglfw3",
            "-o",
            "${workspaceFolder}/game"
        ],
        "options": {
            "cwd": "${fileDirname}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "compiler: /usr/bin/clang++"
    }
]

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

However, I get the following error:

ld: library not found for -llibglfw3 
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I thought that I had properly included the path to the glfw library, but it says that it could not find the library. What am I doing wrong?

As a side-note, I have followed this tutorial to setup the program, but this post assumes that you have a windows machine, so I had downloaded/changed some things to my knowledge of what would work with the m1 mac.

>Solution :

Normally when you give libraries to link with the -l flag, you omit the lib prefix. For example: "-lglfw3" links the file "libglfw3.a". It looks like you should change your -llibglfw3 option.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading