JAL Computing

C++COMProgramming .NET Mac Palm CPP/CLI Hobbies

 

Home
Up

 

Gumption Traps

bulletLINK : fatal error LNK1104: cannot open file
bulletLIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main
bullet Writing IDL with in and out parameters
bulletADO versioning conflict: FAILED(pADOObject.CreateInstance(__uuidof( someObject ))
bullet

Warning C4530: C++ exception handler used, but unwind semantics are not enabled.

LINK : fatal error LNK1104: cannot open file

This error occurs when you try to build a dll that is currently in use by PWS (Personal Web Server). This error occurs even if PWS was manually shut down from the Personal Web Manager. The workaround is to shut down PWS from a DOS prompt. Create a batch file with the command:

C:\WINDOWS\SYSTEM\inetsrv\pws.exe /stop

Now you can create a shortcut to the batch file and place it on your menu bar. You may have to execute this batch file more than once to successfully release the dll. The following article discusses how to release a cached dll under IIS (Internet Information Server).

http://support.microsoft.com/support/kb/articles/Q166/2/79.asp

 

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

This error occurs when you switch from a debug build to a release build. The following is excerpted from the Visual Studio help files:

Note   When building a Release version of a project, you can get the following link error:

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

This error occurs if you are using CRT functions that require CRT startup code. The Release configurations define _ATL_MIN_CRT, which excludes CRT startup code from your EXE or DLL. To avoid this error, do one of the following:

bulletRemove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT startup code to be included. On the Project menu, click Settings. In the Settings For: drop-down list, choose Multiple Configurations. In the Select project configuration(s) to modify dialog box that appears, click the check boxes for all Release versions, and then click OK. On the C/C++ tab, choose the General category, then remove _ATL_MIN_CRT from the Preprocessor definitions edit box.

 
bulletIf possible, remove calls to CRT functions that require CRT startup code and use their Win32 equivalents. For example, use lstrcmp instead of strcmp. Known functions that require CRT startup code are some of the string and floating point functions.


Writing IDL with in and out parameters

While most texts describe the use of [in] or [out, retval] methods, they do not adequately describe the IDL for methods that both take an input parameter and return a parameter. Here are two IDL samples:

[id(85), helpstring("method IsAuthorized")] HRESULT IsAuthorized([in] BSTR SQL, [in] BSTR ID, [in] BSTR PW, [out,retval] BOOL *pVal);

[id(53), helpstring("method GetRecordAt")] HRESULT GetRecordAt([in] long newValue, [out,retval] BSTR *pVal);

ADO versioning conflict: FAILED(pADOObject.CreateInstance(__uuidof( someObject ))

Most C++ ADO programmers use "early binding" to create ADO objects at run time:
if (SUCCEEDED(pConnection.CreateInstance(__uuidof( Connection )))) {

It is also possible to create ADO objects using "late binding" at run time:
if (SUCCEEDED(pConnection.CreateInstance(L"ADODB.Connection"))) {

If you compile your project using early binding and #import "C:\Program Files\Common Files\System\ADO\msado15.dll" your dll will be version dependent upon the registered version of ADO on your development system. If a user tries to create an ADO object using an older version of ADO on their server, the call CreateInstance may fail. One approach is to compile against the _earliest_ version of ADO that provides the needed methods and signatures. Rolling back your development system to an earlier version of ADO is not trivial. Instead, simply compile against the appropriate version of the ADO type library (.tlb)! You don't even need to have the corresponding ADO dll to do this. For instance, the ADO type libraries 2.0, 2.1, and 2.5 are installed by ADO 2.6. If your dll only calls methods in ADO 2.O you could use this syntax:

#import "C:\Program Files\Common Files\System\ADO\msado20.tlb" no_namespace rename("EOF", "adoEOF")

As long as Microsoft does not break binary compatibility the compiled dll should work on systems with ADO 2.0 or better. If you decide to use late binding, you are then responsible to insure that your dll does not call methods and signatures that are not supported by the version of ADO installed on the user's system. This is discussed in the following article:

http://support.microsoft.com/support/kb/articles/Q245/1/15.ASP

Warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX

This warning appears if you add a library such as <string> that uses exceptions. To enable exception handling click on:

Project --> Settings... --> C/C++

Under "Category" Select C++ Language and check the "Enable exception handling". You can now do a rebuild all. You will prompted to save this project setting when you exit the IDE.

Send mail to [email protected] with questions or comments about this web site. Copyright © 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 © 
Last modified: 08/04/09
Hosted by www.Geocities.ws

1