Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SRossi

macrumors regular
Original poster
May 27, 2009
202
0
Glasgow, Scotland
Hi all,

Going through the OpenGL Super Bible: 4th Ed. On the Example on page 157, I am getting an error at this line:

Code:
m3dRotationMatrix44(transformationMatrix, m3dDegToRad(yRot), 0.0f, 1.0f, 0.0f);

The debugger gives this error:

Code:
ld: symbol(s) not found
collect2: ld returned 1 exit status

But this line is directly copied form the source code provided on the books website. I am using the same frameworks (except the cocoa, foundation ect.) and i am including the same files as the example.

Any suggestions?

Thanks

Stephen

EDIT: Also cannot get the next example on page 160 to work either same problem. I actually cannot find out what is wrong. There is no coding issues as I have simply copied the code provided. Also I should say the projects provided DOES work somehow :S.
 
Yeah, the custom header was included with the Project downloads. I have included it, and it is working as it uses other functions correctly.

Also I should point out that I get the same error when using another custom header function:

Code:
gltDrawTorus(0.35f, 0.15f, 40, 20);

This custom header is also included properly, and it works correctly with other methods/functions.

Stephen
 
Are you compiling that file with your main source code? Including it isn't enough usually, but I don't know how which tool you're using to compile.
 
No I didn't trying including the existing files, but when I did it threw errors that it couldn't find other files included in these header files.

In the examples provided Richard has added them into the example, but not adding them to the project. When I tried this it still threw errors.

Btw could you explain a little why compiling it with the source code is better than just including the file?

Thanks for your help so far.

Stephen
 
No I didn't trying including the existing files, but when I did it threw errors that it couldn't find other files included in these header files.

In the examples provided Richard has added them into the example, but not adding them to the project. When I tried this it still threw errors.

Btw could you explain a little why compiling it with the source code is better than just including the file?

Thanks for your help so far.

Stephen

You only include header files (e.g. .h files), not source files. As stated, just including a header file is usually not enough as the header file usually only has the function declarations whereas all of the function definitions are in a separate source file. If you don't build the source file, the linker stage will fail because it cannot find the function you are trying to call. There errors you are getting are because the linker cannot find "m3dRotationMatrix44". This function would be in a separate source file that also needs to get compiled. You need to add those files to whatever ide or build system you are using (e.g. add that file to your project).

While technically, you can sometimes get away with including a source file inside another one, it is something that is not normally done.

Please don't take this the wrong way, however, if you are still having trouble understanding this, then I suggest you put down the OpenGL book and get a basic introductory programming book. Learn about the differences between a header and a source file. What the difference between a function declaration and definition is. How to compile programs that are spread out amongst multiple source files. Learn how to do this on the command line, using gcc/g++/etc so you really understand the build process and that will make you a much better programmer. Then go back to OpenGL.
 
Yeah I understand that but what I was meaning is is it better to add it into the project or just provide a link to it without adding it to the project.

Think I have figured out the problem. If I have thanks for the help kainjow and mslide :).

Stephen

EDIT: Ok, well I have included the gltools and math3d source files to compile with the project. But now they are throwing errors, about other functions being referenced but not linked properly. But these files do not include other files or that so now I am wondering whether it is because I did not create a cocoa application and just a normal c++ command line app. Could this be a problem?

Again thanks for your help.
 
Got it to work at last, had to implement it into a Cocoa app instead of a Command Line app.

Again thank you for all your help.

Stephen
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.