www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Symbol Undefined

reply "ElfQT" <dethjunk yahoo.com> writes:
I'm trying to build a little app with James Lacey's D3D9 - D binding.
Here is the D3D9 .d file: http://elfqt.simeis.hu/szallit/d3d9.d
Here is my source file: http://elfqt.simeis.hu/szallit/Start.d

To build I enter at the command promt:
C:\D\Dmd\bin\dmd.exe -g -debug d3d9.d Start.d Main.def phobos.lib
uuid.lib -of".\Debug\Main.exe"

Main.def contains:
EXETYPE NT
SUBSYSTEM WINDOWS

The error:
Start.obj(Start)
 Error 42: Symbol Undefined _Direct3DCreate9 4

If I build without the "-g" option, all seems fine.

Can someone at least point me somewhere, how to resolve this problem?
Thaks,
 ElfQT
Aug 08 2005
next sibling parent reply "ElfQT" <dethjunk yahoo.com> writes:
Ok, I found a solution.
I have to put in Main.def an IMPORTS setction with
_Direct3DCreate9 4=d3d9.Direct3DCreate9

I found this in "nonagon" .def file (it's a D language DirectX lib, I've
found it googleing and browsing D language DirectX topics, couldn't find
project home or source).

I guess all similar linker problems can resolved with IMPORTS.

ElfQT

ps., and yes, now I can build and debug in Visual Studio :)


"ElfQT" <dethjunk yahoo.com> wrote in message
news:dd7q85$2icl$1 digitaldaemon.com...
 I'm trying to build a little app with James Lacey's D3D9 - D binding.
 Here is the D3D9 .d file: http://elfqt.simeis.hu/szallit/d3d9.d
 Here is my source file: http://elfqt.simeis.hu/szallit/Start.d

 To build I enter at the command promt:
 C:\D\Dmd\bin\dmd.exe -g -debug d3d9.d Start.d Main.def phobos.lib
 uuid.lib -of".\Debug\Main.exe"

 Main.def contains:
 EXETYPE NT
 SUBSYSTEM WINDOWS

 The error:
 Start.obj(Start)
  Error 42: Symbol Undefined _Direct3DCreate9 4

 If I build without the "-g" option, all seems fine.

 Can someone at least point me somewhere, how to resolve this problem?
 Thaks,
  ElfQT
Aug 08 2005
parent reply "ElfQT" <dethjunk yahoo.com> writes:
I'm stuck again. The following code throws "Access violation" on the
CreateDevice call.

(Using the same D3D9.d file:)
 Here is the D3D9.d file: http://elfqt.simeis.hu/szallit/d3d9.d
IDirect3D9* g_pD3D = null; IDirect3DDevice9* g_pd3dDevice = null; HRESULT InitD3D( HWND hWnd ) { g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ); if( null == ( g_pD3D ) ) //return E_FAIL; return 1; D3DPRESENT_PARAMETERS d3dpp; //ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT.D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFORMAT.D3DFMT_UNKNOWN; if( FAILED( g_pD3D.CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE.D3DDEVTYPE_REF/*D3DDEVTYPE_HAL*/, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) { //return E_FAIL; return 1; } return 0; } The same in C++ works (on same machine) LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device HRESULT InitD3D( HWND hWnd ) { if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return E_FAIL; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) { return E_FAIL; } return S_OK; } Any idea, what is the difference? Thanks, ElfQT
Aug 08 2005
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"ElfQT" <dethjunk yahoo.com> wrote in message 
news:dd825a$2rfk$1 digitaldaemon.com...

Wee, you found nonagon!  Release 4 will be done pretty soon, with HLSL 
shader support, if you're interested.  I have a few issues to fix in the 
fixed-function pipeline and with textures, and then some docs to write, but 
it'll be out soon.

The problem is this:

 IDirect3D9* g_pD3D = null;
 IDirect3DDevice9* g_pd3dDevice = null;
Remember that in D, there is an implicit level of indirection for classes and interfaces. So what would be IDirect3D9* or LPDIRECT3D9 in C++ becomes IDirect3D9 in D.
Aug 08 2005
parent reply "ElfQT" <dethjunk yahoo.com> writes:
Then the
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
becomes
g_pD3D = cast(IDirect3D9)Direct3DCreate9( D3D_SDK_VERSION );
?

And what is the right syntax in the
g_pD3D.CreateDevice(... ,&d3dpp, &g_pd3dDevice) call?

How to cast implicit D indirection "back" into C++ pointer?


nonagon: well, if I've got it right, it does not come with source :(.
Is there a project site or anything?
And also, what happened with D Game Dev community ;) ?

ElfQT

