Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Borland C++ Linker

Alright, let me see if I've got this right: If I have

a header file named, say, "test.h" which contains the

following declaration:


void test();


and a file named "test.cpp" which contains the

following:


#include "test.h"

#include

#include


void test()

{

printf("This is a test");

}


I can simply compile test.cpp, thus creating an obj file

in a particular directory, and then have yet another

file, "testi.cpp" including only the test.h file and

still be able to call the function test(), as long as

it is linked to the obj file, can't I? Unfortunately,

I get the linker error "Undefined symbol test() in

module testi.cpp." Am I doing something wrong? Thanks

for your help.


mat


Comments

  • The simplest way to have a multi-file project is to make sure both source files are in your project and to make sure that the prototype (in the header file) is visible to the caller source (by doing a #include). It is also often helpful to #include the header in to source for the function itself so that the prototype and the definition don't get out of synch.





Sign In or Register to comment.