C++ Builder IDE >> "Unresolved external" while linking

by Liz Albin » Sun, 30 Oct 2005 23:31:00 GMT

On Sat, 30 Oct 2004 17:25:22 +0300, Aleksej Antonenko wrote:

> Any help would be really appreciated.

Have you tried including the implementation in your main file?


--
Good luck,

liz


C++ Builder IDE >> "Unresolved external" while linking

by Zach Saw » Sun, 30 Oct 2005 23:41:33 GMT


You might want to get it filed in QC under linker or compiler -- either the
compiler name mangled the functions incorrectly, or the linker is somehow
couldn't find the correct function... You'll have to dig deep into the obj
file to find out -- there're some tools you can use... google DISPOBJ.








C++ Builder IDE >> "Unresolved external" while linking

by Zach Saw » Mon, 31 Oct 2005 00:50:30 GMT





put dispobj into the same folder as your obj file, or simply change
directory to that folder before you invoke dispobj.
btw, to dig into the obj file, you'll need some knowledge of obj file
format, and how the compiler performs name mangling for functions, and in
your case, templates.

once you get some info on the name mangling for your functions which are
unable to be found by the linker, i think you can go ahead and file it in
QC, detailing all the things you've done.

Make sure you have a test case for them to reproduce as well...
Post the summary of your QC in bdn.QualityCentral newsgroup for flag for
sysop's attention.




"Unresolved external" while linking

by Liz Albin » Mon, 31 Oct 2005 01:14:15 GMT





Because each instantiation of a template must see the implementation.
--
Good luck,

liz


"Unresolved external" while linking

by Michel Leunen » Mon, 31 Oct 2005 03:16:26 GMT




You really seem obsessed with compiler bugs. You even see them where
there aren't any.

Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
http://www.leunen.com/
----------------------------------------


"Unresolved external" while linking

by Michel Leunen » Mon, 31 Oct 2005 04:10:26 GMT




Yes, exactly.


That's the way templates work, I'm afraid.

Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
http://www.leunen.com/
----------------------------------------


"Unresolved external" while linking

by Zach Saw » Mon, 31 Oct 2005 11:24:53 GMT

>

yes, I'm paranoid :) Trained to be so. Engineers are always like this... :)




"Unresolved external" while linking

by Zach Saw » Mon, 31 Oct 2005 11:48:00 GMT

>> You might want to get it filed in QC under linker or compile

Anyway, it's my mistake. Totally forgot that template implementations need
to be in the header along with the declarations. It doesn't have to be
inline with the class declaration (i.e. the implementations can come later
in the header) but it needs to be in the header. Again, I appologize for my
mistake.




"Unresolved external" while linking

by Michel Leunen » Mon, 31 Oct 2005 17:40:10 GMT




export is not part of the standard (yet?). Just a few compilers
implement it.

Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
http://www.leunen.com/
----------------------------------------


Similar Threads

1. unresolved external symbol __endthreadex and unresolved external symbol __beginthreadex

I just don't get it.  I punch in the code JUST as it is written and it doesn't work:

//***************************
//
// Hello.h
//
//***************************

class CMyApp : public CWinApp
{
public:
 virtual BOOL InitInstance();
};

class CMainWindow : public CFrameWnd
{
public:
 CMainWindow();

protected:
 afx_msg void OnPaint();
 DECLARE_MESSAGE_MAP()
};

//**************************
//
// hello.cpp
//
//**************************
#include <afxwin.h>
#include "hello.h"

CMyApp myApp;

////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance()
{
 m_pMainWnd = new CMainWindow;
 m_pMainWnd->ShowWindow(m_nCmdShow);
 m_pMainWnd->UpdateWindow();
 return TRUE;
}

////////////////////////////
// CMainWindow message map and member functions
BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd)
 ON_WM_PAINT()
END_MESSAGE_MAP()

CMainWindow::CMainWindow()
{
 Create(NULL, "The Hello Application");
}

