Archived

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

How to deal with linking error?

This topic is 5127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If there''s any error in my program during the compiling time, I can fix it according to the compiler''s hint easily, but sometimes the error happens during the linking time, and I felt I can do nothing with it So usually what mistake may result in a linking error? Is there any general way to deal with it? Thanks!

Share this post


Link to post
Share on other sites
Linking errors are usually due to

* Duplicated symbol (function, class, variable, constant...)
* Missing symbol
* Mismatched compiler settings in between object files.

Fixing them is only a matter of figuring out why a given symbol hasn't been defined once and only once in all the various object files and libraries you're linking together.

* don't define variables or non-inline, non-templated functions in header files
* make sure you link all the right libraries
* make sure there are no name conflicts in between modules (that's where C++ namespaces do help)
* etc


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]



[edited by - Fruny on November 29, 2003 11:04:58 PM]

Share this post


Link to post
Share on other sites
there is no general way to deal with a linker error; if you have it, post the error message here for help.

oops, got beaten to it by a much better post

[edited by - nagromo on November 29, 2003 10:43:47 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Fruny
* don''t define variables (unless they are const) or non-inline, non-templated functions in header files
* make sure you link all the right libraries
* make sure there are no name conflicts in between modules (that''s where C++ namespaces do help)
* etc



* make sure you define all functions you use.


:::: [ Triple Buffer ] ::::

Share this post


Link to post
Share on other sites