473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

error LNK2019

Im having several problems with the error LNK2019.

I ve a class that derives from another:

//controller.h

#include MessagesNotifier_Client

class Controller : public MessagesNotifier_Client
{
public:

Controller();
~Controller();

void TempVerification(int a, int b);

};

//controller.cpp

Controller::Controller(){}
Controller::~Controller(){}

void Controller::TempVerification(int a, int b)
{
if ( abs(a - b) 23 ){
NotifyWarningMessage("warning"); //ERROR LNK2019

}

NotifyWarningMessage is a method defined in MessagesNotifier_Client.

Im using Visual Studio .net 2003. and I have a Solution with 2
projects. The controller class is in
the project A, and the MessagesNotifier_Client in project B:

===Solution "BigTest" (2 projects)
== - A
|
------ Controller.h
------ Controller.cpp
== - B
|
------ MessagesNotifier_Client.cpp
------ MessagesNotifier_Client.h

Any ideas where is the problem, or how I should configure VisualStudio?

Thanks for your support.

Aug 9 '06 #1
1 998
Well...
In your example, project A uses the header(s) from project B.
This way project A makes the _declarations_ of project B objects
available for compilation.
But when linker tries to create the final output for the project A, it
looks for the _definitions_ of (method body, implementation, object
code) of the objects have been used (the final code executes the method
body, right?).
The source code for declarations usually reside in header (H, HPP)
files. For definitions - in CPP files.
(The commonly accepted approach is that the definition is put in header
only if the method is inline).
Everything's fine with the definitions of the objects from project A,
because the CPP files from this project were just compiled and linker
is aware of it. It automatically picks up the _object_ files were
produced from CPP files.
But the CPP files from project B were not the part of the project A
compilation process. Linker knows nothing about these ones and as a
result it cannot find the implementation of methods used from project
B.

If you do not want to include cpp files from project B into project A
(which is natural), you should "inform" the linker where to look for
the definitions which are not the results of project A compilation.

Possible solutions:
1. If project B produces statically linked library (.LIB file), the
..LIB filename with path should be put into the "Additional libraries"
linker parameters.
2. If project B produces dynamically linked library (.DLL file), it
also should produce the corresponding .LIB file which the consumers of
project B should link (the DLL dynamic loading - at run-time - is
possible too, but I skip this topic here for simplicity). See (1) for
what to do with that LIB.
3. If project B produces an executable (.EXE), the possible approach
would be to link an object file (.OBJ) which is produced by compiler as
a result of compilation. The name for this .OBJ file is usually the
same as for CPP file been compiled. Try to look up for it in output or
temporay folders of project B. Handle it the same way as you'd do in
(1).

I would recommend to look into the C++ standard, into compilation
process descripion in general and specifically to the description of
the "separated compilation" idea for more details.

Regards,
NSH

Aug 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Usman | last post by:
Hi I've a COM compiled in visual studio 6 that is internally using zlib library (an opensource library for compression). I've no problem compiling that code. But when I moved to visual...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
4
by: jk2l | last post by:
Error 10 error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj Error 11 error...
1
by: Jonas Schneider | last post by:
Heya, don´t know if you know BOINC: it´s a system for distributed computing, therefore distributing work to many computers and creating a little super-computer, see also their homepage:...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.