Using Dynamic Libraries in C++

  Рет қаралды 231,052

The Cherno

The Cherno

6 жыл бұрын

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

Пікірлер: 191
@medvfx3370
@medvfx3370 6 жыл бұрын
this is literally the meme about programmers that goes it's not working, why? it's working, why?
@TheSpacecraftX
@TheSpacecraftX 3 жыл бұрын
"The rest is trivial and left as an exercise for the reader."
@militardeforcasopostas2559
@militardeforcasopostas2559 2 жыл бұрын
it's not working? other programmers: Too Bad!
@mohamedmostafa396
@mohamedmostafa396 4 жыл бұрын
damn 3 years now and no one answered the question 😂😂
@Lelouch-vi-Britania
@Lelouch-vi-Britania 4 ай бұрын
replying you after 3 years few have answers this but noone got pinned lol
@user-vf2gt1le4q
@user-vf2gt1le4q 3 жыл бұрын
If you use lib + dll,you don't need __declspec(dllimport) because all the functions or variables you wan't to import have defined in lib as pointer;but if you use LoadLibary API to import dll, with __declspec(dllimport) you can tell the compiler which function or variable you want to import, it will reduce the import time
@vertigo6982
@vertigo6982 5 жыл бұрын
I see no pinned comments.. no one answered it correctly?
@NycroLP
@NycroLP 5 жыл бұрын
I think people did but he doesnt care I guess.
@serbastshexany7498
@serbastshexany7498 4 жыл бұрын
Am up writing idk perfect English fluently thxs
@drisicus
@drisicus 4 жыл бұрын
​@@NycroLP I like the content of this channel but the guy is not consistent, he has series unfinished, there is no schedule of videos... I mean, he does this because he wants, so ok I guess
@bulentgercek
@bulentgercek 4 жыл бұрын
@@drisicus Are you serious? How is he not consistent? He got 90 videos on this playlist and still keep doing it. Lots of people learned tons of the information from him. If you think you can do better go for it I'll follow you.
@gideonmaxmerling204
@gideonmaxmerling204 3 жыл бұрын
@@bulentgercek bro, this was not meant as an attack towards him and you are being illogical. Cherno said he would pin a comment but he didn't, that's all this is about.
@muhammadtaimourafzal5285
@muhammadtaimourafzal5285 3 жыл бұрын
cherno is a blessing for programmer community. awesome tutorial
@joachimolsson9497
@joachimolsson9497 6 жыл бұрын
This is because the DLL still has an IAT, Import Address Table. It will still load the functions from the IAT, but as Yuval said if you specify it as import when compiling the compiler will generate imports as imp__func_decl and it will do optimizations to ensure import is efficient. However what hasn't been said yet is this is only optional for function declarations so if you use public data members there is no IAT entry for them, and you need dllimport or else the data will be local to the compilation unit or compiling program depending on what other modifiers are used.
@anonymoussloth6687
@anonymoussloth6687 2 жыл бұрын
I am sorry but I have no idea what u said. Can u provide any resources that explains this in detail? Also, any resources that explain linking stuff more
@ksawery6568
@ksawery6568 5 жыл бұрын
Absolute legend! I kept getting .dll missing errors, and this solved it.
@arunkumaran5522
@arunkumaran5522 6 жыл бұрын
Thanks for the video, most of the videos posted in KZbin have similar contents. But yours is really interesting and felt I have learnt something new. I am currently try to do something with depth camera, since the technology is something advance its hard to find tutorial online. So, thought of digging deeper into every components of C++ and start doing the project by myself. You saved me!!!! thanks for the help...
@barbosikd
@barbosikd 5 жыл бұрын
You literally saved me. Thank you for your work!
@danielkrajnik3817
@danielkrajnik3817 3 жыл бұрын
the original Daniel
@Karuska22ps
@Karuska22ps 2 жыл бұрын
@@danielkrajnik3817 we found him.
@crush3dices
@crush3dices 3 жыл бұрын
Concerning the __declspec(dllimport), if we dont set it the compiler compiles the function call glfwInit(); to something like call glfwInit inside the object file. The linkers job is to resolve this. If we don't add the __declspec(dllimport) then the linker generates something like call 0x4000000 which directs the flow of the program to a function thunk. A thunk is something like a dummyfunction without ret statement at the end which simply jumps to another address. This thunk could look like jmp DWORD PTR __imp_glfwInit and the pointer __imp_glfwInit will then be set when the dll is loaded into memory using the IAT to point to the correct function. On the other hand, if we set __declspec(dllimport) we explicitly tell the compiler at compiletime that we want to use a function inside a dll. Thus we get the asm code call DWORD PTR __imp_glfwInit again __imp_glfwInit beeing set at runtime through the IAT. This saves the thunk memory and the jmp instruction.
@mohammedjawahri5726
@mohammedjawahri5726 3 жыл бұрын
nicely explained, cheers
@anonymoussloth6687
@anonymoussloth6687 2 жыл бұрын
Can u please recommend resources that explore this in more detail?
@crush3dices
@crush3dices 2 жыл бұрын
@@anonymoussloth6687 search for "importing functions using declspec dllimport" inside the microsoft docs
@SpecialAgentDaniel
@SpecialAgentDaniel Жыл бұрын
Thank you for this.
@danichigokun
@danichigokun 4 жыл бұрын
Thanks so much, I tried to install a library but I didn't even know how to do it, but with your help I did it and I learn about it :)
@AgentM124
@AgentM124 6 жыл бұрын
Because you already linked the static library that came with the dll with all the declarations of functions within the dll, it knows where to look for them, except it's maybe slightly less efficient.
@yltfy
@yltfy 4 жыл бұрын
I'm new to this, but I guess this is the right answer.
@cprn.
@cprn. 2 жыл бұрын
Header. He linked and included the library header file. Not the library itself (he did dynamically linked the library itself but it doesn't matter for this answer).
@bulentgercek
@bulentgercek 4 жыл бұрын
8:38 That french throat at "exactly" killed me :D
@Gaelrenaultdu06
@Gaelrenaultdu06 5 ай бұрын
I'm french and i have no idea how this is french xD Sounds more arabic.
@SirusStarTV
@SirusStarTV 5 күн бұрын
He always pronounces exactly as egzakhtly, like russian Х
@smileynetsmileynet7922
@smileynetsmileynet7922 3 жыл бұрын
With MINGW, you can link the standard library statically or dynamicly essentially.
@leynenslucker2991
@leynenslucker2991 4 жыл бұрын
I am currently binge watching this and one thing that amazes me: The hair dude. How did he manage to mess up a hair within 10 days????
@marksladen2901
@marksladen2901 4 жыл бұрын
lol
@laad
@laad 6 жыл бұрын
I was one of those asking for hw/challenges. I'm glad you started doing that!
@almirsmailovic3354
@almirsmailovic3354 3 жыл бұрын
Hello Friend
@wezo13
@wezo13 8 ай бұрын
This has been really helpful, thank you
@friedrichwagner8716
@friedrichwagner8716 2 жыл бұрын
Me: It's not working, why? The Cherno: It works, why? Todd Howard: It just works!
@junyangliu4812
@junyangliu4812 Жыл бұрын
I followed the file configuration in your previous video and my .exe file is in the project/bin/Win32/Debug, so I need to paste .dll file into this directory and it worked. Actually many places have the .exe file and only this one work. Thanks!
@AmeshaSpentaArmaiti
@AmeshaSpentaArmaiti 6 жыл бұрын
my guess is because the functions are still defined in the library even though the actual code is in the dll.
@djskippimusic
@djskippimusic 6 жыл бұрын
Hey Cherno! I had a question, I've been trying to figure out. I was curious if you could help c: I've been studying the Vulkan API, I dunno if you've looked into it at all; however, the backbone of the API is called the Loader, which you link against when you link Vulkan. The Loader is responsible for routing things to the right places, and handling system compatibility. The Loader has different functions for different systems. It can handle processing the functions for you; however, it also gives you the ability to retrieve the function pointer for the appropriate function for that instance, and mapping them to a dispatch table. They do this to mitigate using the Loader as a stage of overhead unless necessary I don't expect help with the Vulkan side of things, but I was curious if you could help me fully wrap my head around dispatch tables and function pointers to external libraries. I've done some searching and found that you can map functions to values using the std::map. In a situation like this how would you go about populating the appropriate data though? Does it require micromanagement? I feel it's kind of similar to the content in the video, though with Vulkan they added a layer inbetween the library and the application to handle system dependencies. I feel this might be something useful to understand in general if it helps with cross compatibility. I appreciate any help you can give c:
@stefh8644
@stefh8644 2 жыл бұрын
Great lesson! I did not find the next video for learning how to build a DLL working at Run Time, which one is it?
@xMudball12x
@xMudball12x 3 жыл бұрын
In dynamic linking, the g++ preprocessor gets all the information that the Windows dynamic linker needs to link whatever DLL is needed at runtime. At compile->assemble time, the DLL is only referenced in terms of modification information in the binary information generated by the preprocessor, so the assembler is blind to the DLL itself, until runtime, when the linker finally calls the information it needs from the preprocessor. In the static version, the linking step simply happens at the compile time, because the assembler gets all the information it needs from the statically linked file at compile time. This is why the dynamic version only works when you tell the preprocessor that it is working with the dynamic linker. Is this correct?
@siddharthchauhan1129
@siddharthchauhan1129 3 жыл бұрын
I never flunked any C++ interview.. (technical + theory) since I started learning C++ from you. Design rounds are some other headache though
@alisonrae
@alisonrae 3 жыл бұрын
Previous video: new haircut This video: crazy hair Me: You are a wizard, Cherno!
@mehdinasiri3022
@mehdinasiri3022 4 жыл бұрын
thank you very much this movie was very helpful for me
@masihkhodabandeh508
@masihkhodabandeh508 4 ай бұрын
Answer to the last question raised in the video: Because we statically load that *dll.lib library which does all things that is necessary for dynamic loading for us.
@altSt0rm
@altSt0rm 2 жыл бұрын
"Hey, my name's The Cherno and welcome back *CRACK* to my C++ series."
@hoen3561
@hoen3561 2 жыл бұрын
"Hey my name is the chana and welcome back to my estate plus plus series" XD
@Xxp0r
@Xxp0r 6 жыл бұрын
Because you're already linking against a .lib file that has all the pointer definitions defined.
@pulkitjoshi6196
@pulkitjoshi6196 3 жыл бұрын
so what about instance of the DLL in main memory? Do we have multiple instances of these library in main memory while 2 programs use them ?
@serbastshexany7498
@serbastshexany7498 4 жыл бұрын
Thxs but i can’t understand you without subtitles thxs alot amazing vlog
@themcscripter2111
@themcscripter2111 2 жыл бұрын
When you statically link the lib it doesn’t define glfw_dll because it already has all the function declarations for it during compile time. When you define this macro, it still knows where to look for the declarations; inside the dll at run time.
@nayabzsharief6736
@nayabzsharief6736 5 жыл бұрын
Hi cherno. Need some help. I have one c++ dll file . I want to use this DLL into c# to create windows form application but when I try to load through add reference I get error. I tried another way by using system.runtime. interopservices in that DLL_import in built function is there but in my DLL I have function which takes one argument as structure member when I call that function it says undefined member ( it is not able to find that structure). So can please provide some solution with example where u have c++ DLL which contains one function and has structure argument
@serkanozturk4217
@serkanozturk4217 Жыл бұрын
Personal Notes: - Static linking happens at compile time, dynamic linking happens at runtime (better to learn usage for linux and cmake)
@haydarjohn
@haydarjohn Жыл бұрын
hey bro if you find great make tutorials can you send me too? Edit: BTW i watched your target following video. Which company do you work for in turkey if you are working.Just curious.
@luckyboy20021
@luckyboy20021 5 жыл бұрын
Thank a lot
@koungmeng
@koungmeng 5 жыл бұрын
My solution of the homework is: because we are using static linking, we don't need to use __declspec(dllimport). But if we are using dynamic linking, we might need to use __declspec(dllimport) to let the compiler know that the function is inside the dll file.
@starriet
@starriet Жыл бұрын
It is actually dynamic linking at the end, not static linking, because you need the dll file anyways. Unless you're specifically talking about the lib file accompanied with the dll file.
@zondaken
@zondaken 5 жыл бұрын
but how do I do that with the GNU Compilers? the way you show is IDE-based but how is it done when you compile on CLI?
@Demki
@Demki 5 жыл бұрын
If you are using mingw, so g++ (or gcc if you are compiling c), you need to add your include directories with "-I" and include library directories with "-L" and include the actual libraries with "-l". This is usually done with a makefile/cmake file to automate the process. The same is true if you are compiling with msvc's compiler through the CLI (except the API for specifying directories and libraries is a bit different), or clang (which afaik supports the same argument format as gcc/g++, or provides a binary that supports that argument format)
@fxchesscom
@fxchesscom 3 жыл бұрын
Hello Cheom Can it possible to package a winform in DLL and export the dll function for third party use? I do it done but error when I use the DLL. It's always happen below: 1.Winform show only when I import dll at the first time. 2.In third party journal, it always show can't find the function name in dll. About a winform in DLL am I right? Thank you very much.
@nikoszervo
@nikoszervo 6 жыл бұрын
Can you make a video about classes (or methods i don't really know) which they use this thing? I don't know what it's purpose is. For example: My_Class_Type *myVar;
@TheApoorvagni
@TheApoorvagni 6 жыл бұрын
Bro, I think you are referring to template programming. He has a video regarding it. search his series.
@kgravikumar
@kgravikumar 6 жыл бұрын
.h file would have __declspec declaration for the library. Is that the reason. Also would have been nicer if you could include the difference in memory size of executables in static and dynamic link library
@eyalpery8470
@eyalpery8470 4 жыл бұрын
Good video!
@massiveblackwood
@massiveblackwood 4 жыл бұрын
Wheres the difference between this and using loadlibrary which you talked about on previous videos? Anyway thanks alot for this series man
@themuchcoolman
@themuchcoolman 6 жыл бұрын
Defining GLFW_DLL is not necessary because when you call one of the functions in your program it links to the function in the glfw3dll.lib which then links to the function in the glfw3.dll.
@Ayush_singh_04
@Ayush_singh_04 3 жыл бұрын
Homework answer: GLFW does not provide any of the API headers .They are provided by your development environment
@ahmedtalaat27
@ahmedtalaat27 2 жыл бұрын
defining the headers is the reason cause dynamic lib way is using precompiled headers
@amingholizad
@amingholizad 2 ай бұрын
It is a trick question. It does bot matter if you define it beforehand or not. It is not checking whether it is defined (there is no #ifndef GLFWAPI). It will be redefined in the header file.
@yogeshpanzade5572
@yogeshpanzade5572 3 жыл бұрын
9:00 maybe some how static lib that we link for function declaration define it for us.
@platin2148
@platin2148 6 жыл бұрын
The question is could i make an application extensible through that mechanism? As i can load arbitrary dlls and runtime.
@davidste60
@davidste60 6 жыл бұрын
Yes, that's how VST plugins work in audio software, you have a folder full of .dll files.
@arthopacini
@arthopacini 6 жыл бұрын
please, make a tutorial about Setting up the glfw in mac and linux, thanks, your videos are Great!
@TeeDawl
@TeeDawl 6 жыл бұрын
Artho Pacini For Linux just get glfw and glew from your package manager. Then check which libs you need via pkgconfig and simply list them for gcc. Then you're done.
@peterarbeitsloser7819
@peterarbeitsloser7819 3 жыл бұрын
@@TeeDawl do you have a tutorial link or something?
@whitecola3265
@whitecola3265 3 жыл бұрын
I've watched the video "Macros in C++" and I spotted that GLFW_DLL has already been defined in the Preprocessor Definition. Is this the reason?
@suyogpathade4805
@suyogpathade4805 4 жыл бұрын
wht a grt explaination, now I know how's the static and dynamic dll works, now I can die peacefully. :)
@TheGreatMaverick
@TheGreatMaverick 4 жыл бұрын
Nice tutorial! I seem to get it, but in the end, something does not work for me. I have a library (namely Armadillo) with library files blas.lib and blas.dll. I supply a path to the library files "-L path/to/libs" and specify I want to use this library file, i.e.: "-lblas". There are two things I have a problem with: 1. When both files are present in the specified directory, how does compiler know which file (.dll or .lib) must be linked? In other words, how does the compiler distinguish that user wants to perform static or dynamic linking? 2. When I supply only .lib file, I expect that static linking has been done, so there should be no need for putting .dll library in the solution folder, however, it is not the case and the executable won't run properly. I will be glad for any feedback, thanks!
@santoshs4393
@santoshs4393 3 жыл бұрын
Please make a video on how to use c# library in a C++ library or C++ application.
@muhammadshahpaal6325
@muhammadshahpaal6325 2 жыл бұрын
My error is that myfilename.dll is missing, try reinstalling (same as yours) but when I place my dll file in debug with exe file of the project it gives me errors about VCRUNTIME and MSVC dll files...why is that?
@Ayush_singh_04
@Ayush_singh_04 3 жыл бұрын
Homework answer: we know that we have putted the dll in the folder that's why we don't need to define gflws_api
@jayateerthaguruprasad
@jayateerthaguruprasad 3 жыл бұрын
Hey.... Suppose dll returns STL container such as vector. Main gets that vector and assigns to a new vector. Both dll and exe compiled using same runtime library ( Multi Threaded Dll or MT) ,my exe crashes. But then when I compile using debug versions it works fine ....... Any idea how to fix this ? Basically I want to know how to return STL containers from dll to exe.
@erjuanjojj
@erjuanjojj 2 жыл бұрын
Great tutorials! What if I want to put my dll in some subdirectory of my executable, or if I have several search paths with the same dlls and it does not know where to look. Can I tell the executable to link to a specific dll and not other found? Thank you very much
@SirusStarTV
@SirusStarTV 5 күн бұрын
You can only provide dll name in implicit dll linking, the dll location should be in search path (%PATH% environment variable) beforehand. You can change %PATH% environment variable user/system wide or make a script that sets this path and then executes your program, because you can't change %PATH% before linking stage by an exe itself.
@chainonsmanquants1630
@chainonsmanquants1630 3 жыл бұрын
Thanks
@nrgamepoint3132
@nrgamepoint3132 3 жыл бұрын
May be that macros are included in that glf header file.😁
@xristosbart8217
@xristosbart8217 6 жыл бұрын
The dll.lib file did that declspec
@VincenzoR97
@VincenzoR97 5 жыл бұрын
that moment when 5:16 you shouldn't tell people they can't make it. tell us what could go wrong and what we can do to not make it go wrong
@ronnoni8301
@ronnoni8301 5 жыл бұрын
Can you please explain about MakeFiles and their implementations in Visual Studio?
@ciankiwi7753
@ciankiwi7753 3 жыл бұрын
afaik Makefiles are not needed when working in Visual Studio, as VS does that work for you. if you are working with the GNU compiler stuff where you compile your stuff from the command line then a makefile saves you the minutes of typing out commands.
@cprn.
@cprn. 2 жыл бұрын
If you're using VS with a *nix project you'll have to use a converter that takes the Makefile and generates a VS solution/project file for you but it rarely works since Makefiles can (and usually do) contain some arbitrary logic. This makes sense because if you don't need to automate something you'll end up with a pretty basic Makefile that is often not really needed (it'd help if you were editing your code in Notepad or equivalent but fully fetched IDEs often handle "standard" cases for you on-the-fly as in: generate in-memory Makefiles using a link-tables of known libraries and discard those Makefiles after compilation is done - its possible because to decide whether any given source file should be compiled or not it is enough to compare its last modification date with the creation date of its target/output file).
@chiragsingla.
@chiragsingla. 2 жыл бұрын
use cmake to generate makefiles
@dex6596
@dex6596 6 жыл бұрын
Is there any way how to make Visual Studio copy dlls to output directory automaticaly?
@agfd5659
@agfd5659 6 жыл бұрын
DEXIT yes
@jousboxx9532
@jousboxx9532 4 жыл бұрын
What's the music?
@tzgardner
@tzgardner Жыл бұрын
8:00 It's not clear to me why you would have if else statements for dllexport and dllimport in the same file. If you are using particular code to build a dll (hence using dllexport), how and why would you ever use dllimport here?
@dariomylonopoulos8462
@dariomylonopoulos8462 6 жыл бұрын
The static library glfw3dll.lib takes care of importing the dll data for you, if you didn't link that static library you would need to define GLFW_DLL, and would be able to use just the dynamic library glfw3.dll
@yuvalgamzon-kapeller5585
@yuvalgamzon-kapeller5585 6 жыл бұрын
Dario Mylonopoulos, actually if you didn't use the static library you would need to do a lot more. You would need to call LoadLibrary to load the dll and then call GetProcAddress to get pointers to functions from the dll. This is essentially what GLEW does. It loads functions from the driver's dll
@pramodbhandari9151
@pramodbhandari9151 4 жыл бұрын
You did define GLFW_DLL but you didn't add any reference to it so it really doesn't matter, the pointers from static dll library file are still the ones doing the job and thus nothing changes.
@stephenfreel899
@stephenfreel899 Жыл бұрын
all i want to know is if he ever plays the guitars in the background of these videos
@arunabhbhattacharya5314
@arunabhbhattacharya5314 Жыл бұрын
We do not need to use __declspec(dllimport) to link to the GLFW functions in a DLL file because the necessary import/export attributes are already included in the GLFW header files and source code.
@sephirapple7317
@sephirapple7317 10 ай бұрын
@arunabhbhattacharya5314 that's not quite correct. the GLFW header file does not contain all the necessary information to link to the DLL file alone. Although it does define GLFWAPI as __declspec(dllimport), this will only happen if GLFW_DLL has already been defined, else __declspec(dllimport) will not be selected from the #ifdef block! All the function pointers in the header are prefixed with GLFWAPI, which the preprocessor has to interpret based on the #ifdef block conditions If GLFW_DLL is NOT defined, then GLFWAPI is NOT interpreted as __declspec(dllimport)! Or, for example, if GLFW_BUILD_DLL is defined instead, then GLFWAPI becomes __declspec(dllexport) instead! We do not need to put __declspec(dllimport) in front of every function pointer in the header file, because GLFWAPI becomes __declspec(dllimport) when GLFW_DLL is defined! The real question however, is why do we not need to define GLFW_DLL to let the preprocessor know how to interpret GLFWAPI?? In other words, where is #define GLFW_DLL written so that we did not need to define it ourselves? And the answer is, as other people have said, GLFW_DLL is defined in glfw3.dll.lib, the static library which pairs with glfw3.dll, the dynamic library! This is why we do not have to #define GLFW_DLL in the project properties, because it is already in glfw3.dll.lib and therefore when the preprocessor reads the header and gets to the #ifdef for GLFWAPI, then it chooses to interpret any GLFWAPI prefix in the rest of the file as __declspec(dllimport) without us manually defining GLFW_DLL. Hope this helps to understand what is happening here!
@cipsasmiaumiau3773
@cipsasmiaumiau3773 5 ай бұрын
hello, I have a question, why are most people not using namespace std? Is this just preference or are there other benefits to it.
@CSDex
@CSDex 2 ай бұрын
It’s bad practice
@cipsasmiaumiau3773
@cipsasmiaumiau3773 2 ай бұрын
@@CSDex Yes, I understand that, but what is the reason for it? Why is it bad practice?
@mayankshigaonker8551
@mayankshigaonker8551 9 күн бұрын
@@cipsasmiaumiau3773 He has definitely made a video on it
@michaliskaseris2467
@michaliskaseris2467 4 жыл бұрын
Because the _WIN32 and GFLW_DLL are now both defined, the elif defined(_WIN32) && defined(GLFW_DLL) evaluates to true. Consequently, GLFWAPI evaluates to __declspec(dllimport).
@fr3ddyfr3sh
@fr3ddyfr3sh 4 жыл бұрын
Michalis Kaseris this is the correct answer!
@naserhamidi6386
@naserhamidi6386 3 жыл бұрын
challenge answer: With that, it is now static linking
@sparklexscrewyachivements813
@sparklexscrewyachivements813 3 жыл бұрын
coool
@user-qg8hi2th6k
@user-qg8hi2th6k 4 жыл бұрын
I have commented out the GLFWAPI's declaration but keep the"#define GLFWAPI",it still prints 1.
@danielkrajnik3817
@danielkrajnik3817 3 жыл бұрын
8:00 captions on
@kuroakevizago
@kuroakevizago 3 жыл бұрын
Please put the answer Cherno really need it :)
@kontent_king
@kontent_king 5 жыл бұрын
Plz make a video on C++ SQL Connector.
@byronwatkins2565
@byronwatkins2565 4 жыл бұрын
You are still linking to the glfwdll.lib library of stubs...
@bloodwolf8307
@bloodwolf8307 4 жыл бұрын
cool
@RK-on1br
@RK-on1br 5 жыл бұрын
yeah, exachktly
@gawarivivek
@gawarivivek 4 жыл бұрын
Because we have included "glfw3.h".
@boot-strapper
@boot-strapper 6 жыл бұрын
How do you do linking without a fancy IDE? I prefer command line and simple text editors. Most other languages have configs files for this kind of thing, what about C++?
@TheCherno
@TheCherno 6 жыл бұрын
You should really get used to using an IDE man, you might be okay on small projects but once you get to working on anything of decent size you won't be able to do it. That being said for MSVC look at the cl.exe command line flags: msdn.microsoft.com/en-us/library/f35ctcxw.aspx
@boot-strapper
@boot-strapper 6 жыл бұрын
I find that using IDEs leads people to not actually understand how the code all fits together. I do use intelliJ at work sometimes but I really prefer sublime text and the good ol' command line. Plus I use linux generally which has limited support for Microsoft products and IDEs. I've been attempting to use your lessons to build a game that I can compile to web assembly and run in the browser. Keep up the good work man, loving it!
@matt_7670
@matt_7670 6 жыл бұрын
@Kishore G. I've been using Emacs for school, and visual studio for anything I do as personal projects. I feel like emacs is such a pain to use (probably just inexperience), but it is much better than vim IMO. However, some of the most basic features seem to be missing (like going to the definition of a function). How do you enable that at work? Or do you end up just using grep all of the time? I had some luck using gtags and hitting m-., but half of the time it takes me to the wrong definition.
@Demki
@Demki 5 жыл бұрын
I know it's a bit of a late reply but... Generally the way to go about it if you don't want to use an IDE is to use make/cmake to automate the compilation. FWIW if you are using Visual Studio you can enable a more verbose build output which shows you the exact CLI commands used to build the solution. (Tools -> Options... -> Projects and Solutions -> Build and Run: set "MSBuild project build verbosity:" to "Detailed" or "Diagnostic", or if you prefer the log file - set the "MSBuild project build log file verbosity:" to "Detailed" or "Diagnostic"). If you are using GCC/G++ or clang then the command line arguments format are a bit different from MSVC's, but overall require the same stuff (specifying include directories, specifying library directories, specifying libraries). At that point you are better off making a makefile for any project that is a bit larger, which will allow you to automate the build process (you'd only have to type "make" in the command line to build the project). Basically an IDE makes the process of making a makefile easier (in fact visual studio uses a slightly different form equivalent to makefiles in its project files, but overall it achieves the same goal).
@susobhandas6143
@susobhandas6143 3 жыл бұрын
hey cherno bro -
@miguelhyto54
@miguelhyto54 3 жыл бұрын
8:45 idk men D: i came here to learn :v
@mikefochtman7164
@mikefochtman7164 Жыл бұрын
I'd just add a small comment. The second time you compiled your DLL, you didn't copy the new version over to where the .exe file lives. That means the second time you ran it, your exe used the older version of your dll. Moving the DLL should be made part of the build automatically with a custom build step. Someone new to DLL's can get frustrated when they make a change to the DLL code, hit 'Build All', and their change doesn't seem to work. Manually copying the DLL outside of VS means VS doesn't know how to update that copy. (go ahead, ask me how I learned this... lol )
@jakubpruher979
@jakubpruher979 5 жыл бұрын
What the hell is __declspec? I'm looking it up now, but damn! Might have said it, since this is a TUTORIAL!
@johnlime1469
@johnlime1469 4 жыл бұрын
I think I watched too many Chris Hansen videos because I keep hearing "pedophiles" instead of "header files"
@arungaurav7054
@arungaurav7054 3 жыл бұрын
where is the pinned comment?
@Ochenter
@Ochenter 4 жыл бұрын
Do I need a PC to do these lessons ? Thanks.
@Ochenter
@Ochenter 4 жыл бұрын
@Tintin Hello. Are you the real "Tintin" ? What is a mobile ? Thanks.
@user-iu9ph5ld2v
@user-iu9ph5ld2v Жыл бұрын
I even do not understand the question....
@ahmedtalaat27
@ahmedtalaat27 2 жыл бұрын
static linking uses ..lib + headers and more optimized way | dynamic linking uses ...dll.lib + ... .dll files but not optimized.
@Kramer-tt32
@Kramer-tt32 11 ай бұрын
I thought libraries had .so or .a files. What the heck is all this!?!... I'm so glad I use linux at my job every day
@docika86
@docika86 8 ай бұрын
What you have mentioned is the Unix/Linux analogies of dynamic( .so = shared object) and static library( .a - archive) file type extensions. This video above concerns the Windows related terminology(hence the author created and maintains a Win. video game engine and this tutorial series is connected to that).
@sleepyNovember_project
@sleepyNovember_project 10 күн бұрын
​@@docika86stfu no one asked
@SirusStarTV
@SirusStarTV 5 күн бұрын
That what using linux all the time does to mf.
@Garycarlyle
@Garycarlyle 4 жыл бұрын
Good video but would have preferred not to have to do homework. I didnt even do it in high school :)
@Garycarlyle
@Garycarlyle 4 жыл бұрын
Probably can tell by my bad written English LOL
@johnclasing4627
@johnclasing4627 2 жыл бұрын
Where's the pinned comment!?
@user-si9jy3zs1j
@user-si9jy3zs1j 3 жыл бұрын
no one answered the question, after 3 years :(. What's the secret anyway?
@abacaabaca8131
@abacaabaca8131 4 ай бұрын
Does anyone knows how to do this using g++. The AI i am consulting to atm does not tell anything about macro definition in the source code. I have three source files: 1. vec2d.cp 2. triangle.cpp 3. zone.cpp triangle.cpp depends on vec2d.cpp and zone.cpp depends on triangle.cpp and vec2d.cpp. My strategy: 1. compile all .cpp files into .o file command: Example: g++ -c vec2d.cpp -o vec2d.o g++ -c triangle.cpp -o triangle.o g++ -c zone.cpp -o zone.o 2. link the object files when there is usage into a single .dll file. g++ vec2d.o triangle.o zone.o -o zone.dll Cannot remember whether this is the command. Objectively, we want zone.dll 3. Write a consumer code that depends on zone.dll by including its respective .h files. for example, #include "zone.h" 4. compile the consumer code into .o file g++ -c consumer.cpp -o consumer.o 5. Link consumer.o to zone.dll g++ consumer.o -L. -l:zone -o program */Unfortunately i got linker error exception at this point because it cannot find zone.dll in the linker's search path.
@SirusStarTV
@SirusStarTV 5 күн бұрын
On which operating system do you use g++? If on linux there's no such thing as dll, it's windows thing. Linux has shared objects files with .so extension.
@alexreg78
@alexreg78 Жыл бұрын
We touch item$ Time... So.. Be course We r not Alone. Alien...
@kemptcode
@kemptcode 6 жыл бұрын
I wish I spoke australian.
@TutorialsWithGary
@TutorialsWithGary 6 жыл бұрын
John Doe î
@Gizego
@Gizego 6 жыл бұрын
English is 2nd language for me and i have no problem understanding
@LousyPainter
@LousyPainter 6 жыл бұрын
He was kidding... At least I hope he was.
@fatihakbas8529
@fatihakbas8529 6 жыл бұрын
Why? Are you going to make some tutorials in English using Australian accent?
@vertigo6982
@vertigo6982 5 жыл бұрын
The only Australian I know is "Fosters" is Australian for "beer".
@alexreg78
@alexreg78 Жыл бұрын
Lord) cash memory Free? U freak))
@strum007
@strum007 2 жыл бұрын
What is the answer? No comment has been pinned yet :(
Using Libraries in C++ (Static Linking)
18:43
The Cherno
Рет қаралды 428 М.
Homemade Professional Spy Trick To Unlock A Phone 🔍
00:55
Crafty Champions
Рет қаралды 60 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 26 МЛН
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 51 МЛН
Stack vs Heap Memory in C++
19:31
The Cherno
Рет қаралды 554 М.
Dynamic Arrays in C++ (std::vector)
14:14
The Cherno
Рет қаралды 372 М.
DLL vs EXE | Windows DLL Hell
8:10
The PC Security Channel
Рет қаралды 97 М.
BEST WAY to make Desktop Applications in C++
26:00
The Cherno
Рет қаралды 887 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 187 М.
I Rewrote This Entire Main File // Code Review
16:08
The Cherno
Рет қаралды 131 М.
Software Development with C++: Dynamic and Static Linking
8:54
CoffeeBeforeArch
Рет қаралды 3,7 М.
Static vs. Shared Libraries
11:00
Dave Xiang
Рет қаралды 64 М.
How to Deal with Multiple Return Values in C++
17:20
The Cherno
Рет қаралды 204 М.