Add-Ons & Services

Inline member function and __declspec(dll(im|ex)port)

A general discussion forum.

Inline member function and __declspec(dll(im|ex)port)

Postby ahtoh » 01 Sep 2011, 16:27

I have problem with inline member function, which placed very often in POCO. I made my static lib under VC2010, which use some poco libs. This lib was build with POCO_STATIC defined macro. If i assembly my lib with my exe and with static poco libs and with POCO_STATIC macro, then i don't have any problem. But if i assembly my exe with my lib and with shared poco libs i have problem with multiple defined inline member function some POCO classes, which used both in my lib and my exe.

I investigate that problem is in __declspec(dll(im|ex)port) attribute. When my lib is compiling with POCO_STATIC macro, then all classes doesn't have any dll(im|ex)port atribute. So, inline functions implementations embed to the my lib without any attributes. When my exe linking with shared poco libs, they already have same inline functions implementations but with __declspec(dllexport) attribute. So linker doesn't eliminate same inline function implementation. In usual case, if my exe is linking with static poco libs, linker eliminates same code and keep only one implementation.

Of course, i can build my lib for both cases with and without POCO_STATIC macro. But i would want to have one my static lib, and the exe or dll decides which poco libs it needs. So i can't understand why inline member functions use everywhere in poco libs. I don't think that using inline function makes better performance. But inline member functions bring problems.

How can i compile/link my lib that it can be used for assembling with both POCO libs static and shared?
Posts: 4
Joined: 10 Jun 2011, 13:28
Location: Russia

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest