[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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
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
Infinity08Commented:
Which is the unresolved external ? And can you show the code ?
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.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Infinity08Commented:
>> Which is the unresolved external ?
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
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 ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kloodzmanAuthor Commented:
no, but bcb searches for X.cpp if X.h is included in the working directory.
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.
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;
}
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 ?
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
kloodzmanAuthor Commented:
no such folders exist...
Infinity08Commented:
kloodzman, when you re-compile the project, is the CSerial.cpp file compiled successfully ? Is there an object file (.o) ?
kloodzmanAuthor Commented:
no, when i compile, the debug_build directory has only unit1.obj, project1.obj,project1.tds.
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 ...
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.
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?
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.).
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?
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?
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)
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
kloodzmanAuthor Commented:
no, using bcb, as you would know if y
kloodzmanAuthor Commented:
ou read the question...
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)
kloodzmanAuthor Commented:
I have... I have added one of them ,then the other,then both, then none and included them....
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.
kloodzmanAuthor Commented:
done that...
Infinity08Commented:
And ?
Kent OlsenDBACommented:

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
kloodzmanAuthor Commented:
yes... I know...Done it all....
Infinity08Commented:
>> yes... I know...Done it all....

And ? What's the result ?

Did the re-compilation generate a CSerial.obj file ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.