We help IT Professionals succeed at work.

error linking multi threaded app

chronicles asked
Can someone tell my why I'm receiving the following error messages when trying to compile a sample multi-threaded appliction downloaded from microsoft's web site?
 The platform: Windows 98, Machine: PII 300, compiler: VC++6. The threads are created from win32 API calls (Createthread()). Source file: .Cpp. I'm also making wininet API calls from these threads.

//here is the error:

error LNK2001: unresolved external symbol __imp__HttpQueryInfoA@20
An answer I found in the MSDN library states:

(When compiling with /MD, a reference to "func" in your source becomes a reference "__imp__func" in the object since all the run-time is now held within a DLL. If you try to link with the static libraries LIBC.LIB or LIBCMT.LIB, you will get LNK2001 on __imp__func)

I am assuming that /MT generates the same errors. However, this setting is required for multithreaded apps to run.
Watch Question

Do you linke your program with Wininet.lib that librarry requires when using Wininet.lib

You can add the library as following

On menu chose Project / Settings ==> dialog appears ==> choose tab "Link"
and add Wininet.lib in edit box "Object / Library modules"


Thanks a bunch thienpnguyen! Your answer was very helpful. All but one of the errors have clear up.


LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main

//settings: Multithreads has been selected;
//            I am linking with LIBCMT.LIB ;
//            Not included - LIBC.LIB;

//code in question:

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrev  LPSTR lpszArgs, int nWinMode)

//I know the answer's similar to your previous answer but I've seemed to have run out of options of .LIBs to link. Could you please help me out with this one, thanx.
What kind of application you have ? Window or console ?

The easy way is to use wizard to make the kind of project you want. After that
put your files to new project.

From  menu,  choose File / New ==> appear dialog ==>  choose tab "Project" ==> choosse
the kind of project that you want ...

By do this way, VC++ will choose the correct libraries for you.

For setting Multi thread

On menu chose Project / Settings ==> dialog appears ==> choose tab "C/C++"
==> on "category" combox , choose "Code Generation"
==> on "Run-time  library" choose multi-thread that you want

Good luck


Thanx thienpnguyen for the help. It works fine except for one last error message:
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

Can't seem to figure this one out. Please help again.


Disregard the last comment. Your lastest comment didn't appear until I submitted mine.

the application I'm trying to compile is a windows application.

Actually, I'm trying to compile the (Asyncdemo.cpp)
 <a href= "http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/networking/asyncdemo/Default.asp" >
Asyncdemo.cpp </a> downloaded from the Microsoft web site.

 If multithreading is turn off, I can get it to compile without errors, however, the program crashes when I try to run it. With multithreading turned on I received the errors presented to you.
If your project is a console application, you need  the "main(...)" function.
If your project is  Windows application, you need the WinMain(...) function.

In this case, I almost think your project is console application. Therefore, you need to write
the main() function

void main(int argc, char **argv. )

      // do something in here




I guess there's no way to change your comments if something doesn't work as intended, which is why the previous comment looks confusing! sorry about that.

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "thienpnguyen" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/commspt

Per recommendation, force-accepted by
CS Moderator

Experts: please check for "Points For" questions -- there are a bunch in this TA.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.