?
Solved

Error LNK2028: unresolved token

Posted on 2007-10-19
18
Medium Priority
?
1,569 Views
Last Modified: 2008-01-09
I am getting the following error:


Error      27      error LNK2028: unresolved token (0A000023) "extern "C" int __cdecl nf_report_usage(struct _iobuf *,struct nfopt_proginfo const *)" (?nf_report_usage@@$$J0YAHPAU_iobuf@@PBUnfopt_proginfo@@@Z) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)      loadcardset.obj      


I would assume it's something to do with how I have my project setup?

For example I have:

Multi-threaded DLL (/MD)
Compile as C++ Code (/TP)

I am excluding:

MSVCRT.lib;MSVCMRT.lib



0
Comment
Question by:directxBOB
  • 7
  • 5
  • 4
  • +1
18 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 20107284
Where is the nf_report_usage function defined ?
0
 
LVL 7

Expert Comment

by:lucky_james
ID: 20107342
you need to include libraries in your project which contain the definition of method nf_report_usage.
0
 

Author Comment

by:directxBOB
ID: 20107380
Cheers lads got me onto the following error which I am now googling:

Error      27      error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ)      report.obj      
0
Technology Partners: 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: 20107390
Wow, very informative error message lol. Are you still linking to msvcmrt.lib ?
0
 
LVL 7

Expert Comment

by:lucky_james
ID: 20107394
seems like you are creating something here......
check is there any object you are creating whose definition lies in another library.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20107396
Can you maybe also show the line of code that the error refers to ? (line 27 in report.cpp I presume)
0
 

Author Comment

by:directxBOB
ID: 20107417
Yeah very old code, being moved to visdual studio, it's doing my nut in.

 I have excluded msvcmrt.lib, 27 is the error number (26 warnings before hand)
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20107423
>>  I have excluded msvcmrt.lib

Try adding it to the linker settings again ...


>> 27 is the error number (26 warnings before hand)

And there is no line that the error is referring to ?
0
 

Author Comment

by:directxBOB
ID: 20107468
Ok I ignore:

MSVCRT.lib;LIBCMT.lib

now getting:

Error      27      error LNK2028: unresolved token (0A000015) "extern "C" __int64 __cdecl _time64(__int64 *)" (?_time64@@$$J0YA_JPA_J@Z) referenced in function "extern "C" __int64 __cdecl `anonymous namespace'::time(__int64 *)" (?time@?A0x5a228d06@@$$J0YA_JPA_J@Z)      getdate.obj      


Will try and narrow this one down...  just another 414 to go..

0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20107484
>> Ok I ignore:

What does that mean ? I think you need those libraries :)
0
 

Author Comment

by:directxBOB
ID: 20107560
From articles I have been reading CLR:Old Syntax in a multithreaded app, unless you compile the C as C++ and of course Zi needs to be disabled, MSVCRT.lib;LIBCMT.lib need to be ignored etc.

Anyway, going back a step or two if I do not ignore MSVCRT.lib;LIBCMT.lib I get:


Error      27      error LNK2028: unresolved token (0A000015) "extern "C" __int64 __cdecl _time64(__int64 *)" (?_time64@@$$J0YA_JPA_J@Z) referenced in function "extern "C" __int64 __cdecl `anonymous namespace'::time(__int64 *)" (?time@?A0x5a228d06@@$$J0YA_JPA_J@Z)      getdate.obj      
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20107634
_time64 should be in the standard Visual C++ libraries, so you need to link to them to use it.

What do you mean by ignore ?
0
 
LVL 7

Expert Comment

by:lucky_james
ID: 20107646
time64.......are using 64 bit time routines??
i think you need to check 'detect 64-bit issues' to yes in the solution ( if you are using visual studio IDE)
0
 
LVL 7

Accepted Solution

by:
lucky_james earned 1000 total points
ID: 20107817
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 1000 total points
ID: 20123294
>>>> What do you mean by ignore ?
He means that the linker settings allow to specify libraries to ignore. That is used for example to ignore single-threaded CRT runtime libraries like libc.lib call all modules already wre supplied by msvcrt.dll

Normally the default linker settings prevent you from having to play with 'ignoring' libraries and 'adding' libraries in the correct order. But with older code or libraries which have the wrong threading model (e. g. single-threaded when you are linking multi-threaded) or 32/64 bit differences or UNICODE/non-UNICODE mixups you can get errors like the one above.

The only senseful way out - I know - is to create a new empty project with the needed settings (if you rename your current project and folders, you can use the current project name), copy the needed source files from the saved project and add these files to the new project. If you got 'unresolved external' errors you should add the library(ies) to the project tree (or if different debug and release libraries put them to linker input modules for either configuration). These libraries should have the same threading-model as your project or you would get similar problems like the ones above.

Regards, Alex
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 20123315
>>>> ... like libc.lib call all modules already wre supplied by msvcrt.dll

should mean

   ... like libc.lib cause all modules already were supplied by msvcrt.dll




0
 

Author Comment

by:directxBOB
ID: 20123420
I got this working over the weekend, I created a new project add all the source files. Removed the main and made it into a static class library. I now use a wrapper to access it. Certainly a long way around it but it allows me to have the old code sit there unchanged and to worry about errors in my new code only.

Cheers for all the help.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20123638
>> >>>> What do you mean by ignore ?
>> He means that the linker settings allow to specify libraries to ignore

Thanks for explaining, Alex. I'm not familiar with Visual C++, as you might already know ;)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

862 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