At 16:19 2002-12-10 +0100, you wrote:
I've just noticed that CodeWarrior 8.3 won't build my project which contains
2 .cpp files and MathLib.c file. All files are declared in the project and I
use only one segment. In the main.cpp, I call "pow" and "sqrt" functions
from the MathLib.c. Both MathLib.h and MathLib.c were added automatically
when creating the project.

I got a "Link error : pow (sqrt) referenced from main.cpp is not defined".
This doesn't exactly look like the error message I'd expect... in CW, you can copy error messages to the clipboard by highlighting one of them, and then using Edit/Copy.

Looking closer at MathLib.h, I see the problem. This header file doesn't have the proper guards for inclusion in a C++ program. You can get around this by saying:

extern "C" {
#include "MathLib.h"
}

That will tell C++ that the functions declared by MathLib.h are from a .c source file, and will allow you to link your C++ code to the MathLib C code.

The second .cpp file, Tools.cpp, contains some shared functions. I do have
to add "#include "Tools.cpp" in the Main.cpp so that the builder can find
the functions' definitions, otherwise I will get the same error.
Another problem -- you don't include other .cpp files, you add them to your project, and you make a common .h file that declares prototypes for the exported functions.

I've tried to look in the samples which using multiple files, comparing the
configuration, but I cannot find the difference. I can build successfully
the samples.

--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com


--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to