[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

[Linker Error] Error: Unresolved external

Posted on 2007-10-02
32
Medium Priority
?
575 Views
Last Modified: 2013-12-13
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?
0
Comment
Question by:kloodzman
  • 14
  • 12
  • 4
  • +1
32 Comments
 
LVL 46

Assisted Solution

by:Kent Olsen
Kent Olsen earned 60 total points
ID: 20001372
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
 
LVL 53

Expert Comment

by:Infinity08
ID: 20001376
Which is the unresolved external ? And can you show the code ?
0
 

Author Comment

by:kloodzman
ID: 20001443
H and CPP files of  the Serial class, http://www.codeproject.com/system/serial.asp.
there could be a vc++ / bcb incompatibility thing.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Infinity08
ID: 20002737
>> Which is the unresolved external ?
0
 

Author Comment

by:kloodzman
ID: 20004374
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
 
LVL 53

Accepted Solution

by:
Infinity08 earned 90 total points
ID: 20004758
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
 

Author Comment

by:kloodzman
ID: 20005156
no, but bcb searches for X.cpp if X.h is included in the working directory.
0
 

Expert Comment

by:sjith2000
ID: 20005215
>>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
 

Author Comment

by:kloodzman
ID: 20005275
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
 
LVL 53

Expert Comment

by:Infinity08
ID: 20005307
>> 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
 

Expert Comment

by:sjith2000
ID: 20006001
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
 

Author Comment

by:kloodzman
ID: 20006115
no such folders exist...
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20006355
kloodzman, when you re-compile the project, is the CSerial.cpp file compiled successfully ? Is there an object file (.o) ?
0
 

Author Comment

by:kloodzman
ID: 20006412
no, when i compile, the debug_build directory has only unit1.obj, project1.obj,project1.tds.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20006500
>> 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
 

Expert Comment

by:sjith2000
ID: 20006776
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
 

Author Comment

by:kloodzman
ID: 20006900
->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
 
LVL 53

Expert Comment

by:Infinity08
ID: 20007074
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
 

Author Comment

by:kloodzman
ID: 20007205
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
 

Author Comment

by:kloodzman
ID: 20008329
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
 
LVL 53

Expert Comment

by:Infinity08
ID: 20008508
>> 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
 

Expert Comment

by:sjith2000
ID: 20011948
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
 

Author Comment

by:kloodzman
ID: 20012387
no, using bcb, as you would know if y
0
 

Author Comment

by:kloodzman
ID: 20012390
ou read the question...
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20012752
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
 

Author Comment

by:kloodzman
ID: 20012853
I have... I have added one of them ,then the other,then both, then none and included them....
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20012875
>> 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
 

Author Comment

by:kloodzman
ID: 20013030
done that...
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20013097
And ?
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 20013461

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
 

Author Comment

by:kloodzman
ID: 20014697
yes... I know...Done it all....
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20014991
>> yes... I know...Done it all....

And ? What's the result ?

Did the re-compilation generate a CSerial.obj file ?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question