Link error (LNK1120) in CPPUnit tests

6532e3e5e09db6f966770fdf86c03345
0
hellhound_01 104 Jan 12, 2012 at 16:09

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:

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

2 Replies

Please log in or register to post a reply.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Jan 12, 2012 at 16:58

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.

6532e3e5e09db6f966770fdf86c03345
0
hellhound_01 104 Jan 12, 2012 at 19:00

Thanks Oisyn for your explanation. I’ve to think about my access specifiers.
I now why I don’t like the MSVC, damn extras …