Moving graphics engine to DLL project

Started by
12 comments, last by Dawoodoz 13 years, 6 months ago
I tried to make my graphics engine into a DLL by moving all code from the DirectX example project to a new DLL project in Visual C++ 2005.
I have made a working connection between the DLL and a testing project in the same visual studio solution so that simple calls can be made.
Now I have both DXUT.h and stdafx.h included in the whole engine but only stdafx.h is forced to be included.
I have checked that the DirectX libs and stuff are included in Visual Studio.

Here are the link errors after solving many regular errors:
1>------ Build started: Project: GameEngine, Configuration: Release Win32 ------1>Compiling...1>stdafx.cpp1>Compiling...1>SDKmisc.cpp1>Model.cpp1>IntegerArray.cpp1>DXUTmisc.cpp1>DXUTDevice11.cpp1>DXUTcamera.cpp1>DXUT.cpp1>StringMethods.cpp1>GameEngine.cpp1>Linking...1>   Creating library C:\Users\David\Documents\Visual Studio 2005\Projects\GameEngine\Release\GameEngine.lib and object C:\Users\David\Documents\Visual Studio 2005\Projects\GameEngine\Release\GameEngine.exp1>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXMatrixMultiply@121>GameEngine.obj : error LNK2001: unresolved external symbol _D3DX11CompileFromFileW@441>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXMatrixOrthoOffCenterLH@281>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXVec3Normalize@81>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXVec3Transform@121>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXVec3TransformCoord@121>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXMatrixTranspose@81>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXMatrixScaling@161>GameEngine.obj : error LNK2001: unresolved external symbol _D3DXMatrixTranslation@161>DXUT.obj : error LNK2001: unresolved external symbol __imp__InitCommonControls@01>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXQuaternionMultiply@121>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXMatrixRotationQuaternion@81>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXMatrixLookAtLH@161>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXMatrixInverse@121>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXMatrixPerspectiveFovLH@201>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXMatrixRotationYawPitchRoll@161>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXQuaternionRotationMatrix@81>DXUTcamera.obj : error LNK2001: unresolved external symbol _D3DXVec3TransformNormal@121>DXUTmisc.obj : error LNK2001: unresolved external symbol _DXTraceW@201>DXUTmisc.obj : error LNK2001: unresolved external symbol _D3DX11SaveTextureToFileW@161>SDKmisc.obj : error LNK2001: unresolved external symbol _D3DX11GetImageInfoFromFileW@161>SDKmisc.obj : error LNK2001: unresolved external symbol _D3DX11CreateTextureFromFileW@241>C:\Users\David\Documents\Visual Studio 2005\Projects\GameEngine\Release\GameEngine.dll : fatal error LNK1120: 22 unresolved externals1>Build log was saved at "file://c:\Users\David\Documents\Visual Studio 2005\Projects\GameEngine\GameEngine\Release\BuildLog.htm"1>GameEngine - 23 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Have anyone seen that before?

Is there any good general method for solving link errors?
Advertisement
It looks like you don't have the lib files for the D3DX functions linked into your DLL; check which files the DLL project is linking against and compare that to your exe/original project/another D3D project which uses D3DX functions.
Thanks, it solved it.

Solution for anyone with the same issue:
Project's property page - Configuration Properties - Linker - Input
Additional Dependencies:
d3dcompiler.lib dxerr.lib dxguid.lib d3dx9.lib d3d9.lib winmm.lib comctl32.lib dxgi.lib d3dx11.lib d3d10.lib
I have one problem remaining. I have an HLSL supershader and a header for named constant definitions used by both the HLSL shader and the engine DLL.
I don't want the user to see the HLSL file because the user would start to modify it and be unable to upgrade to another version of my engine.
If I include the shader as a static string then it can't reach the header file because that won't be released with the engine.

How can I place both files in the engine without duplicating code or making an included mess for the user?
Have the file names declared in the header file, but defined in cpp files, not header files. So when you compile your dll, they will be in the dll, not the header.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Quote:Original post by smasherprog
Have the file names declared in the header file, but defined in cpp files, not header files. So when you compile your dll, they will be in the dll, not the header.