"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:dd85a8$2v17$1 digitaldaemon.com...
 "ElfQT" <dethjunk yahoo.com> wrote in message 
 news:dd825a$2rfk$1 digitaldaemon.com...

 Wee, you found nonagon!  Release 4 will be done pretty soon, with HLSL 
 shader support, if you're interested.  I have a few issues to fix in the 
 fixed-function pipeline and with textures, and then some docs to write, 
 but it'll be out soon.

 The problem is this:

 IDirect3D9* g_pD3D = null;
 IDirect3DDevice9* g_pd3dDevice = null;
Remember that in D, there is an implicit level of indirection for classes and interfaces. So what would be IDirect3D9* or LPDIRECT3D9 in C++ becomes IDirect3D9 in D.
Aug 08 2005
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"ElfQT" <dethjunk yahoo.com> wrote in message 
news:dd8fb1$9lh$1 digitaldaemon.com...
 Then the
 g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
 becomes
 g_pD3D = cast(IDirect3D9)Direct3DCreate9( D3D_SDK_VERSION );
Well, for one, the Direct3D header file you're using makes the huge mistake of using IWhatever* instead of just IWhatever in every single function that takes or returns an interface pointer. I have no idea how the guy who made these headers got them to work. If you'd like, I could post the D3D9/D3DX header file that I made from the June 2005 DirectX SDK. Or, you can download the nonagon Release 3 zip from below and use the d3d9d.d module in there.
 nonagon: well, if I've got it right, it does not come with source :(.
It's not open-source, sorry. However, if there's anything you need help with, in terms of DirectX programming (i.e. problems not caused by incorrectly-defined functions ;) ), I'd be glad to help!
 Is there a project site or anything?
Well, I was hosting it on my ISP, but then I switched ISPs, and so now I have my site and nonagon on James Dunne's server. You can download Release 3 of nonagon at http://jamesdunne.no-ip.org/~jarrett/nonagon.zip. There is also a Google group for nonagon at http://groups.google.com/group/nonagon.
 And also, what happened with D Game Dev community ;) ?
I wasn't aware there was one!
Aug 08 2005
next sibling parent "ElfQT" <dethjunk yahoo.com> writes:
The "header" is from dsource.
http://www.dsource.org/projects/bindings/
I didn't thougth it is completly wrong.

I asked  "D Game Dev community", because I've seen the question on 
news/forums in directx and similar topics... I thougth that if any, than you 
would know about it :)

I am experimenting with your d3d9d.d, thank you. 
Aug 08 2005
prev sibling parent reply "ElfQT" <dethjunk yahoo.com> writes:
"header" corrected.

Then a big, nice beginner err in my code:
"... wc.lpszClassName = "DWndClass";"
"... CreateWindowA( "D3D Tutorial", ...

-> hWnd points to zero, then .CreateDevice gives 2005530516 
(D3DERR_INVALIDCALL)

But at the end I succeeded.

When I close my app, I get an "AssertError Failure Start(128)" error.
Is this the garbage collector, or I miss to free something?

ElfQT 
Aug 08 2005
parent reply "ElfQT" <dethjunk yahoo.com> writes:
OK, I'm tired now. (It's 1:35 AM here.)
I haven't returned anything... and I didn't recognized Start(128) point to 
exactly where to look ;)
ElfQT

 When I close my app, I get an "AssertError Failure Start(128)" error.
 Is this the garbage collector, or I miss to free something?
Aug 08 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"ElfQT" <dethjunk yahoo.com> wrote in message 
news:dd8qbn$l6q$1 digitaldaemon.com...

 The "header" is from dsource.
It might be outdated, or something. Though I'm pretty sure D has always had the implicit level of indirection (and definitely since before 2004, when that binding was written). If you're wondering why I call it a "header" - I'm still used to C++ terminology, and to me, a "header" is "a file which doesn't have any code, just declarations." I suppse in D, they're called "import modules," but "header" is shorter ;)
 I haven't returned anything... and I didn't recognized Start(128) point to 
 exactly where to look ;)
Yeah, I wish D's built-in assert allowed for including error messages. When I get an "AssertError Failure fork(593)," I'm just totally flabbergasted at first, until I realize it's a function missing a return value. If it said "function must return a value" or something, it'd be more helpful.
Aug 08 2005
prev sibling parent Chris Sauls <ibisbasenji gmail.com> writes:
ElfQT wrote:
 I'm trying to build a little app with James Lacey's D3D9 - D binding.
 Here is the D3D9 .d file: http://elfqt.simeis.hu/szallit/d3d9.d
 Here is my source file: http://elfqt.simeis.hu/szallit/Start.d
 
 To build I enter at the command promt:
 C:\D\Dmd\bin\dmd.exe -g -debug d3d9.d Start.d Main.def phobos.lib
 uuid.lib -of".\Debug\Main.exe"
Just so you know, you don't have to specify phobos.lib on the command line. You might have to if you are using a custom hacked copy, I'm not sure. But in the default case, its automatically linked. -- Chris Sauls
Aug 08 2005