void CMainWindow::OnPaint()
{
 CPaintDC dc(this);

 CRect rect;
 GetClientRect(&rect);

 dc.DrawText("Hello, MFC", -1, &rect,
  DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}

--------------------Configuration: hello95 - Win32 Debug--------------------
Compiling...
hello.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/hello95.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

The project was a Win32 Application.  What have I done wrong?  There is no indication that anything else is necessary but to me it looks like there are some includes not included or some libs not libed that should be included and\or libed.

-- 
George Hester
__________________________________

2. Link error LNK2019: unresolved external symbol

3. unresolved external symbol when link with exp lib

Hi,
I am using VS.NET 2003 with MFC7 and I have a link error:
I use a library dll built with VC60 and mfc4.2, I have the export lib and
include file for that library. The dll implements a Document class (CMyDoc).
In the program when I use RUNTIME_CLASS(CMyDoc) to call CreateObject I got a
link error unresolved external symbol:
"public: static struct CRuntimeClass * __stdcall CMyDoc::GetThisClass(void)"
(?GetThisClass@CMyDoc@@SGPAUCRuntimeClass@@XZ).
I can't call CMyDoc::_GetBaseClass() instead, because it is declared
protected.
I changed the program to use _RUNTIME_CLASS(CMyDoc) instead, and I have a
different unresolved external symbol:
"public: static struct CRuntimeClass const CMyDoc::classCMyDoc"
(?classCMyDoc@CMyDoc@@2UCRuntimeClass@@B)
I know that CMyDoc::classCMyDoc is an export in my dll.

The MFC it's getting worst and worst!






4. ATL and MFC causing link error - LNK2019: unresolved external symb

5. ATL and MFC causing link error - LNK2019: unresolved external

I'm saying that one of my projects that is using "MFC" and not using "ATL" 
compiles and links my CPP/.H file fine.

Another project project that is using "MFC" and "ATL" (as project 
configuration settings) results in the unresolved extenral symbol.

both projects have classes derived from CSingletonObj.





"Brian Muth" wrote:

> 
> >>
> >> error LNK2019: unresolved external symbol "protected: __thiscall
> >> CSingletonObj::CSingletonObj(void)" (??0CSingletonObj@@IAE@XZ) referenced in
> >> function "private: __thiscall CMyClass::CMyClass(void)" (??0CMyClass@@AAE@XZ)
> 
> That certainly looks like a reference to an object that you defined. Are you saying that when you look at the code for CMyClass that 
> you can't find any reference to CSingletonObj?
> 
> Brian
> 
> 

6. Linking errors. - VC++ - Unresolved external Symbol

7. linking 2 projects together - getting 'unresolved external symbol' error

Hi I am hoping someone can help me.

I have set up a VC++ 2005 solution containing three project folders: 
myFunction, myMain1 and myMain2.

myFunction contains a set of functions that I would like to utilise in my 
other projects, namely myMain1 and myMain2.

myMain1 and myMain2 simply try and instantiate the object contained in 
myFunction, so as to utilise the functions within myFunction. myFunction 
builds ok. The problem is that I get an error LNK2019: unresolved external 
symbol error when I try and build myMain1 and myMain2.

Here is the reduced content of the above projects:

1) myFunction project contains:

-----------------------------------

// ttest.h  ----begin

#ifndef TTEST_H
#define TTEST_H

class TTEST
{
 public:

  TTEST();

  void TTEST :: out( void );
};

#endif

// test.h -----end

------------------------------------

// ttest.cpp ----begin

#include <iostream>
#include "ttest.h"

TTEST :: TTEST()
{}

void TTEST::out(void)
{
 std::cout << "hi";
}

// ttest.cpp -----end

------------------------------------

// ttestmain.cpp   ----begin

#include <iostream>
#include "ttest.h"

int main(int argc, char** argv)
{
 TTEST myt = TTEST();

 myt.out();

 int n;
 std::cin >> n;

 return 0;
}

// testmain.cpp ----end

------------------------------------


2) myMain1 project contains:

-----------------------------------
// realmain.cpp   ----begin

#include <iostream>
#include "ttest.h"

int main(int argc, char** argv)
{
 TTEST myt = TTEST();

 myt.out();

 int n;
 std::cin >> n;

 return 0;
}

// realmain.cpp ----end
---------------------------------

Within the myMain project I have gone to properties > C++ > Additional 
include Directories, and placed the path to the directory containing 
testmain.h

Note that when I build myFunction, it works ok and the function outputs "hi" 
to the screen. I want to execute that same function from myMain1's 
realmain.cpp.

This does work if I include all the above files within a 'single' project 
folder within the VC++ solution. however if i have two separate project 
folders as constructted above, it doesnt link and complains of unresolved 
external symbol:

myMain1.obj : error LNK2019: unresolved external symbol "public: void 
__thiscall TTEST::out(void)" (?out@TTEST@@QAEXXZ) referenced in function 
_main
myMain1.obj : error LNK2019: unresolved external symbol "public: __thiscall 
TTEST::TTEST(void)" (??0TTEST@@QAE@XZ) referenced in function _main
F:\Tools\Microsoft\Visual Studio Projects\test\MSVC\Debug\test.exe : fatal 
error LNK1120: 2 unresolved externals

Can anyone tell me what I need to do to gett he above configuration working?

Many thanks.

Peter 


8. Link Error: Unresolved external GetThisClass