Hi all

I think that I should start this by saying that I am fairly new to C++. Currently, I can only write basic OOP programs.

However, I have been given a task at work to compile and link some old code that we have (roughly 10 years old) to produce an executable. An error is occurring at the linking stage that I cannot seem to solve.

The error messages that I am getting are similar to the one below:

Linking...
.\Reports.def(4) : warning LNK4017: DESCRIPTION statement not supported for the target platform; ignored
   Creating library .\Debug/Reports.lib and object .\Debug/Reports.exp
Reports.exp : error LNK2001: unresolved external symbol "public: bool __thiscall CReportList::ActivateDatabaseReport(unsigned short *,unsigned short *)" (?ActivateDatabaseReport@CReportList@@QAE_NPAG0@Z)
Reports.exp : error LNK2001: unresolved external symbol "public: bool __thiscall CReportList::ActivateReport(unsigned short *)" (?ActivateReport@CReportList@@QAE_NPAG@Z)
Reports.exp : error LNK2001: unresolved external symbol "public: bool __thiscall CReportList::DeactivateReport(unsigned short *)" (?DeactivateReport@CReportList@@QAE_NPAG@Z)
Reports.exp : error LNK2001: unresolved external symbol "public: bool __thiscall CReportList::get_ReportText(unsigned short *,unsigned short * *)" (?get_ReportText@CReportList@@QAE_NPAGPAPAG@Z)
.\Debug/Reports.dll : fatal error LNK1120: 4 unresolved externals
Build log was saved at "file://c:\ORH\SPARSim\SPARSim_Development_JAE\02_PoliceSimulation\Reports\Debug\BuildLog.htm"
Reports - 5 error(s), 1 warning(s)

I think that the problem might be with the file Reports.def (code below).

; Reports.def : Declares the module parameters for the DLL.

LIBRARY      "Reports"
DESCRIPTION  'Reports Windows Dynamic Link Library'

EXPORTS
    ; Explicit exports can go here
	?ReportEventA@CReportList@@QAEXPAVCActivity@@@Z @1
	?ReportList@@YAAAVCReportList@@XZ				@2
	?ActivateReport@CReportList@@QAE_NPAG@Z			@3
	?DeactivateReport@CReportList@@QAE_NPAG@Z		@4
	?StopReporting@CReportList@@QAEXXZ				@5
	?get_ReportText@CReportList@@QAE_NPAGPAPAG@Z	@6
    ?Initialise@CReportList@@QAE_NJAAV?$vector@VCStationReportData@@V?$allocator@VCStationReportData@@@std@@@std@@@Z @7
	?ActivateDatabaseReport@CReportList@@QAE_NPAG0@Z @8

I don't know how a dll works and so have no idea what is going wrong.

Any help would be much appreciated!

Thank you!

I have now solved the problem.

The method name given in the .def file is the "decorated name" eg:

?ReportEventA@CReportList@@QAEXPAVCActivity@@@Z

The format of these decorated names has changed slightly through the versions of Visual Studio, hence why it was not working.

I used DUMPBIN to get the correct decorated name for the version of Visual Studio that I am using, amended the .def file accordingly, and it now works!

JimSim

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.