Sign in to follow this  

How to export inline-functions from a DLL

This topic is 4278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. Presently I try to implement a math library for my 3D engine and to export it to a static DLL. The problem is, that the math library defines inline functions and the compiler generates the link error LNK2019. Can anybody tell me, how to export a class from a DLL with inline class members? Thanks.

Share this post


Link to post
Share on other sites
You can't export inline methods because of the way the compiler uses them. The compiler needs to see the entire function implementation in order to inline something.

It shouldn't affect exporting a class though, although I stay away from doing that, it always comes out ugly when I try...

A math library probably shouldn't be in a DLL if it's going to be inline, you only need to provide the header. Alternatively, provide it as a .lib so the linker can do some optimizations if possible.

Share this post


Link to post
Share on other sites
How are you exporting the functions, are you using the .def file or __declspec(dllexport) (I'm assuming MSVC here) on the function itself? With the later I would expect the compiler to see that you're exporting the inline function and also generate a normal version of it for the export. If you're using the .def file the though compiler doesn't know about the export (only the linker knows about it) and thus won't generate the normal version of the function, giving you your link error.

....I haven't actually tried this myself though, so no guarrenttees it'll work [smile]

Share this post


Link to post
Share on other sites

This topic is 4278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this