Groups | Blog | Home
all groups > visual c > december 2006 >

visual c : Inline funtions (STL) not inlining


Mick O''Neill
12/29/2006 9:40:00 PM
I asked about this a few days ago, and not found an aswer yet, but I have
tracked down further info. I am getting the problems occrrung with the stl,
under thses sorts of circumstances:

#include "LibraryHeader.h"
#include <list>

namespace MyNamespace {
public ref MyClass {
public:
MyMethod() {
list<LibraryNamespace::LibraryObject> myList;
....
}
};
}

What occurs is I end up with a link 2001 error, trying to reference the
list<LibraryNamespace::LibraryObject> constructor. Note that the Library is
unmanaged code.

Mick O''Neill
12/29/2006 10:27:00 PM


[quoted text, click to view]
ok: I am trying to wrap the ImageMagick library at the moment: Here is a
paste of the message (with the real function names)

error LNK2001: unresolved external symbol "public: void __thiscall
std::list<class Magick::Coordinate,class std::allocator<class
Magick::Coordinate> >::push_back(class Magick::Coordinate const &)"
(?push_back@?$list@VCoordinate@Magick@@V?$allocator@VCoordinate@Magick@@@std@@@std@@$$FQAEXABVCoordinate@Magick@@@Z) NETMagick.obj

error LNK2001: unresolved external symbol "public: __thiscall
std::list<class Magick::Coordinate,class std::allocator<class
Magick::Coordinate> >::list<class Magick::Coordinate,class
std::allocator<class Magick::Coordinate> >(void)"
(??0?$list@VCoordinate@Magick@@V?$allocator@VCoordinate@Magick@@@std@@@std@@$$FQAE@XZ) NETMagick.obj

and the code causing it....

public ref class IMDrawableBezier : public
IMDrawable<Magick::DrawableBezier> {
public:
IMDrawableBezier(System::Collections::Generic::IList<IMCoordinate^>%
coordinateList) {
std::list<Magick::Coordinate> lst;
for each (IMCoordinate^ point in coordinateList) {
lst.push_back(::Magick::Coordinate(point->X, point->Y));
}
pDraw = new CLASS(lst);
}
};
Carl Daniel [VC++ MVP]
12/30/2006 12:36:56 AM
[quoted text, click to view]

Does "LibraryHeader.h" contain a #pragma managed directive?

If not, you're probably ending up with an ODR violation with LibraryObject
being defined as both a CLR class and a native class - that could be the
source of your error. You might try:

#pragma managed (push, off)
#include "LibraryHeader.h"
#include <list>
#pragma managed (pop)

to see if that resolves the error.

-cd

Mick O''Neill
12/30/2006 1:36:00 AM


[quoted text, click to view]

Thanks Carl - something I hadn't thought of. However, just tried it, and
made no difference. I'll keep trying to find a work around. Maybe something
will click.

Mick
Mick O''Neill
12/30/2006 5:13:01 AM
Hey everyone - I've figured it out. It has to do with the way the ImageMagick
headers builds the libraries and/or DLL's. Because I'm wrapping the whole
thing in a .NET assembly, but linking to the static ImageMagick libraries,
the Headers are getting confused, and thinking the assembly is a DLL build of
the library, and prefixing the declarations with a __declspec(dllexport),
effectively stopping the inlining.

Now I've figured out the "why", should be simple enough to stop it all.

Thanks for your help folks.
Bruno van Dooren [MVP VC++]
12/30/2006 7:13:33 AM
[quoted text, click to view]

Could you please post the complete compiler error message?

--

Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"

AddThis Social Bookmark Button