Тёмный

Making and Working with Libraries in C++ (Multiple Projects in Visual Studio) 

The Cherno
Подписаться 643 тыс.
Просмотров 241 тыс.
50% 1

Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► thecherno.com/discord
Series Playlist ► thecherno.com/cpp
Thank you to the following Patreon supporters:
- Samuel Egger
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Опубликовано:

 

25 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 190   
@prezadent1
@prezadent1 6 лет назад
You forgot to turn off wire-frame display for the cactus.
@shaladddin5687
@shaladddin5687 3 года назад
I'm immediately subscribing, because of how clear the tutorial is
@robertmoats1890
@robertmoats1890 2 года назад
You're naturally gifted at walking people through potentially complex concepts rather effortlessly. I'll definitely be checking out more of your videos. Thanks man!
@pwrdwnsys
@pwrdwnsys 6 лет назад
Your C++ series is really good. Thanks for making these as they're super helpful.
@suspicious_atharva
@suspicious_atharva 3 года назад
Dogecoin
@HaeriStudios
@HaeriStudios 6 лет назад
This is exactly what I needed! I would love to see a tutorial about proper use of namespaces in a large project and correct inclusion of header files (So that no circular dependencies can happen)
@fzntolenk
@fzntolenk 6 лет назад
Cool... You showed what exactly I was looking for... in detail and easy to understand...
@drewbell5260
@drewbell5260 5 лет назад
Great stuff Cherno. Thanks!
@mb-ql1gb
@mb-ql1gb 6 лет назад
Great tutorial, short, direct and on point, well explaint for beginners, thank you very much!
@bulentgercek
@bulentgercek 3 года назад
This video explain its content as beautiful as a masterpiece. Thank you.
@gavinw77
@gavinw77 2 года назад
Thank you, this was much easier than the MS guide for setting up a DLL. I couldn't get that to work. This guide is simpler. And note that it's also good for DLL's, not just static libraries!
@zonico5826
@zonico5826 6 лет назад
As always, great video!
@Playturbot
@Playturbot 6 лет назад
I spent hours trying to figure this out myself a few weeks ago. If I only knew that it was this simple...
@dreamhollow
@dreamhollow 2 года назад
This was really helpful. I feel like I understand namespaces much better, too.
@lechi_2002
@lechi_2002 6 лет назад
I would like to see a video about exception handling in C++.
@shpresimmuja467
@shpresimmuja467 6 лет назад
Tudor Lechintan he doesn't like exception handling, and I agree, exception handling is stupid.
@greatbullet7372
@greatbullet7372 6 лет назад
we dont want to make exceptions xD
@michaelatorn8380
@michaelatorn8380 5 лет назад
3 important commands: -try -throw -catch
@claudiopisa2043
@claudiopisa2043 3 года назад
@@shpresimmuja467 why ? They can be very useful
@acho8387
@acho8387 2 года назад
Absolutely amazing.
@MSSoftwareGuru
@MSSoftwareGuru 5 лет назад
Wow, you really saved me!!! Thanks SOOO much!
@amateursdream
@amateursdream 4 года назад
As usually amazing!
@adrianoldchannel2494
@adrianoldchannel2494 6 лет назад
That's incredible
@josea8187
@josea8187 6 лет назад
Great video as always mate. It would be great if you could make a couple of videos regarding operator overloading as well as polymorphism.
@pradyumnkejriwal3007
@pradyumnkejriwal3007 6 лет назад
Jose A he already did those
@georges.154
@georges.154 6 лет назад
Awsome video! Thanks a lot man!
@loryon
@loryon 6 лет назад
That was useful thanks !
@femloh
@femloh 5 лет назад
Your tutorials are really good. Thanks for this. Want to build a custom maths library for my 3d projects so I don't recopy every time. Thanks.
@mfatihaydogdu7
@mfatihaydogdu7 Год назад
Thanks!
@soddoffbaldrick2209
@soddoffbaldrick2209 5 лет назад
Awesome! Thanks.
@eduardolacerda8818
@eduardolacerda8818 6 лет назад
I would like to see a video about C++ mobile development showing how to develop a very simple cross-plataform app. Maybe a video about "modern C++"? Another one about makefiles and/or CMake? I couldn't find good youtube videos about these topics, so... :)
@unluckyaf7673
@unluckyaf7673 2 года назад
God bless you mate!
@menderelcapbig1876
@menderelcapbig1876 2 года назад
recursively watching all your videos
@FelipeMendez
@FelipeMendez 6 лет назад
where i could find a cmake vesion of this?
@sheepmeahow
@sheepmeahow 6 лет назад
I tried separating my solution into an Engine and Game project like you showed in this video, however in my Engine project I am doing static linking to many third party libraries such as glew and glfw. This results in compiler errors in my Game project that says "cannot open source file "GL/glew.h" " etc... So do I have to do the static linking for all third party libraries again in the Game project (seems tedious) or is their a way to combine/merge them into the Engine.lib?
@shyammishra3568
@shyammishra3568 3 года назад
Hey , A big fan of your great c++ sessions. can you please make one video on VSTest or native c++ unit testing in visual studio? This will be a great subject to make a video. Looking for hearing soon :)
@slayer5171
@slayer5171 5 лет назад
Briliant video. Thanks..
@jackthehammer2245
@jackthehammer2245 6 лет назад
Thanks for your video! Any chance to cover V-table in your future video? especially the internal behavior in memory. Also when talking about V-table it would also be nice to cover multi inheritance(evil diamond that people like to stay away) and the internal behavior. It is quite confusing but also interesting topic. Thanks again for your cool video! Hopefully could see more topics on C++ Optimization in future! (You probably have a lot to cover since this is c++.....Take your time!)
@JuWnL
@JuWnL 4 года назад
Really helpful
@thetankgarage
@thetankgarage 6 лет назад
I find it absolutely astonishing how vague and insanely complicated learning compiling with C is. You'd think having had over 45 years someone would have created a workflow that's actually readable. I can learn any programming language in 2-3 days but after 4 days now I'm still no where near closer to actually compiling a usable .lib file or where it actually goes in my project or anything. I think I'm actually more confused than helped by all the reading about Visual Studio I've done.
@QuoteVG
@QuoteVG 6 лет назад
After you make the reference to Engine, do you still need to keep the additional include directory that you added at 6:20?
@YoqubDavlatov-fb2br
@YoqubDavlatov-fb2br Год назад
You are "answers" to all of my questions))
@chainonsmanquants1630
@chainonsmanquants1630 3 года назад
Thanks
@piotrlenarczyk5803
@piotrlenarczyk5803 3 года назад
Thank you for video.
@shohamziner
@shohamziner 3 года назад
very helpful. thx
@F1nalspace
@F1nalspace 6 лет назад
Like it, even though i knew all the stuff. But confirming it is kind of satisfying ;)
@97Giorgos97
@97Giorgos97 6 лет назад
Great!
@ProjectPhysX
@ProjectPhysX 6 лет назад
Can you make a video on how to setup CUDA in VS 2017?
@VinayKumar123
@VinayKumar123 3 года назад
thank you
@raphaelkuttruf
@raphaelkuttruf 3 года назад
A similar tutorial for DLLs would be great. Maybe a C# Windows Forms App with C++ DLLs in the backend? :)
@FelipeMendez
@FelipeMendez 6 лет назад
do audio next, what are good options for cross platform audio libraries and what techniques exist to manage audio effects and so on
@adambeardsley7909
@adambeardsley7909 6 лет назад
Dose the lib file have to be Inside the project solution for this to work. I have tried creating static library in a separate project but carnt seem to get it to link.
@Alexander-lc8oe
@Alexander-lc8oe 5 лет назад
Please make a video on Makefiles and CMake! Keep up the great work!
@LegacyCS2
@LegacyCS2 6 лет назад
You uploaded this the 18th of October. It's the 29th today. Are there gonna be anymore videos in the series? or have you lost interest? Great series btw, I've learned SO MUCH. Thank you! :D
@TheCherno
@TheCherno 6 лет назад
lol yes of course there will be more videos, it hasn't even been two weeks, relax :)
@LegacyCS2
@LegacyCS2 6 лет назад
I'm relaxing. Sorry for hurrying you. I've just noticed that between each other vids there has been less than a week between them, sometime there were a new vid everyday. I was just curious. :'D
@billroberts4534
@billroberts4534 3 года назад
I follow your instruction and it works beautifully. However, when I add a header-only file to the static library project there are numerous errors - such as string not defined. How can I add an external header-only file to a static lib project?
@riccardostresa
@riccardostresa 3 года назад
I have a question: but what about ? Isn't that a library too? We have added the header file to cpp, but where is the library itself? Is it something that is dynamically linked like dlls? It seems to me that it is a sort of "special" link also because my program runs on another pc that does not have Visual Studio installed. I'm confused.
@KayVerbruggen
@KayVerbruggen 6 лет назад
Is this also the setup of the game engine series?
@teddychen1709
@teddychen1709 Год назад
I made it, half way of the series!
@franejelavic
@franejelavic 6 лет назад
Hi Cherno, First of all thank you very much for this series and everything you do here. One question regarding the above. If you would make a project to be build on someone else's computer, is all of this defined in a makefile? How do you keep this consistency of linking the right static library and keeping absolute paths unchanged when you ship your project and aren't sure if the customer or someone who works with you has VisualStudio? Sorry if this is basic just need to wrap it all in my head. Thank you in advance and best regards.
@ABCo-ABMedia
@ABCo-ABMedia 4 года назад
This is a really late reply, and probably not helpful anymore, but a couple of things to mention here. For the "customer", they won't notice. These are static libraries here, which means that when the application gets compiled they essentially become a part of the executable. So, you just give the "customer" the executable file, and it should just work. However, if you give the actual code to someone, things are a bit different. No, there is no makefile, because this is using the VC++ compiler, and all of these settings are stored inside the "vcxproj" file, so, if they have Visual Studio, and you give them the whole folder containing the "sln" file, all of the settings will transfer over. But, of course, they need Visual Studio. You could make a makefile yourself if you want.
@akshaynaik4888
@akshaynaik4888 6 лет назад
Please make a detailed video on c++ templates
@Fragtex_CN
@Fragtex_CN Год назад
wonderful video!!!!! appreciation from China!!!😉
@seino__
@seino__ Год назад
Yes it was veri helpful. Appreciation from India
@ashutoshrautela3454
@ashutoshrautela3454 6 лет назад
Templates... Please make an in depth video on templates
@Xhyllos1
@Xhyllos1 2 года назад
Does the library have to be of the same language as the main project? If not, how can we use a library written in a different language? Thanks for the tutorial. It clarified a few things for me.
@Wimachtendink
@Wimachtendink 4 года назад
Well don't I feel stupid, watch the whole video is the moral of this comment I guess...
@Samuel-wl4fw
@Samuel-wl4fw 3 года назад
thanks a lot man
@ElTsakoss
@ElTsakoss 4 года назад
You are the best
@angucbac2655
@angucbac2655 6 лет назад
Thanks for your sharing. Would you introduce about some Design pattern in C++.
@Popart-xh2fd
@Popart-xh2fd Год назад
All this process of defining source folder is done on Visual Studio program, it would be nice to see how it's done at the configuration file level so that the same can be done on other programs like de Visual Studio Code.
@BinkiklouGaminglol
@BinkiklouGaminglol 5 лет назад
You talked about make a similar video but with a DLL ? Will you ever do it ?
@tzgardner
@tzgardner Год назад
8:29 That's interesting, I didn't know VS connected the libs from all your projects automatically. I thought you had to add them in the Linker under additional library Directories.
@Narblo
@Narblo 6 лет назад
I did this with my project but i am having truble with my only nested namespace , it wont get recognized idk why :(
@user-br6jl1hh7v
@user-br6jl1hh7v 5 месяцев назад
Do you have a video that does the same thing but create an import library and a DLL to install with the app?
@imanmehrabinezhad3844
@imanmehrabinezhad3844 8 месяцев назад
I watched all three sequenced videos on linking in C++. While things are much more clear to me now, I was wondering if you can make a video about using CMake as well. I ask this because I tried linking Armadillo for example and could not solve the errors.
@shavais33
@shavais33 3 года назад
What about the libraries that the engine links into it? In my experimental project, even though I have my "engine" set up as a project reference in my "game", I still have to link my game against all the same external libraries that my engine links against, or I get a whole bunch of unresolved externals when I go to build my game, even though those externals are linked statically into the engine, and the engine is a static library. The thing is, the engine.h file includes bunches of .h files in the engine which in turn include external library headers. So I guess to avoid this, I'd have to somehow not reference any external library headers in the engine headers that are included in the engine.h file, is that right? If you have public class members that are, return or take as parameters types that are defined in external libraries, what do you do? Define wrapper types for all those types? But the definitions for those types is going to have to be somewhere? The consumer of the library is going to have to know about them, so..? That doesn't solve the problem? Is there no way to just tell the linker that all these external libraries are in engine.lib? I guess to successfully wrap an external library into an internal library, you have to completely avoid exposing any of the wrapped libraries types. Which means your public interface can't use any of the types exported by that library. I suppose I know this already, but. I guess I was naively hoping some part of all the modern schiz would take care of this for me.
@ilieschamkar6767
@ilieschamkar6767 Год назад
did you find a solution for this?
@VulcanRavenPL
@VulcanRavenPL Месяц назад
It's soo much different than the videos, no macros like #ifndef etc. @Cherno is that few thing we really need ? That's awesome. On Microsoft tutorial there is bunch of stuff. Why yours better ? Could you give me some explanation?
@sunday-thequant8477
@sunday-thequant8477 11 месяцев назад
You have some guide to do all this from CMake?
@disenchantedcardgd9878
@disenchantedcardgd9878 3 месяца назад
Y'all can take this a step further and do it in cmake, it's objectively better for bigger projects and gives You more control.
@CR33D404
@CR33D404 10 месяцев назад
May i ask how is this better than just writing all the stuff (definitions and declarations) in a header file and then include it whenever we need it?
@untitledisdead
@untitledisdead 2 года назад
I keep thinking hes gonna hit his hand on that cactus with all that arm flailing body language
@napalmpig3772
@napalmpig3772 4 года назад
I feel like Neo downloading Kung Fu
@iamjovani
@iamjovani 6 лет назад
Please cover exception handling or template classes and functions
@johncyestibeiro2609
@johncyestibeiro2609 5 лет назад
Why did you include "Engine.h" in Engine.cpp? Shouldn't it work without that step as well?
@poryg5350
@poryg5350 4 года назад
Not exactly. The compiler does not care about naming, naming is only useful for us people. So if you don't include Engine.h inside Engine.cpp, then the function declaration inside Engine.h could be treated as a completely different function from the one inside Engine.cpp. For this reason some compilers even throw an error when you define a previously undeclared top level function in a program that's not meant to be executable.
@Melobotica
@Melobotica Год назад
How would I make the library work for Debug and Release mode?
@CashewOCE
@CashewOCE 6 лет назад
This is great and all but how do you go about this using a different IDE or even just a basic editor like Sublime Text, Notepad++ etc?
@pradyumnkejriwal3007
@pradyumnkejriwal3007 6 лет назад
Wally Nut how do you even compile the code with simple text editors
@402ExpectationFailed
@402ExpectationFailed Год назад
Hi, sorry for the very late reply, I'm sure you'll have all figured it out by yourself by now, but maybe it will be useful for someone in the future. I was in your same situation because I am on Ubuntu and I decided to go raw with just notepad and g++. So I made some research and came up with something. This is for linux + notepad + g++ though, idk about windows, maybe there's something analogous: First, I tried to replicate the filesystem like this: engine/ |_ engine.h |_ engine.cpp game/ |_ application.cpp I then positioned myself in the engine directory: 1 - I generated the object file from engine.cpp > g++ -c engine.cpp After this, engine.o file should pop up in the directory 2 - I created the library file from the object file using linux's command for creating static libraries, ar > ar rsv engine.a engine.o After this, engine.a file should pop up in the directory, which is the actual library file 3 - I then positioned myself in the game directory > cd ../game 4 - Finally I compiled application.cpp linking it to the library. The parameters are: -I : (capital i) the relative / absolute path for inclusion of the header file (similar to what he did around 6:06), in our case it's the engine directory -L : the relative / absolute path to the library file (similar to what he did around 8:00), in our case it's the engine directory -l : (lowercase L) the name of the library file, in our case it's engine.a > g++ -I ../engine application.cpp -L ../engine -l:engine.a After this, the executable a.out should pop up in the directory and do whatever is in the main() function I used relative paths because I don't need it to be "a stable setting" since there's nothing automated in here.
@Piplodocus
@Piplodocus 5 лет назад
I spent the first 10s trying to work out if that is an Ibanez RG and a Manson. 🤔
@geekofthewild600
@geekofthewild600 2 года назад
How would I do this using G++ or CMake?
@Djzaamir
@Djzaamir 6 лет назад
implement some algorithms , specially those which involve pointers
@abhishek.rathore
@abhishek.rathore Год назад
How do I share this library to others? I mean how can they use it in their projects? By sharing the Engine folder? Does this work even if they don't use Visual Studio to link or not even Windows?
@akshayraut3719
@akshayraut3719 6 лет назад
you can do more object oriented things like namespaces, exception handling etc. Also you made a video on vectors, then u should also do other data structures specially those which are in the STL for c++. These are my 2 suggestions. And u r doing great so far and i follow u everywhere dude(not in real but virtually :p)....
@zonico5826
@zonico5826 6 лет назад
So with let's say C#, it works just like this? Noice!
@ABCo-ABMedia
@ABCo-ABMedia 4 года назад
Um, no. For C#, you would have to use a DllImport on a DLL file, which is a DYNAMIC library, in this video, he describes how to use STATIC libraries... Static libraries don't and physically can't exist for C# since it's practically interpreted after it's compiled to IL. So, technically, if you choose DLL in the list instead of LIB when he changed the project's properties, then added a C# project to the solution, set the build dependencies and set the library to copy to the C# bin directory, and used "DllImport" attributes within the C# code to access things in the DLL, then, yes, you could. Just not QUITE in the way he showed it.
@ilieschamkar6767
@ilieschamkar6767 Год назад
how can I include in game all the third party includes of Engine ?
@artinzareie4806
@artinzareie4806 9 месяцев назад
Can you please make a video on how to do this with CMake?
@dXXPacmanXXb
@dXXPacmanXXb 6 лет назад
What if I make a new solution where I also want to use a library/engine I made in a previous project?
@MuriloFernandoFloriani
@MuriloFernandoFloriani 3 года назад
Did you get an answer? I'm thinking about it too...
@javadmahdavi1151
@javadmahdavi1151 Год назад
how can I add header-only library in visual studio
@harshtiwari9588
@harshtiwari9588 6 лет назад
IDK why I am Getting this error can anyone help me please!! 1>Application.obj : error LNK2019: unresolved external symbol "void __cdecl engine::PrintMessage(void)" (?PrintMessage@engine@@YAXXZ) referenced in function _main 1>C:\Dev\Cherno(C++)\Game\Debug\Game.exe : fatal error LNK1120: 1 unresolved externals 1>Done building project "Game.vcxproj" -- FAILED.
@sing759
@sing759 4 года назад
if you are having this error while you right click and building your application.cpp.... just Ctrl+F7 instead of right-click build You can successfully build your Game project.
@ycombinator765
@ycombinator765 Год назад
K A A N Z O L is
@bloodwolf8307
@bloodwolf8307 4 года назад
cool
@vertigo6982
@vertigo6982 5 лет назад
10:17 dont you have to recompile for the std::cin.get() to work?
@xeliani.7809
@xeliani.7809 4 года назад
Late answer but, When he typed it and ran the program, it recompiled automatically then ran the instructions of the program
@Mohammed24441
@Mohammed24441 3 года назад
What about header-only libs using cmake.
@remi.scarlet.
@remi.scarlet. 8 месяцев назад
How do you build cross platform? I mean do you build Hazel exclusively for windows? Do you not plan on having Linux (Android) support? Because id like to know how you set up a cross platform project, especially cause of Android... (.so) Do you use CMake?
@marflage
@marflage 5 лет назад
How does Application.cpp know i has to compile Engine.cpp as well? I mean only Engine.h is included in Application.cpp and not Engine.cpp, too.
@xrafter
@xrafter 4 года назад
Compiler
@yesveryprofesionalnameyes6055
@yesveryprofesionalnameyes6055 5 лет назад
Now , how to do it in dev c++?
@olliert4840
@olliert4840 4 года назад
If we change the name of engine to WHAT NOW?
@supakm
@supakm 6 лет назад
it will be even better if you have subtitle
@lilyvmax6642
@lilyvmax6642 2 года назад
I love you
@michabiegaj1612
@michabiegaj1612 4 года назад
When I compile library project I cannot see .lib. I don't know why
@destroyerofchalk6456
@destroyerofchalk6456 3 года назад
what if dll, cou you give a tutorial about "Making and Working with dll in C++"
Далее
How to Deal with Multiple Return Values in C++
17:20
Просмотров 203 тыс.
Using Libraries in C++ (Static Linking)
18:43
Просмотров 427 тыс.
это самое вкусное блюдо
00:12
Просмотров 1,2 млн
WHY did this C++ code FAIL?
38:10
Просмотров 177 тыс.
Stack vs Heap Memory in C++
19:31
Просмотров 553 тыс.
Should you learn C++?? | Prime Reacts
20:29
Просмотров 321 тыс.
Harder Than It Seems? 5 Minute Timer in C++
20:10
Просмотров 146 тыс.
How to write your own code libraries in C.
9:57
Просмотров 134 тыс.
why do header files even exist?
10:53
Просмотров 369 тыс.