OpenGL setup: GLFW and GLAD in Visual Studio Code on macOS

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • Contents of the video:
    00:00 Intro
    01:00 GLFW download and project setup
    03:03 VS Code default build task configuration
    06:46 Glad download
    Homebrew : brew.sh
    GLAD : glad.dav1d.de
    Sample code 1 : www.glfw.org/documentation.html
    Sample code 2 : learnopengl.com/code_viewer_g...
    --------------------------------------------------
    --------------------tasks.json--------------------
    {
    "version": "2.0.0",
    "tasks": [
    {
    "type": "cppbuild",
    "label": "C/C++: clang++ build active file",
    "command": "/usr/bin/clang++",
    "args": [
    "-std=c++17",
    "-fdiagnostics-color=always",
    "-Wall",
    "-g",
    "-I${workspaceFolder}/dependencies/include",
    "-L${workspaceFolder}/dependencies/library",
    "${workspaceFolder}/dependencies/library/libglfw.3.3.dylib",
    "${workspaceFolder}/*.cpp",
    "${workspaceFolder}/glad.c",
    "-o",
    "${workspaceFolder}/app",
    "-framework",
    "OpenGL",
    "-framework",
    "Cocoa",
    "-framework",
    "IOKit",
    "-framework",
    "CoreVideo",
    "-framework",
    "CoreFoundation",
    "-Wno-deprecated"
    ],
    "options": {
    "cwd": "${fileDirname}"
    },
    "problemMatcher": ["$gcc"],
    "group": {
    "kind": "build",
    "isDefault": true
    },
    "detail": "compiler: /usr/bin/clang++"
    }
    ]
    }

Комментарии • 128

  • @magicman02
    @magicman02 7 месяцев назад +7

    You have no idea how much this tutorial helped me. I was struggling to find a good tutorial for this EXACT thing and you did it perfectly and clearly.

  • @mr.mclovin8415
    @mr.mclovin8415 2 года назад +3

    You made the process so easy . Brilliant tutorial .

  • @somabencsik
    @somabencsik Год назад

    Thank you so much, I was looking for a tutorial for like hours until I finally saw your video, and it is working, thanks once again!

  • @nunzioturtulici9636
    @nunzioturtulici9636 Год назад

    I wanna say thank you! I would gone crazy trying to set up all without your video...thanks for sharing!

  • @torcat
    @torcat Год назад

    The instructions were PERFECTLY. Thank you so much buddy!

  • @maxrathbone-boschis547
    @maxrathbone-boschis547 11 месяцев назад

    This is what I have been looking for ages, THANK!!

  • @sauravregmi2872
    @sauravregmi2872 2 года назад +2

    Great instructions - easy to follow.
    Highly recommended!!!

  • @fullViewJay
    @fullViewJay Год назад

    Great simple and easy tutorial. Thank you!
    You can also change the file type to be glad.cpp as well to avoid adding the extra path to the args list

  • @ReggaeUnicorn
    @ReggaeUnicorn Год назад

    Nice job mate, much better than the official docs and much clearer.

  • @sungjuyea4627
    @sungjuyea4627 Год назад +2

    As a person who uses VSCode on MacOs, this works perfectly! Thanks!!!

  • @aninosspro
    @aninosspro 6 месяцев назад

    thanks for the video. you fix in a 4 min what I was stuck in for the past 3 to 5 hours, keep the grease work

  • @idkwhatIshouldsayhere
    @idkwhatIshouldsayhere Год назад +4

    Indian Programming Legend comes to save the day again...

  • @aaaakko139
    @aaaakko139 6 месяцев назад

    Best one! Really help me figure out how to build OpenGL with vscode

  • @aomadeira
    @aomadeira 7 месяцев назад

    Simple and straight to the point, thanks!

  • @ishiniavindya103
    @ishiniavindya103 2 года назад

    Great tutorial thank you. Worked so well with my Macbook M1

  • @lolaueda8206
    @lolaueda8206 Год назад +1

    It is so clear! Thank you so much!
    I was waiting for it the whole year. Would you be teaching how to use VSC set up for 3D with shaders, where we add more separate files??
    You made my day!

  • @user-xw1lr8bz7c
    @user-xw1lr8bz7c Год назад

    thank you so much, this was incredibly helpful :)

  • @vante6886
    @vante6886 6 месяцев назад

    Worked perfectly in mac M1, thank you!

  • @popcultureprogrammer2171
    @popcultureprogrammer2171 Год назад

    @rosxnb THANK YOU SO MUCH! I've been banging my head against the wall trying to figure this all out for WEEKS, since I dont have admin privileges on my school Macbook so I cant install libraries at root. I circumvented it by simply just having Homebrew on the desktop, and other than that, followed your tutorial exactly. I dont usually 'like' videos ( because I'm lazy & usually dont love the content on YT, but you earned it!. Thank you!

  • @prashantshrestha5564
    @prashantshrestha5564 Год назад

    you made the entire process too easy. thanks buddy now i can bang my head in the wall

  • @mona-wy4yn
    @mona-wy4yn 2 года назад

    thank you so much for this u are a life savior!

  • @danniel90
    @danniel90 2 года назад

    This was very helpful. Thanks!

  • @luckysun1852
    @luckysun1852 Год назад

    amazing videos, you saved my life.

  • @octaviotastico
    @octaviotastico Год назад

    Thanks man! Very appreciated!

  • @viggenzz
    @viggenzz 3 месяца назад

    thanks a lot. you are doing god's work. exactly what I needed.

  • @adamspiano
    @adamspiano 11 месяцев назад

    Thanks so much for this!!

  • @rameshsharma4023
    @rameshsharma4023 2 года назад

    Thank you sir🥰.it help me a lot💐💐💐

  • @DevelopedEgg
    @DevelopedEgg 4 месяца назад

    Helped a lot thanks

  • @nikoniko5570
    @nikoniko5570 Год назад

    Holy shit, man
    I LOVE YOU

  • @user-jy5yh9on4l
    @user-jy5yh9on4l Год назад +1

    Большое спасибо, добрый человек

  • @donnychan1999
    @donnychan1999 Год назад

    You are a savior sir

  • @minanaji9597
    @minanaji9597 Год назад

    Works on M1 macbook! Thanks!

  • @brunocastro7858
    @brunocastro7858 6 месяцев назад

    nice number of subs, my guy

  • @tedpark6311
    @tedpark6311 2 года назад

    Thank you so much!

  • @wilchardruin
    @wilchardruin Год назад

    it's a great begin , thanks

  • @GWebcob
    @GWebcob 4 месяца назад

    thank you very much!

  • @fox20431
    @fox20431 2 года назад

    awesome! think you so much!!!

  • @user-ix5jf6vd3n
    @user-ix5jf6vd3n 2 года назад

    Thank you a lot!

  • @joahnoub173
    @joahnoub173 9 месяцев назад

    Amazing thanks!

  • @user-xd7xj1hc1l
    @user-xd7xj1hc1l Год назад

    Thx. Great video! Although I got this "code in description" after typing and following the video for ten minutes😅

  • @abdulhakim9537
    @abdulhakim9537 7 месяцев назад

    Thank you so much bro

  • @oscarv6907
    @oscarv6907 Год назад

    This worked really well for me, although I changed my task.json because my folder structure was different.

  • @12Vencedor
    @12Vencedor 2 года назад

    xcode wouldnt work. i tried everything 3 hours.
    this at first didnt worked too until i double checked that i copied wrong folder. now it works!!! thank you very much!!

  • @user-hk8fn3vt2c
    @user-hk8fn3vt2c Год назад

    Thank you very much

  • @jhalakgiri8612
    @jhalakgiri8612 2 года назад

    Keep it up 👍

  • @rylee5233
    @rylee5233 Год назад

    Thank you !Thats is really helpful and clear

  • @user-hq4lu7fu1z
    @user-hq4lu7fu1z Год назад

    Thank you!

  • @dawidklyta2515
    @dawidklyta2515 3 месяца назад

    I have done everything as you said, and it built but did't want to run app. I found out that i needed to add one more line in the task.json inside args "-Wl,-rpath,@executable_path/lib" and now it works perfectly. Thanks very much.

  • @gregfrllo
    @gregfrllo Год назад

    thank you so much

  • @1-upprotocol621
    @1-upprotocol621 Год назад

    Legend, tysm

  • @nijhoomofficial
    @nijhoomofficial 2 года назад

    Thanks a lot

  • @ephysio7357
    @ephysio7357 Год назад

    Very good tutorial, thank you !

  • @pr8880
    @pr8880 2 года назад

    Thanks sir for Gl setup. It troublesoot my problem

  • @johnsarofeen7022
    @johnsarofeen7022 2 года назад

    I love you

  • @mrunalkadhane5883
    @mrunalkadhane5883 11 месяцев назад +3

    Hi I am getting this error dyld[74341]: Library not loaded: @rpath/libglfw.3.dylib after running ./app in the terminal. Can you please help with this

  • @d1legends157
    @d1legends157 Год назад +1

    For the first sample code, my build starts but never seems to finish... what can I do?

  • @aarushikhatrimarry8979
    @aarushikhatrimarry8979 2 года назад

    👍👍👍

  • @Sony_MiniDisc
    @Sony_MiniDisc Год назад

    I love indian programming tutorials

  • @ahmadbodayr7203
    @ahmadbodayr7203 Год назад

    gold

  • @ww25_td
    @ww25_td Год назад

    Hi I am getting warning saying ld: warning: dylib was built for newer macOS version (13.0) then being linked (12.3). Do you have any suggestions? I am using the most up to date version of glfw and my Mac is 13?

  • @user-jj5df5yc1p
    @user-jj5df5yc1p Год назад +1

    after continuing on with the tutorial i still have an issue where it fails tp build successfully saying that there isn't a glad header folder to find/use when there clearly is one

  • @aunesto17
    @aunesto17 11 месяцев назад +1

    Hello. Thanks for this guide, I'm about to start a course that needs OpenGL and I only have a mac laptop so this is great. While trying to run Sample code 1 I get this error:
    Undefined symbols for architecture x86_64:
    "_main", referenced from:
    implicit entry/start for main executable
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    Could you please help me.

  • @stamponfloormagic
    @stamponfloormagic 2 года назад +6

    hi, I am having trouble getting the file to run using the first code, the error message I keep getting is:
    ~/main.cpp:1:10: fatal error: 'GLFW/glfw3.h' file not found
    #include
    ^~~~~~~~~~~~~~
    1 error generated.
    Build finished with error(s).
    any recommendations for how to solve? Thanks :)

    • @rosxnb
      @rosxnb  2 года назад +1

      Maybe you entered the include path wrong.
      If you still have problem let me know

    • @iamadityavaishy
      @iamadityavaishy Год назад

      @@rosxnb I have the same problem. Help please

  • @SlurpCode
    @SlurpCode Год назад

    I choose the same default build task however my args structure is different, is this normal and do I need to change it?

  • @sanghamitradas9437
    @sanghamitradas9437 Год назад

    Hey. Mine is stuck at "Starting build..." for over 15mins now. Do you have any clue why? No other errors.

  • @user-jj5df5yc1p
    @user-jj5df5yc1p Год назад

    i've followed your steps correctly up until the build but it gives me "clang: error: no such file or directory: '/Users/monsieurpipes/local_Uni_Files/2nd Year/comp2006/cw2/*.cpp'
    clang: error: no such file or directory: '/Users/monsieurpipes/local_Uni_Files/2nd Year/comp2006/cw2/glad.c'" any ideas why??

  • @ddmichael9035
    @ddmichael9035 2 года назад

    Hi, have you tried to include ASSIMP in the project? I followed your instruction to set up the OpenGL environment, but there seems to have linking issue when I include ASSIMP into the project. Any hint?

    • @rosxnb
      @rosxnb  2 года назад

      The linking process must be similar as I have shown for glad and glfw in the video.
      Maybe It has other dependencies, make sure you link all them. Unfortunately I haven't tried ASSIMP.

  • @abdullaannoman332
    @abdullaannoman332 Год назад

    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    Build finished with error(s).

  • @ilt_RIAD65
    @ilt_RIAD65 10 месяцев назад

    i need help. my error is: error: invalid argument '-std=c++17' not allowed with 'C'. how do i right now

  • @zhenko9841
    @zhenko9841 Год назад +1

    Great tutorial, but u need to change the sound.

  • @preetikumari538
    @preetikumari538 Год назад

    Doing as it is why it is showing terminal failed
    please help me with this

  • @chhavi019
    @chhavi019 5 месяцев назад

    hi can you also explain how to add GLUT too?

  • @purassicjark
    @purassicjark 5 месяцев назад

    Does GLEW need to be installed as well?

  • @syi14
    @syi14 8 месяцев назад

    why i do not have the c/c++ compiler?

  • @sergioruppel7269
    @sergioruppel7269 Год назад

    i have a question, now that we modified the task.json file, will it be used for every c++ file we compile?

    • @rosxnb
      @rosxnb  Год назад

      you should include every cpp file path in task.json individually. All this is exactly like the commands you would pass to the compiler with flags and list of files but task.json is like script which invokes the compiler command each time so you won't have to write long commands every time you want to compile your files.

  • @gurinderkaur6817
    @gurinderkaur6817 3 месяца назад +1

    fatal error: 'glad/glad.h' file not found
    #include
    ^~~~~~~~~~~~~
    1 error generated.
    i go this error please help

  • @_nakhoo_
    @_nakhoo_ 5 месяцев назад

    I got an error:
    clang: error: no such file or directory: '/Users/.../Desktop/youtube/*.cpp'

  • @ammarhamdy289
    @ammarhamdy289 2 года назад

    my visual studio on Mac m1 cannot select a file to open

  • @chrystalmathias1185
    @chrystalmathias1185 Год назад

    brew command not found -it says in the terminal

  • @Itsme-yq7cj
    @Itsme-yq7cj 6 месяцев назад

    After repeating what you did, it gives me "clang: error: linker command failed with exit code 1 (use -v to see invocation)". I would appreciate if someone helps me. P.S I am using glfw 3.3.9

  • @d1legends157
    @d1legends157 Год назад

    I finished the tutorial and the second sample code compiled and ran! I see why programmers lose their hair.

  • @sandeep.p7
    @sandeep.p7 Год назад +1

    How to run the code after "build run sucessfully"

    • @rosxnb
      @rosxnb  Год назад

      you could just type "./app" in the terminal. Make sure you are in the right directory and you can see the "app" file.
      we name the executable as "app" with following command in the tutorial
      {
      "-o",
      "${workspaceFolder}/app"
      }

  • @ngvi84
    @ngvi84 6 месяцев назад

    can u instruct me include glut library

  • @rylee5233
    @rylee5233 Год назад

    I cant start build after using conmand shift B ....what happened?or is there any other way to build?

    • @rylee5233
      @rylee5233 Год назад

      OK I found it in just under Terminal

  • @sheldonxu635
    @sheldonxu635 Год назад

    i made a mistake creating the main.cpp under the dependancy folder, im so dumbbb

  • @ankansaha3260
    @ankansaha3260 10 месяцев назад +1

    I had followed all the steps..
    but there showed me this error......."'GLFW/glfw3.h' file not found".
    this file is on the right place, but probably the compiler can't detect it..
    what would I do to solve this..??

    • @Aaans-bd8ep
      @Aaans-bd8ep 8 месяцев назад

      have you figured out how to solve this error? I have the same

    • @ankansaha3260
      @ankansaha3260 8 месяцев назад

      @@Aaans-bd8ep Yes, I did.

    • @ryanliu8665
      @ryanliu8665 5 месяцев назад

      how? lol
      @@ankansaha3260

  • @ashersaipe
    @ashersaipe 2 года назад

    thanks so much for this! however the second example code link doesnt work. is this just me? please could you just reply with the code?

    • @rosxnb
      @rosxnb  2 года назад

      code I used was from learnopengl.com which by the way is great resource to learn about OpenGL if you are a beginner.
      here is the link:
      learnopengl.com/code_viewer_gh.php?code=src/1.getting_started/2.1.hello_triangle/hello_triangle.cpp

  • @savo0403
    @savo0403 2 года назад

    hi! when i do the brew install glfw i get the error "zsh: command not found: brew" but it says that installation is successful

    • @rosxnb
      @rosxnb  2 года назад +1

      checkout following stack overflow discussion
      stackoverflow.com/questions/36657321/after-installing-homebrew-i-get-zsh-command-not-found-brew/71919315

    • @savo0403
      @savo0403 2 года назад

      @@rosxnb Thank you so much but now when i run specific code it says 'GL/glew.h' file not found what should i do

    • @rosxnb
      @rosxnb  2 года назад

      It's because you probably haven't specified the path for the GLEW.
      In this tutorial, I have used glad which is an alternative for the GLEW, so provide path to the files in task.json as I have done in video for the libraries.

  • @user-jj5df5yc1p
    @user-jj5df5yc1p Год назад +1

    anyone else have the issue of not being able to open the source code for the header file?

    • @gamerxl369
      @gamerxl369 Год назад

      I'm experiencing the same problem. Works fine initially but once i try to set up glad and test the new code to build it i get errors. Well i was gonna complain more, but it after moving the file out of the folder and then putting it back in for some reason it miraculously worked...
      Not sure what i did. Like i am still geting error glad/glad.h file not found but it bypassed it and i got it to print the triangle

  • @ericdomer3292
    @ericdomer3292 2 года назад

    hello im not able to find libglfw.3.3.dylib im only able to find libglfw.3.dylib please please please help out

    • @rosxnb
      @rosxnb  2 года назад

      have you tried re-downloading GLFW and check if the files exits?

    • @johnyeap7133
      @johnyeap7133 Месяц назад

      same here only libglfw.3.dylib

  • @ryanliu8665
    @ryanliu8665 5 месяцев назад

    build is taking forever, anyone have any ideas?

  • @user-jx1cu9yh6y
    @user-jx1cu9yh6y Год назад

    for love of the god i need help its not working and i need it real bad for my study please answer me as you can🙏

    • @rosxnb
      @rosxnb  Год назад

      what error message are you getting?

  • @jakehues
    @jakehues 2 года назад

    Hi, im getting this error: cannot open source file "OpenGL/gl.h" and this inside my glfw3.h: #include #include errors detected please update your includePath. Any ideas? Thanks :D

    • @rosxnb
      @rosxnb  2 года назад

      Path to the file "OpenGl/gl.h" is actually provided by OpenGL framework.
      Make sure you pass the flag "-framework OpenGL" without spelling error

  • @Israeli8103
    @Israeli8103 Год назад

    not working for arm64

    • @alexba88ify
      @alexba88ify Год назад

      Are you also getting some error about duplicate _main?

  • @DeadManRising
    @DeadManRising 10 месяцев назад +1

    dude speak louder, damn.

  • @ahmadbodayr7203
    @ahmadbodayr7203 Год назад +1

    read about islam if you are not muslim bro, thanks for the great video

  • @HarvestrX
    @HarvestrX 9 месяцев назад

    Buy a PC, Macs are garbage!

  • @harshithgreddy8131
    @harshithgreddy8131 2 года назад +1

    I am getting the following errors Can you please guide me through
    clang: error: no such file or directory: '/Users/harshithgreddy/Desktop/Project/*.cpp'
    clang: error: no such file or directory: '/Users/harshithgreddy/Desktop/Project/glad.c'

    • @rosxnb
      @rosxnb  2 года назад

      looks like you have provided the wrong path to source files
      do re-check that and if it still doesn't work, hit me up on twitter @rosxnb

    • @japde2694
      @japde2694 Год назад

      I also have the same problem, did u manage to fix the issue?

    • @rushikeshvayandeshkar4902
      @rushikeshvayandeshkar4902 Год назад

      @@japde2694 I am also

  • @JAO1230e
    @JAO1230e Год назад

    Doesn't work. The code builds, but when trying to run ./app within the terminal it fails. This is the error message:
    dyld[33776]: Library not loaded: @@HOMEBREW_PREFIX@@/opt/glfw/lib/libglfw.3.dylib
    Referenced from: /Users/user/Computation/app
    Reason: tried: '/System/Volumes/Preboot/Cryptexes/OS@@HOMEBREW_PREFIX@@/opt/glfw/lib/libglfw.3.dylib' (no such file), '/usr/local/lib/libglfw.3.dylib' (no such file), '/usr/lib/libglfw.3.dylib' (no such file, not in dyld cache)
    I do not know how to fix

  • @shivabaidya436
    @shivabaidya436 2 года назад

    for someone this code may not work due to glutWindow can't open, add this in the code: glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);