Strange problem with linking

Started by
7 comments, last by Falku 14 years ago
Hi Everyone, This is my first post. I'm using Visual Studio 2008, DirectX10. I've came with maby simple problem, which is "error LNK2019: unresolved external symbol" but, it occurs only in my functions. I've checked my linked static libraries, my function names, implementation and everything seems to be okey. I can tell that I haven't comitted any error. I realised also, when I move body of function from *.cpp file to header *.h file, errors disappears, I've got cpp files in my project. This is compilation log: http://pastebin.com/N9Kf71rj I hope that I presented a problem sufficiently and I'll be very thankful for any help. Greetings, Arthur [Edited by - Falku on April 2, 2010 4:13:00 PM]
Advertisement
You'd have to show us the code too, but I'm guessing you're omitting the class name qualifiers in the cpp file:
// Headerclass Foo{   void example();};// Sourcevoid example() // Won't work{   // ...}// needs to be:void Foo::example(){   // ...}

It also appears only to be compiling Renderer.cpp. Are all your other implementation files part of the project? If you do a full rebuild, do they all get compiled?
Thank You for Your answer :) All my files are compiled, I've also checked if I got Renderer::func(), not only func(), Renderer.cpp compile only in this case because other files are already compiled. I've done serveral times full rebuild, more, I've even done a new project and set up everything from the beginning.
Post some code that won't compile then.
Hey,

This is main.cpp
http://pastebin.com/qNMi24uT

This is Renderer.h
http://pastebin.com/pKMcqEZA

This is Renderer.cpp
http://pastebin.com/tfWBTsKi

This is SceneManager.h
http://pastebin.com/Uka8DfmS

This is SceneManager.cpp
http://pastebin.com/Rve9iUds

Functions which cause errors are commented, code is commented too so I this it will be easy to You. I also cut off larger not important fragments.

Thank You for attention.
Many of your functions are declared inline. Inline functions must be implemented either inside the class body (in fact, any function implemented in the class body is implicitly considered "inline") or in the header file.

The simplest thing would be to remove "inline" from the header files. Inline is a hint to the compiler, one that is largely ignored in modern compilers which prefer to use their own heuristics for inlining.
Oh man, thanks much for Your help, this is it ;) but what if I want to make function inline, should I use __forceinline instead of inline?

[Edited by - Falku on April 2, 2010 6:52:35 PM]
Well, if you think they should be inlined then include them in the header. The compiler will likely inline short functions unless it decides that some other factor, such as optimising code size or something would cause the code to end up slower.

__forceinline should be only reserved for those exceedingly rare cases where something can be proved - through profiling - to be faster than the compiler makes it. If you make a habit of using __forceinline you are actually making it harder for the compiler to make good decisions.
Ok, thanks again I thins that my problem is solved greatly ;)

This topic is closed to new replies.

Advertisement