Jump to content
  • Advertisement
Sign in to follow this  
codeseeker

How to export LPDIRECT3D9 & LPDIRECTDEVICE9 Symbols from DLL?

This topic is 3989 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 Coders, I just started working with DLL's using C++ , i know the basics of exporting functions, variables, and classes but im having a persistent trouble thats preventing me from getting any work done. You see im building a game engine, or library. I want to have the ability to export a function that allows me to create a directX device , but it doesnt work externally. So i figured i need to export the symbols LPDIRECT3D9 and LPDIRECTDEVICE9 , but... It still will not work, and i get a terrible error when i try to do this. Heres how im exporting , if you need to look at the syntax: #define Engine_API static __declspec(dllexport) Engine_API LPDIRECT3D9 d3d = NULL; Engine_API LPDIRECTDEVICE9 d3ddev=NULL; so what exactly am i doing wrong? when i try to export these symbols it seems to be conflicting with DirectX9 , is their anyway around this??? What should i do? Thanks In Advance, CodeSeeker

Share this post


Link to post
Share on other sites
Advertisement
Cant provide you with the error messages: im at school.

I dont know if its conflicting or not, but when i try compling the code i gave you all above it screams out errors.


I did include d3d9 and d3dx9 , so that cant be it... #pragma comment(lib,"d3d9.lib"); #pragma comment(lib,"d3dx9.lib");


If any of you could compile the code i gave , and see if you can figure it out by the error message that would be great. Otherwise ill have to go home later tonight and compile and save the error log.

Share this post


Link to post
Share on other sites
Quote:
Original post by codeseeker
If any of you could compile the code i gave , and see if you can figure it out by the error message that would be great. Otherwise ill have to go home later tonight and compile and save the error log.
I haven't actually tried compiling that code, but it looks fine to me. The only thing I can think of that might be missing is a #include <d3d9.h> so the compiler knows what the LPDIRECT3D9 and LPDIRECTDEVICE9 types are.

Share this post


Link to post
Share on other sites
Ok so heres how it went.


LPDIRECT3D9 d3d;


static __declspec(dllexport) d3d;



complier error:

d3d must have linkage in order to import or export.

doesnt make much sense honestly, i have the libraries included and the headers included , i could send you the source if you have an email? Honestly i dont know how it would be my source, but ill do an external test where the code is not part of my game engine and see if it compiles right, if so its most likely my engine code.

Thanks for the help anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by codeseeker
Ok so heres how it went.


LPDIRECT3D9 d3d;


static __declspec(dllexport) d3d;



complier error:

d3d must have linkage in order to import or export.

doesnt make much sense honestly, i have the libraries included and the headers included , i could send you the source if you have an email? Honestly i dont know how it would be my source, but ill do an external test where the code is not part of my game engine and see if it compiles right, if so its most likely my engine code.

Thanks for the help anyway.
What's the exact error message? I'm not sure, but you probably can't use static with __declspec(dllexport). Instead of the above 2 lines, try this:
__declspec(dllexport) LPDIRECT3D9 d3d;

Also, when you're importing the symbol, it should use __declspec(dllimport). You might want to try creating a new DLL project in visual studio and look at how it handles this (Using a preprocessor directive to determine which linkage to use).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!