Trying to compile

Started by
6 comments, last by Reminator 15 years, 3 months ago
Hi, I'm trying to compile this sample code from Introduction to 3D Game Programming with DirectX 9.0c Shader Approach. But I get a compile error. Here's the code: #include <d3dx9.h> #include <iostream> using namespace std; // Overload the "<<" operators so that we can use cout to // output D3DXVECTOR3 objects. ostream& operator<<(ostream& os, D3DXVECTOR3& v) { os << "(" << v.x << ", " << v.y << ", " << v.z << ")"; return os; } int main() { // Using constructor, D3DXVECTOR3(FLOAT x,FLOAT y,FLOAT z); D3DXVECTOR3 u(1.0f, 2.0f, 3.0f); // Using constructor, D3DXVECTOR3(CONST FLOAT *); float x[3] = {-2.0f, 1.0f, -3.0f}; D3DXVECTOR3 v(x); // Using constructor, D3DXVECTOR3() {}; D3DXVECTOR3 a, b, c, d, e; // Vector addition: D3DXVECTOR3 operator + a = u + v; // Vector subtraction: D3DXVECTOR3 operator - b = u - v; // Scalar multiplication: D3DXVECTOR3 operator * c = u * 10; // ||u|| float length = D3DXVec3Length(&u); // d = u / ||u|| D3DXVec3Normalize(&d, &u); // s = u dot v float s = D3DXVec3Dot(&u, &v); // e = u x v D3DXVec3Cross(&e, &u, &v); cout << "u = " << u << endl; cout << "v = " << v << endl; cout << "a = " << a << endl; cout << "b = " << b << endl; cout << "c = " << c << endl; cout << "d = " << d << endl; cout << "e = " << e << endl; cout << "||u|| = " << length << endl; cout << "u dot v = " << s << endl; return 0; } And here's the error: Embedding manifest... mt.exe : general error c10100b1: Failed to load file "..\Debug\3dvectors.exe". The system cannot find the path specified. Is this a linking error? The project is an empty project. Thanks in advance for any help. -------------edit--------------- I'm using Visual C++ 2008 Express Edition and have DirectX 9 installed.
Advertisement
It's not a link error, it means that the program cannot find that location. In your project properties check to make sure that the putput directory is correct, if it is try deleting everything in the Debug folder, and let the compiler rebuild everything from scratch.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Also check your permissions since if you don't have permission to that folder you'll see that error of if another instance of the program is running.
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
Hi!

If I get into this kind of trouble, I always use the following.
I download a minimal dx9 tutorial (nehe or something), I try to compile and run.
It should work.
Then I use this project file, include my sources in small steps, it should work.

Füge
------edit------
OK so I fixed my first problem. I just had to go to File > move to > folder. However I ran into another problem, and I believe that it is now a linking error.

Error:

1>------ Build started: Project: 3dvectors, Configuration: Debug Win32 ------
1>Compiling...
1>vector3.cpp
1>Linking...
1>vector3.obj : error LNK2019: unresolved external symbol _D3DXVec3Normalize@8 referenced in function _main
1>C:\Users\Remington\Documents\Visual Studio 2008\Projects\3dvectors\Debug\3dvectors.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Remington\Documents\Visual Studio 2008\Projects\3dvectors\3dvectors\Debug\BuildLog.htm"
1>3dvectors - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

[Edited by - Reminator on January 17, 2009 12:19:04 PM]
I looked all over the internet to see how others solved the problem, and it seems that it is definitely a linking problem. However, I don't know what's wrong. I'm pretty sure I set up the directories right. What else do I have to do? Anyone have any idea?

----edit----
OK i figured out the problem. I forgot to add the d3dx9.lib file to additional dependencies.

Thanks for your guys support from earlier.

[Edited by - Reminator on January 19, 2009 4:18:39 PM]
Did you add d3dx9.lib to your 'additional library dependencies' list?
[TheUnbeliever]
Thanks for your input TheUnbeliever. I didn't see your post at the time I edited my post (didn't refresh the page).

This topic is closed to new replies.

Advertisement