# "unresolved external symbol _Direct3DCreate9@4"

11 replies to this topic

### #1poita

Senior Member

• Members
• 322 posts

Posted 08 June 2006 - 01:48 PM

I'm creating my direct 3d interface object by using:

// in WinMain ...

if((pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)

return E_FAIL;

pD3D is defined globally as a LPDIRECT3D9 and I've included d3d9.h but I'm getting this error message:

"1>main.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function _WinMain@16"

Any ideas what's wrong? I remember I got the same error before when I did this but I can't remember how I solved it.

### #2monjardin

Senior Member

• Members
• 1033 posts

Posted 08 June 2006 - 02:02 PM

It looks like you aren't linking to the D3D libraries...
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

### #3gmax136

New Member

• Members
• 3 posts

Posted 08 June 2006 - 02:38 PM

### #4Qlone

New Member

• Members
• 7 posts

Posted 09 June 2006 - 03:06 PM

... or add the .lib file to your solution, or #pragma comment(lib, "d3d9.lib") in the header file of your pogram... so may ways :)

### #5poita

Senior Member

• Members
• 322 posts

Posted 10 June 2006 - 07:16 AM

Oh ok. I was under the impression that including the header file allowed you to use those functions.

What exactly does linking to the library do?

[EDIT] Thanks btw! :)

### #6baldurk

Senior Member

• Members
• 1057 posts

Posted 10 June 2006 - 09:40 AM

poita said:

Oh ok. I was under the impression that including the header file allowed you to use those functions.

What exactly does linking to the library do?

[EDIT] Thanks btw! :)

The way the build system works is in a couple of major parts (not counting the preprocessor and suchlike).

First, the compiler will take the raw source code and convert it into an object file. This is why you need to include header files. The header files contain the declarations of the functions you're using. ie. the header files say to the compiler, "there is such a function matching this prototype - if it gets used, don't give an error". If you didn't include the header, or used the function wrongly, the compiler would tell you about it.

That's assuming you're using dynamic linking, which I guess you probably are :).
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

### #7poita

Senior Member

• Members
• 322 posts

Posted 11 June 2006 - 11:02 AM

Thanks for that baldurk, makes perfect sense now. :)

Off-topic:

Regarding you sig, I always heard that with 2 more lines:
"He that knows and knows not that he knows is asleep. Awaken him.
He that knows and knows that he knows is wise. Follow him."

Don't know if you already knew them but just though I'd put that out there.

### #8monjardin

Senior Member

• Members
• 1033 posts

Posted 12 June 2006 - 02:02 PM

Those sayings would be easier for me to follow in C++ rather than in English. ;)
void Person::FollowBaldurkAdvice(Person & other)
{
if (!other.Knows() && !other.ThinksHeKnows())
this->Teach(other);
else if (!other.Knows() && other.ThinksHeKnows())
this->Shun(other);
else if (other.Knows() && !other.ThinksHeKnows())
this->Awaken(other);
else if (other.Knows() && other.ThinksHeKnows())
this->Follow(other);
}

... or perhaps a truth table would help.
Knows | Thinks He Knows || Action
-----------------------------------
0  |        0        || Teach
0  |        1        || Shun
1  |        0        || Awaken
1  |        1        || Follow


monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

### #9baldurk

Senior Member

• Members
• 1057 posts

Posted 12 June 2006 - 05:35 PM

hah. I did originally have the entire quote, but generally the first two lines are very relevant to forums, the second two aren't :). Besides, 4 lines is a bit much for a sig.

monjardin: your JwN meter has gone down I see :).
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

### #10monjardin

Senior Member

• Members
• 1033 posts

Posted 12 June 2006 - 06:48 PM

Yes, the JwN meter has gone down. Lately, the MMO noobs are getting shot down before I even see their posts. This one cheered me up a bit. The poster took the constructive criticism for what it was.

Otherwise, the standard procedure has been to degrade the DevMaster forum members. In light of the answer you just gave poita, I don't know how anyone could claim this forum is inhospitable to beginners. It's a good question from someone that doesn't have much programming experience, but a lot of places would flame him/her anyway.

Also, did you notice that the FollowBaldurkAdvice method does't work with a const Person? ;)
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

### #11enderleit

New Member

• Members
• 2 posts

Posted 17 October 2009 - 07:31 AM

I have this same problem, except when I check the Options->Directories, the directx includes and library folders are already added to the appropriate Directory tabs...

Is there something else I need to do to use DirectX in my code?

/Sincerely
Martin Enderleit

### #12enderleit

New Member

• Members
• 2 posts

Posted 17 October 2009 - 07:49 AM

Never mind, I figured it out!
// Martin "eLeit" Enderleit

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users