[Linker Error] Error: Unresolved external

I get the
"[Linker Error] Error: Unresolved external"
message on a borland dev studio platform (XP) while no dll/lib or whatever is required.
(only header and source files. h file included, cpp in working path.)
what could cause this?
kloodzmanAsked:
Who is Participating?
 
Infinity08Commented:
Did you implement those methods ? CSerial::~CSerial() and CSerial::CSerial(). Did you compile the .cpp file containing the implementation (did the compilation succeed ?) ? Is that .cpp file part of the project you're compiling ?
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi kloodzman,

Several things, actually.

If your header file declares a function (method) that doesn't exist, you'll get a clean compile but this kind of linking failure.  Watch VERY carefully for misspellings and make sure that class methods really are prefixed by classname::

If you are linking multiple objects of your own, this is one of the common issues.

If you've changed or are referencing a library that is not one of the Borland libraries you can get this.


My money is on option 1.  :)


Good Luck,
Kent
0
 
Infinity08Commented:
Which is the unresolved external ? And can you show the code ?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
kloodzmanAuthor Commented:
H and CPP files of  the Serial class, http://www.codeproject.com/system/serial.asp.
there could be a vc++ / bcb incompatibility thing.
0
 
Infinity08Commented:
>> Which is the unresolved external ?
0
 
kloodzmanAuthor Commented:
everything related to the class - for example, a code containing only " CSerial serial;" gives


[Linker Error] Error: Unresolved external 'CSerial::~CSerial()' referenced from C:\...\BORLAND STUDIO PROJECTS\TEMP\DEBUG_BUILD\UNIT1.OBJ

[Linker Error] Error: Unresolved external 'CSerial::CSerial()' referenced from C:\...\BORLAND STUDIO PROJECTS\TEMP\DEBUG_BUILD\UNIT1.OBJ
0
 
kloodzmanAuthor Commented:
no, but bcb searches for X.cpp if X.h is included in the working directory.
0
 
sjith2000Commented:
>>H and CPP files of  the Serial class, http://www.codeproject.com/system/serial.asp.
>>there could be a vc++ / bcb incompatibility thing.

The source code that you are referring to in the above specified link will copile and build and successfully in Visual Studio compiler.I am sure that you have not included some files, while building the project.Please check that.
0
 
kloodzmanAuthor Commented:
No idea...

#include <vcl.h>
#pragma hdrstop
#include "Serial.h"
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

__fastcall TForm1::TForm1(TComponent* Owner)
      : TForm(Owner)
{
CSerial serial;
}
0
 
Infinity08Commented:
>> no, but bcb searches for X.cpp if X.h is included in the working directory.

Does it ?

And did you check the other questions I asked ?
0
 
sjith2000Commented:
Hi kloodzman,
Please check that all the .cpp files are places in  "Source Files" and header files are placed in the  folder "Header Files"(Make sure no file is missing).If any file is missing, pls add it to the workspace folders.Then, it will build fine
0
 
kloodzmanAuthor Commented:
no such folders exist...
0
 
Infinity08Commented:
kloodzman, when you re-compile the project, is the CSerial.cpp file compiled successfully ? Is there an object file (.o) ?
0
 
kloodzmanAuthor Commented:
no, when i compile, the debug_build directory has only unit1.obj, project1.obj,project1.tds.
0
 
Infinity08Commented:
>> no, when i compile, the debug_build directory has only unit1.obj, project1.obj,project1.tds.

Then you need to make sure to add the CSerial source files (.h and .cpp) to the project as I said earlier ...
0
 
sjith2000Commented:
Yes.Thats what I also think.Open the workspace,add  the .h files to  "Header Files " and add the .cpp files  to the "Source Files" folders.Make sure  that you are not missing any files.Give Re-build all command.This should solve your problem.
0
 
kloodzmanAuthor Commented:
->Yes.Thats what I also think.Open the workspace,add  the .h files to  "Header Files " and add the .cpp files  ->.to the "Source Files" folders.Make sure  that you are not missing any files.Give Re-build all command.This ->should solve your problem.

I just said i dont know what the "Header Files "  and "Source Files" mean. where is it? what menu?
0
 
Infinity08Commented:
Did you read my post ? You need to add the source files that you downloaded to the project (just like you added the source files that are currently there : unit1.cpp eg.).
0
 
kloodzmanAuthor Commented:
Did you goto the url? there are two files - CSerial.cpp and CSerial.h. thats it. both in the correct path, everything included. if this was trivial, it probably wouldnt be on EE, now would it?
0
 
kloodzmanAuthor Commented:
well, forget it. i can go around it (copying all the code to one file. very elegant, I know...)
to get rid of these points, if someone can please refer me to a free MODBUS (RTU) class (crc and all)
that will work on bcb?
0
 
Infinity08Commented:
>> Did you goto the url? there are two files - CSerial.cpp and CSerial.h.

Well, but the CSerial.cpp file is apparently not compiled when you rebuild your project. So, that means that it wasn't added to the project. So, that means you need to add it to the project as has been said a few times earlier ... Did you try that already ? (you should have an option somewhere to add a file to the project)
0
 
sjith2000Commented:
OK kloodzman.I will explain.I am not sure which compiler are you using.If you are using the VC++6 compiler, when you open the workspace file(the file with the extension .dsw), you will get the folders "Source files", "Header files" in the Workspace explorer.If your worspace is not visible in the editor, use the command Alt + 0 to show the workspace explorer.Now you can right click in the "Source Files" folder to add the .cpp files and  right click in the "Header files" folder to add the header files.Now you do re-build.Hope this will solve the problem
0
 
kloodzmanAuthor Commented:
no, using bcb, as you would know if y
0
 
kloodzmanAuthor Commented:
ou read the question...
0
 
Infinity08Commented:
It doesn't matter which IDE you use, kloodzman. Can you just try to add the CSerial.cpp and CSerial.h files to the project, then rebuild the project, and see if your problem is fixed ? (As I've already suggested a few times before)
0
 
kloodzmanAuthor Commented:
I have... I have added one of them ,then the other,then both, then none and included them....
0
 
Infinity08Commented:
>> I have... I have added one of them ,then the other,then both, then none and included them....

And what was the result ?

You have to add both (you have to see them in the project tree, together with the other source files). Then you have to do a re-build of the project.
0
 
kloodzmanAuthor Commented:
done that...
0
 
Infinity08Commented:
And ?
0
 
Kent OlsenData Warehouse Architect / DBACommented:

Let's go back to the basics.  :)  This is a Borland IDE and all of their IDE's are derived from the same code base.

Adding a source file to the project is just a few clicks.

  Project / Add to Project

An "Open File" dialog box will display.  Select the source file (C or CPP file) to be added to the project.

The header file is associated with the C/CPP file by #include directives.  They are NOT added to the project.  Note that the header file should be quoted, not bracketed, unless the header file is located in one of the default libraries.

#include "myfile.h"



Sorry for being absent...
Kent
0
 
kloodzmanAuthor Commented:
yes... I know...Done it all....
0
 
Infinity08Commented:
>> yes... I know...Done it all....

And ? What's the result ?

Did the re-compilation generate a CSerial.obj file ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.