Jump to content


Link error (LNK1120) in CPPUnit tests


2 replies to this topic

#1 hellhound_01

    New Member

  • Members
  • PipPip
  • 58 posts

Posted 12 January 2012 - 04:09 PM

Hi,

after Migration of our GCC compatible sources to MSVC I've some trouble to get the CPPUnit tests
runable. If those tests tries to access hidden members (private, protected) using preprocessor
macros like this on exported classes:

#define protected public
#include <brGraphics/brImage.h>
#undef protected

And tries to access a hidden method like this:

protected:
   unsigned int getNativePixelColor(const brColor& color);

I got the follwing error:

Quote

2>brImageTest.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: unsigned int __thiscall binrev::brGraphics::brImage::getNativePixelColor(class binrev::brGraphics::brColor const &)" (__imp_?getNativePixelColor@brImage@brGraphics@binrev@@QAEIABVbrColor@23@@Z)" in Funktion ""public: void __thiscall binrev::test::brImageTest::testGetNativePixelColor(void)" (?testGetNativePixelColor@brImageTest@test@binrev@@QAEXXZ)".
2>C:\binrev\binrevengine\modules\brGraphics\branches\hellhound-dev\bin\Debug\brGraphics_tests.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.

I tried to define the related methods public, in that case everything is running fine.
Any suggestions how I could solve this issue without making those methods public?

Best regards
Hellhound
"There is only one god and his name is death. And there is only one thing we have to say to Death: Not today!" -- Syrio Forel (from Game of Thrones)

#2 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 12 January 2012 - 04:58 PM

I don't think you can, other than leaving the access specifiers be and befriending your unit test suite with the appropriate classes.
Unfortunately, MSVC++ mangles the access specifiers in the symbol names, which explains the linker errors.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#3 hellhound_01

    New Member

  • Members
  • PipPip
  • 58 posts

Posted 12 January 2012 - 07:00 PM

Thanks Oisyn for your explanation. I've to think about my access specifiers.
I now why I don't like the MSVC, damn extras ...
"There is only one god and his name is death. And there is only one thing we have to say to Death: Not today!" -- Syrio Forel (from Game of Thrones)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users