LNK problems continued

Hard life in C++ lane, I'll tell you.

Trying to compile code with unmanaged CAsyncSocket class I got LNK errors:

Build Log    
Build started: Project: SocketCplus4, Configuration: Release|Win32
Command Lines      Creating temporary file "c:\Documents and Settings\....\My Documents\Visual Studio 2005\Projects\SocketCplus4\SocketCplus4\Release\RSP00000E1064772.rsp" with contents
[/OUT:"Release\SocketCplus4.exe" /INCREMENTAL:NO /MANIFEST MANIFESTFILE:"Release\SocketCplus4.exe.intermediate.manifest" /DELAYLOAD:"OleAcc.dll" /DEBUG /PDB:"c:\Documents and Settings\....\My Documents\Visual Studio 2005\Projects\SocketCplus4\SocketCplus4\Release\SocketCplus4.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /MACHINE:X86  DelayImp.lib
".\Release\CAsynsocket_test1.obj"
".\Release\SocketCplus4.res"]

Creating command line "link.exe @"c:\Documents and Settings\......\My Documents\Visual Studio 2005\Projects\SocketCplus4\SocketCplus4\Release\RSP00000E1064772.rsp" /NOLOGO /ERRORREPORT:PROMPT"

Output Window      Linking...
LINK : warning LNK4199: /DELAYLOAD:OleAcc.dll ignored; no imports found from OleAcc.dll
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
Release\SocketCplus4.exe : fatal error LNK1120: 1 unresolved externals
 Results      Build log was saved at "
file://c:\Documents and Settings\......\My Documents\Visual Studio 2005\Projects\SocketCplus4\SocketCplus4\Release\BuildLog.htm"
SocketCplus4 - 2 error(s), 1 warning(s)

Now,
(1) libcmt.lib IS INCLUDED in two libraries which are referenced in the project. One of them is
\...\Visual Studio 8\VC\lib. The fields in the project database where I entered them are:
Project-->properties-->Linker-->General-->Additional Library Directories
This is how it is recommended in C++ Linker Options MSDN article: "/LIBPATH (Additional Libpath)"
In addition to that,
Link Library Dependencies is set to "Yes"
Use Library dependency Inputs -- "Yes"

(2) OleAcc.dll - I ran into a problem with it as well. I found the .dll file in two directories: C:\I386 and C:\WINNT\System32\. When I included the file into Project-->Properties-->Linkre-->Input it gave me an error: Error   1   fatal error LNK1107: invalid or corrupt file: cannot read at 0x2A0   C:\I386\oleacc.dll. It is corrupt in both directories.

I have this .dll file in two other partitions installed just recently: Windows Server 2003 G:\Windows\System32. I linked to it: the same error. I've got this file on another partition with Win2K Pro and SQL Server. The same error. What is going on

(3) I cannot even start guessing what the last error means: mainCRTStartup is missing in .exe file, if I read it correctly. Where can I get it

I need to get a handle on it. It is getting ridiculous.

Aside from helping me with the above, could you give me a pointer to a handbook or a manual describing a general way to handle such problems

Thanks.


 




Answer this question

LNK problems continued

  • bsierad

    I don't know anything about these header or .cpp files. If you have the WinMain method then you need to use the linker option /SUBSYSTEM:WINDOWS and not /SUBSYSTEM:CONSOLE as your build log is indicating.

    As for your question regarding oleacc.dll, I believe the file is part of PlatformSDK\lib. I don't believe you should be using the one in the System32. Nevertheless, folks on the win32 dev newsgroups would know more about such files: http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.win32.programmer.ole&lang=en&cr=US

    Thanks,
      Ayman Shoukry
      VC++ Team



  • Fritz Bilda

    oleacc.dll IS NOT a part of platformSDK\lib. There are no .dll files in any lib directory at all. Only .lib and .obj extensions.

  • iLinkTech.ca

    Okay.  So now you'll need to replace your WinMain with _tWinMain.  This will either evaluate to wWinMain (which is decorated as _wWinMain@16 since WinMain is defined using the __stdcall calling convention) or WinMain, depending on whether Unicode is defined.

    Yes, it's complicated... but that's the cost of writing code that is portable to Unicode and Ascii, whether you asked for it or not. :)

    Another route you can take is to see what the wizard generates on a new Win32 project:

    int
    APIENTRY _tWinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)

    Hope this helps, Alex.

    Brian


  • Pierre PP

    I should have thanked you for the post earlier. I appreciate it.

  • Don Lafontaine

    Thanks, I will be working on it. I did not have Winmain.h. Included it in just now.

    You have answered only a fraction of my questions, though. How about the corrupt oleacc.dll Where can I get a good one

    Thanks.

  • Michael Legner

    Do you have WinMain in your application One of the things that might cause such error is using WinMain but still using the linker option /SUBSYSTEM:CONSOLE. The linker will search for an entry point main in this case and not WinMain

    If you use /SUBSYSTEM:WINDOWS instead WinMain will be used as an entry point.

    Hope this helps!

    Thanks,
      Ayman Shoukry
      VC++ Team


  • ffattizzi

    I included WinMain.h but not WinMan.cpp. No change. The same errors as I reported before.

  • Srini111

    \...\Visual Studio 8\VC\PlatformSDK\lib is included in my project.

  • Larantz

    Setting the /SUBSYSTEM:WINDOWS instead of SUBSYSTEM:CONSOLE resulted in this error:

    Error 2 error LNK2019: unresolved external symbol _wWinMain@16 referenced in function _wWinMainCRTStartup LIBCMT.lib 


  • LNK problems continued