Can anyone help?
I am having problems using header files, I am experiencing the following error;
Linker Error: Undefined symbol _opensc in module SCREENO.C
(Using Borland 4.52)
The header file opensc.h contains the the prototype but I still get this error.
If I include the code from the function opensc in the header file the program compiles and works.
If I don't use a header file/seperate module for the function opensc but include it as a seperate function in the program all works too??
Any help highly appreciated.
> Linker Error: Undefined symbol _opensc in module SCREENO.C
This is a linker message, not a compiler message.
The compiler uses .h files to tell it about the outside world.
The linker uses .lib files to tell it about the outside world.
You need to find the library containing the symbol "_opensc", and tell the linker to use that library.
Ah, I'm wasting my time looking for problems with the header file then.
Problem with Library/linking to the library file(s).
I thought I had that set correctly;
I've set the project screeno options to look for include & library files in the correct dircetories.
I created a project, target type "Static Library (for.exe)[.lib] and added the node containing the source code for the function opensc.
I thought that should do the trick??
> I created a project, target type "Static Library (for.exe)[.lib]
This is what you do when you are creating a library
I thought you were creating a program (.exe), which just uses a library for some of the required routines.
Yes that's right.
I have a program screeno.exe that uses a function I have created, opensc.
I was told to create the header file with the prototype for the function and create the library files etc by creating a project - target type static library (for.exe)[.lib]
Is this wrong?
function opensc's definition should be in a .cpp file separate from the main.cpp file. Compile them all. Include the header file in both .cpp files. If this doesn't work than post your code.
> uses a function I have created, opensc
I think you need two projects then
This is a "target type static library (for.exe)[.lib]", and contains those functions which you want to put into the library.
You can include whatever you want, EXCEPT for a function called main.
A key aspect of this is one or more .h files which describe all the functions which are in the library. If you have mylib.lib as the library, the .h file might be called mylib.h
This is a "target type .exe", and contains the non-library code and a main() function.
Anything which wants to call a library function will need to #include "mylib.h".
In your project setup, you will tell the compiler where to find mylib.h, and you'll tell the linker where to find mylib.lib.
Nice thing about MSVC++6 and VS.NET is that you don't even have to mess with settings. It's all GUI. And the default settings don't have to be reset.
"I think you need two projects then"
Yes this is the set-up that I have, for some reason the Borland IDE will not find the library files that I am creating - even though I tell it were to find them.
My lecturer has told me that this is a problem with Borland (V5 at college but expected V4.52 to work at home) ....very helpful.
The work around is to add an extra node to my test project "target type .exe", the node to add is the source code used to create my library file (mylib.c).
Thanks for all the help/suggestions.