What would the file names refer to?
You said you had some constants that you want hidden from users, as well as a shader. Declare them in the header, and define them in your cpp file.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Quote:Original post by smasherprog
You said you had some constants that you want hidden from users, as well as a shader. Declare them in the header, and define them in your cpp file.


The problem is that the shader is depending on the header.
One header with macros is used by both HLSL and Cpp.

#define Common_MaxNumberOfDynamicPointLights 64#define Common_ObjectType_Skybox 0	// This is used by the engine to draw the sky#define Common_ObjectType_Material 1	// This is used for your objects#define Common_ObjectType_Shadow 2	// This is used to render shadows#define Common_ObjectType_Effect 3	// This is used for post effects	#define Common_NumberOfObjectTypes 4	// Last object type + 1#define Common_CascadeCount 4// The types of shaders with reused numbers in different object types to compile fewer shaders.#define Common_FirstShadowPixelShaderType 0#define Common_PixelShaderType_Shadow_Simple 0	//#define Common_PixelShaderType_Shadow_Alpha 1	// D#define Common_LastShadowPixelShaderType 1#define Common_FirstSkyPixelShaderType	 2#define Common_PixelShaderType_Sky_Simple 2	//#define Common_LastSkyPixelShaderType 2#define Common_FirstMaterialPixelShaderType 3#define Common_PixelShaderType_Material_NoTextures 3	//#define Common_PixelShaderType_Material_DiffuseOnly 4	// D#define Common_PixelShaderType_Material_Bump 5	// D N#define Common_PixelShaderType_Material_SpecularBump 6	// D N S#define Common_PixelShaderType_Material_Specular 7	// D   S#define Common_PixelShaderType_Material_Illuminated 8	// D#define Common_PixelShaderType_Material_IlluminatedBump 9	// D N#define Common_PixelShaderType_Material_IlluminatedSpecularBump 10	// D N S#define Common_PixelShaderType_Material_IlluminatedSpecular 11 // D   S#define Common_LastMaterialPixelShaderType 11#define Common_FirstEffectPixelShaderType 12#define Common_PixelShaderType_Effect_None 12#define Common_PixelShaderType_Effect_ADD_AB 13#define Common_PixelShaderType_Effect_ADD_ABC 14#define Common_PixelShaderType_Effect_ADD_ABCD	 15#define Common_PixelShaderType_Effect_Blur_Linear 16#define Common_PixelShaderType_Effect_AddArg	 17#define Common_PixelShaderType_Effect_MultiplyWithArg 18#define Common_PixelShaderType_Effect_RaiseToArg 19#define Common_PixelShaderType_Effect_GrayScale	 20#define Common_LastEffectPixelShaderType 20#define Common_NumberOfPixelShaderTypes	21 // Max pixel shader type + 1#define Common_FirstShadowVertexShaderType 0#define Common_VertexShaderType_Shadow 0#define Common_VertexShaderType_AlphaShadow 1#define Common_LastShadowVertexShaderType 1#define Common_FirstSkyVertexShaderType	2#define Common_VertexShaderType_Sky 2#define Common_LastSkyVertexShaderType 2#define Common_FirstMaterialVertexShaderType 3#define Common_VertexShaderType_Material_Flat 3#define Common_VertexShaderType_Material_Bump 4#define Common_LastMaterialVertexShaderType 4#define Common_FirstEffectVertexShaderType 5#define Common_VertexShaderType_Effect_Standard 5#define Common_LastEffectVertexShaderType 5#define Common_NumberOfVertexShaderTypes 6 // Max vertex shader type + 1
Well, try changing them to extern const ? You are kind of stuck if you use defines and want to hide them from users in a dll.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Quote:Original post by smasherprog
Well, try changing them to extern const ? You are kind of stuck if you use defines and want to hide them from users in a dll.


OK, I haven't used extern constants before.
How do I reach them in both compiletime and runtime?

This topic is closed to new replies.

Advertisement