Hi!
As a beginner in Borland C++ Builder I'm facing a Linker Error message which I have no idea of how to deal with. Concretely, my console project called as "my_proj" is calling the function my_func() whose code definition is included in the source file source.cpp (this source file is included in the directory C:\PROGRAMS\my_proj\ together with all the files related to my_proj project). Well, when compiling the project, the following error message appears:

[Linker Error]Error:Unresolved external 'my_func()' referenced from C:\PROGRAMS\MY_PROJ\DEBUG_BUILD\SOURCE.OBJ

As for the relevant content of my source file, it looks something like that

void my_func(); 
int main() 
{ 
    my_func(); 
    return 0; 
} 
void my_func() 
{ 
   ... 
}

A certain IDE setting might be relevant. Concretely, at "Tools > Options > C++ Options", the C:\PROGRAMS directory is set to be both the BPI/LIB output directory and the Package output directory as well. I've chosen that setting since seemed to me in accordance with my intention that C:\PROGRAMS host all my C++ projects.
Could anybody please tell me something useful about how to overcome the mentioned linker error?
Notice this is my first program that involves user-built functions.
Thanks for any idea!

Dani AI

Generated

A quick diagnosis: an "Unresolved external" is a link-time complaint that the call site (the .OBJ that contains the call) could not find a matching symbol definition in any linked object or library. The most likely reasons are (1) the .cpp that contains the function implementation was not compiled/linked into the project, (2) the declaration and definition do not match (signature, namespace, or calling convention), or (3) the function has internal linkage (declared static or in an anonymous namespace). 's suggestion that the implementation file may not be part of the build is the top suspect, and 's comment about directory/path mistakes is relevant when build outputs are redirected.

Practical checks (in this order):

  • Confirm the implementation .cpp is present in the Project Manager. If it is not listed, add it (Project menu or right‑click project → Add/Add to Project).
  • If the file is listed, verify it is not excluded from the active build configuration (check the file's Compile/Exclude setting).
  • Perform a full Build/Rebuild (not just Compile) so link step runs.
  • Look in the project's debug/release output folder for the .obj corresponding to the .cpp that should contain the definition. If the .obj is missing the file was not compiled; if present and the symbol is still unresolved, check the signature/calling-convention issues below.

Correctness checklist and small example layout (separate files):

// myfunc.h
#ifndef MYFUNC_H
#define MYFUNC_H
void my_func();
#endif

// myfunc.cpp
#include "myfunc.h"
void my_func() { /* implementation */ }

// main.cpp
#include "myfunc.h"
int main() { my_func(); return 0; }

Extra causes to watch for: mismatched prototypes (parameters, return type, namespaces), differing linkage (C vs C++ — use extern "C" consistently if needed), wrong calling convention (__stdcall, __cdecl, etc.), or accidentally using static / anonymous namespace for a function that should have external linkage. When build output directories were changed globally, restore or use project-local output folders to avoid misplaced .obj/.lib files.

Recommended Answers

All 2 Replies

Could anybody please tell me something useful about how to overcome the mentioned linker error?

Usually this means that much to your chagrin, you have not actually told the toolchain to build the file into your project.

Make sure that the input locations(directories) that you have specified in the tools-options are correctly pointing to the required libraries and resources. Also check whether you missed a '\' in the directory name.(that is entering c:name instead of c:\name). Good luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.