OpenGL in DLLs
I''m trying to abstract some of my OpenGL drawing procedures into a DLL so I can make a program that will load plugins. Whenever I try to draw from inside the DLL, I can''t seem to escape the "unresolved external" errors. I''ve tried everything I can think of to get around this, but with no luck. Is this even possible, or am I beating my head against a brick wall?
I though this might have something to do with scope limitations inherent of the rendering context. I''d really appreciate any feedback anyone could offer.
your dll uses opengl32.lib and the others you need in the settings?
we wanna play, not watch the pictures
we wanna play, not watch the pictures
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
If you are calling DLL functions from your main program, you need to export the functions with a .def file.
So, say you have a CalcNormal function to calculate normals in your DLL, you need to declare the function as extern and then create a .def file for your project that contains the following:
EXPORT
functionname1
functionname2
functionname3
So, for calcnormal it would be:
EXPORT
CalcNormal
BTW: comments in this file use the ; character, and details on .def files are in MSDN.
Hope that helps
So, say you have a CalcNormal function to calculate normals in your DLL, you need to declare the function as extern and then create a .def file for your project that contains the following:
EXPORT
functionname1
functionname2
functionname3
So, for calcnormal it would be:
EXPORT
CalcNormal
BTW: comments in this file use the ; character, and details on .def files are in MSDN.
Hope that helps
you can also declare the functions/classes as
__declspec(dllexport) -- for your DLL compile
or
__declspec(dllimport) -- for your program compile
This may be MSVC specific. I think it worked in Dev-C++ though.
Usually this is done with a conditional define (that''s how I did it in PortaLib)
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
__declspec(dllexport) -- for your DLL compile
or
__declspec(dllimport) -- for your program compile
This may be MSVC specific. I think it worked in Dev-C++ though.
Usually this is done with a conditional define (that''s how I did it in PortaLib)
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
It depends on the compiler. In Borland C++ Builder it makes it very easy by not needing to put the libarys for nearly everything in the project.
As far as Importing and Exporting, BCB works like brettporter said MSVC works, but it does it alot more eaisly and dynamicly. I think that this feature of BCB has been used in MSVC if you have it. You need to put somthing like EXPORT in front of functions you want to export and the compiler will change the definition of EXPORT depending on what it is compiling (it works somthing like that, read the manual to find out the specifics.)
Also when asking a question like this, it is usualy a good idea to say what compiler you are using.
ANDREW RUSSELL STUDIOS
Web site coming soon...
As far as Importing and Exporting, BCB works like brettporter said MSVC works, but it does it alot more eaisly and dynamicly. I think that this feature of BCB has been used in MSVC if you have it. You need to put somthing like EXPORT in front of functions you want to export and the compiler will change the definition of EXPORT depending on what it is compiling (it works somthing like that, read the manual to find out the specifics.)
Also when asking a question like this, it is usualy a good idea to say what compiler you are using.
ANDREW RUSSELL STUDIOS
Web site coming soon...
^Bump this up^
( I gotta learn this too.. I recently learned the basics of dll loading, but I get the unresolved external errors too.. I was trying to make tutorial 23 using .dll files )
Hey..... that''s a good point.. if one of you guys that are experienced with .dll files could rewrite the code from tutorial 23 using dlls, and post the code for download, then we could see clearly how to use OpenGL in dlls..
~Cobra~
( I gotta learn this too.. I recently learned the basics of dll loading, but I get the unresolved external errors too.. I was trying to make tutorial 23 using .dll files )
Hey..... that''s a good point.. if one of you guys that are experienced with .dll files could rewrite the code from tutorial 23 using dlls, and post the code for download, then we could see clearly how to use OpenGL in dlls..
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement