Archived

This topic is now archived and is closed to further replies.

Fenix_ufo

Linker errors on C++ compilers

Recommended Posts

Back when I used Borland C++ Builder 1.0 (yes, 1.0) I often got linker fatal errors when trying to compile, for no apparent reason. If I tried to compile on an other computer, the same code would work perfectly. Sometimes I was able to get it to compile on my computer by rebooting, but most times I had to compile it on an other computer, paste the new source and exe files over the old ones, and then if I were lucky C++ Builder would grant me the privilege of allowing me to work with my code and compile it... for a while. Now, I have moved to Visual C++ 6.0, and the same thing happens. I downloaded the directx SDK and all its examples compiled without problems, however if I write some code of my own it will give me several linker errors. Furthermore, if I copy and paste the code of one such example into a new project it will also give me linker errors. Any idea about the source of my computer''s curse? Is it a new plot by Microsoft to stop people from learning programming? For the record, I''m using Win 98 SE, not ME. Fenix_ufo

Share this post


Link to post
Share on other sites
quote:
Original post by Fenix_ufo
I downloaded the directx SDK and all its examples compiled without problems, however if I write some code of my own it will give me several linker errors. Furthermore, if I copy and paste the code of one such example into a new project it will also give me linker errors.

Er ... you did remember add the necessary DirectX libraries ( dxguid.lib, dinput8.lib, d3d8.lib, etc.) to the list of libraries to link to, right?

Share this post


Link to post
Share on other sites
if you have any linker errors, make sure you have included all necessary .lib files into your project. In Visual C++ 6.0, there are settings for your project where your program will link (when compiled) to some .lib files specified in that settings.

Some default .lib files are already included, such as kernel32.lib, user32.lib, etc, so when a person wants to learn how to make a simple windows application, he does not have to deal with this. But other .lib files aren't. DirectX .lib files are not included by default, so you have to include them. Check your project settings.

This is an example (directly taken from MSDN) when to include a .lib file:

IDirect3D8
....
Requirements
Header: Declared in D3d8.h.
Import Library: Use D3d8.lib.

see that d3d8.lib, that's the .lib file that you have to include to your project in you want to use IDirect3D8.

Just realized, I hope you don't get confused with the word "include" I'm using here: I don't mean #include.



My compiler generates one error message: "Doesn't compile."
-Albert Tedja-


[edited by - nicho_tedja on July 15, 2002 2:28:15 PM]

Share this post


Link to post
Share on other sites