LNK2001 LNK2019 error

Started by
15 comments, last by MaxDemian 15 years, 8 months ago
I did a new proyect again and added the files (cApp.h and cApp.cpp)to the proyect, now it goes with no problems :), but I don't want to add cApp.h to my proyect. I mean, when u use #include <windows.h> u dont have to add windows's header to ur proyect :/ How can I solve it?
Advertisement
Quote:Original post by MaxDemian
I did a new proyect again and added the files (cApp.h and cApp.cpp)to the proyect, now it goes with no problems :), but I don't want to add cApp.h to my proyect. I mean, when u use #include <windows.h> u dont have to add windows's header to ur proyect :/ How can I solve it?

Well, no, you don't have to add it to your project, but then again, you didn't write it. And it's not specifically part of your project.

But, yes, there's a way to do this. What steps did you take to add the path to the project in the first place? The usual way to do this is to "Add existing item..." when right-clicking on your project's source/header folders in the solution explorer, and then either specifying relative paths to these files when you #include them, or by adding the path under "Additional include directories" in your project's setting.
Oh well, I didnt add the path in the proyect exactly. I opened VS.Net then: Menu -> Tools -> Options.

In the dialog I press on "Proyects" and there u can add directories, so I did it. I did it in this way because I wanted to use this path for all my proyects.
Quote:Original post by MaxDemian
Oh well, I didnt add the path in the proyect exactly. I opened VS.Net then: Menu -> Tools -> Options.

In the dialog I press on "Proyects" and there u can add directories, so I did it. I did it in this way because I wanted to use this path for all my proyects.

Ah, I see. The problem is that VS can't couple any non-compiled code with this header file without knowing any more about it. You could either add the .cpp to your project (which you don't want to do), or add the library file. In that case, you'd need a pre-built .lib file that corresponds to cApp, which, if you want to keep it apart from your current project, you'd probably make in a separate solution/project configured as a static library. (You could also make it a DLL, but that doesn't seem like what you're after.) You'd then need to add that directory in the same manner as you did before (except under "Library files").

If you need any more direction, just say which option you're going to go with and what's stumping you ;).
I would like to do it in a DLL. So, what should I do?
:)

PS: Is there any advantage between dll from lib or lib from dll?
Quote:Original post by MaxDemian
I would like to do it in a DLL. So, what should I do?
:)
I'd start with google on this one, never having jumped into it. Even just on gamedev, there are some helpful looking results, such as this and this.

Quote:PS: Is there any advantage between dll from lib or lib from dll?

A static library is guaranteed to work. It's compiled into the executable, so you don't have to distribute extra files with your program, though it does cause the .exe's size to increase, understandably. However, if you change any part of it, you'll have to recompile any projects that use it. Also, if sending updates to clients, for example, you'll have to either 1) patch an executable or 2) send an entirely new one.

A DLL is nice in that, if you update it, you don't have to recompile everything that uses it, since the program loads it dynamically and trusts it to be there. Due to the dynamic loading, there's some trickiness in getting it to work (see the links above). If the .dll isn't there, then your program will refuse to work. This means that you'll have an extra file or few to distribute with your program. However, when updating it, all you have to do is update the .dll, not the entire executable.

Oh I see. Thank you very much for helping :)) I will read those post :D

This topic is closed to new replies.

Advertisement