Jump to content
  • Advertisement
Sign in to follow this  
Schluppi

How to export inline-functions from a DLL

This topic is 4494 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!