Programming notes: February 28, 2014 22:14:04

Source: Internet
Author: User
Error 1: fatalerrorC1189: # error: PleaseusetheMDswitchfor_AFXDLLbuilds correction method: Project-settings-CC, select "CodeGeneration" in the category ", then, if MultithreadedDLL or DebugMultithreadedDLL is selected under Userun-timelibrary to statically link to the mfc Library, run

Error 1: fatal error C1189: # error: Please use the/MD switch for _ AFXDLL builds correction method: Project-settings-C/C, select "Code Generation" in the category ", then, if you select Multithreaded DLL or Debug Multithreaded DLL under Use run-time library to statically link the mfc library, run

Error 1: fatal error C1189: # error: Please use the/MD switch for _ AFXDLL builds

Correction Method: Project-> Settings-> C/C ++, select "Code Generation" in the category, and select Multithreaded DLL or Debug Multithreaded DLL under Use run-time library.

If you statically link the mfc library, you must set the Runtime Library to a static link.
Dynamic Link to the mfc Library, and the Runtime Library must also be set to dynamic link.

Error 2: error C2039: "Enable3dControls": Not a member of "CWinApp"

This function is not directly called in the program. There is no problem during debug debugging, and it suddenly appears during release,
The reason is that this method is no longer supported in the high version,
Correction Method: comment out the following two sentences in afxwin2.inl,
// _ AFXWIN_INLINE BOOL CWinApp: Enable3dControls ()
// {Return TRUE ;}
If you are using MFC in a static library, you need to note the following two sentences:
// _ AFXWIN_INLINE BOOL CWinApp: Enable3dControlsStatic ()
// {Return TRUE ;}

Error 3: error LNK2005

This error is always encountered every time I spent a great deal of time. google has a great god to summarize the common cause of the error. copy here

Source: http://hi.baidu.com/_sherry_liu/item/7a928d0bff3b09dbdde5b086

This warning message is often encountered in the past, because there is no problem in the operation, so I did not go into details. However, I searched the internet for the success prompt "0 errors and 0 warnings. The original problem lies in the reference selection of the default library.
VS2008, project -- Property -- configuration Property -- C/C ++ -- code generation: it has four options:/MT,/MTd,/Md,/MDd, you must make all the databases used use the same configuration, otherwise there will be a corresponding prompt, or even a function that cannot be parsed. Sometimes the library we use is not controllable by ourselves, so we can only set the project attributes to the same option as the library you use.
Error 1 error LNK2005: _ free has defined MSVCRT. lib in libcmtd. lib (dbgheap. obj)
Error 2 error LNK2005: _ malloc has defined MSVCRT. lib in libcmtd. lib (dbgheap. obj)
.....
If a bunch of redefinition errors occur in the same lib and conflict with it is the same lib, the functions of the two lib should be the same. You can select either of them, you only need to enter the databases to be ignored in "ignore specific databases.
Project properties-configuration properties-linker-input-ignore specific libraries: libcmtd. lib
Project properties-configuration properties-General-Use of MFC: use MFC in shared DLL
Conflicts between MSVCRT. lib and libcmt. lib are still common.
The error message shows that the _ isctype and other symbols are repeatedly defined in the msvcrt. lib and libcmt. lib libraries. Why is this problem? This will start with the role of the two databases.
Msvcrt. lib is the C Runtime Library of Multithreaded DLL in VC, while libcmt. lib is the Runtime Library of Multithreaded. In the same project, all source files must be linked to the same C Runtime Library. If a file uses the Multithreaded DLL version, and other files use the Single-Threaded or Multithreaded version library, that is to say, different libraries will cause this warning.
After we understand the meaning of the alarm information, we need to find the cause of the problem. In the project settings, we can see that the current project uses the Multithreaded non-DLL version of The Runtime Library, which indicates that there are other files in the project using the Runtime Library of another version. Obviously, it is the static library of openssl. View the nt under ms in openssl. mak, we can find that openssl uses the compilation switch/MD for compiling in the static library version, that is, the openssl static library is the default C Runtime Library of the Multithreaded DLL version.
The cause is found. There are obviously two solutions. In short, the runtime libraries of the two projects are unified.
The simple method is to change the dynamic library of the project to the C Runtime Library of Multithreaded DLL version.
In some cases, your project may not change the current Runtime Library. You can change the/MD switch in the openssl nt. mak to/MT and re-compile the openssl static library.
The default library "library" conflicts with other libraries. Use the/NODEFAULTLIB: library LNK4098 solution.
You are attempting to link to an incompatible library.


Note:
The Runtime Library now contains commands that prevent mixing different types of commands. This warning is reported if you try to use different types of runtime libraries in the same program or use runtime libraries of debug and non-DEBUG Versions. For example, if you compile a file to use one Runtime Library, and compile another file to use another Runtime Library (for example, single-thread Runtime Library for multi-thread Runtime Library ), and try to link them, this warning will be obtained. All source files should be compiled to use the same Runtime Library. For more information, see use the Runtime Library (/MD,/MT, And/LD) compiler options.




You can use the/VERBOSE: LIB switch of the linker to determine the library to search. If you receive LNK4098 and want to create executable files that use a single thread or a non-Debug Runtime Library, use the/VERBOSE: LIB option to determine the library that the linker searches. The linker outputs LIBC. lib as the Search Library, instead of LIBCMT. lib, MSVCRT. lib, LIBCD. lib, LIBCMTD. lib, and MSVCRTD. lib. You can use/nodefalib Lib for each library to be ignored to notify the linker to ignore the wrong Runtime Library.


The following table shows the databases to be ignored Based on the Runtime library to be used.




To use the first row of Runtime Library, ignore these libraries in row 2nd
Single thread (libc. lib)
Libcmt. lib, msvcrt. lib, libcd. lib, libcmtd. lib, and msvcrtd. lib


Multithreading (libcmt. lib)
Libc. lib, msvcrt. lib, libcd. lib, libcmtd. lib, and msvcrtd. lib


Multiple Threads Using DLL (msvcrt. lib)
Libc. lib, libcmt. lib, libcd. lib, libcmtd. lib, and msvcrtd. lib


Debug a single thread (libcd. lib)
Libc. lib, libcmt. lib, msvcrt. lib, libcmtd. lib, and msvcrtd. lib


Debug multiple threads (libcmtd. lib)
Libc. lib, libcmt. lib, msvcrt. lib, libcd. lib, and msvcrtd. lib


Multi-thread Debugging Using DLL (msvcrtd. lib)
Libc. lib, libcmt. lib, msvcrt. lib, libcd. lib, libcmtd. lib




For example, if you receive this warning and want to create an executable file that uses a non-debug, single-threaded version of The Runtime Library, you can use the following options with the linker:




/NODEFAULTLIB: libcmt. lib/NODEFAULTLIB: msvcrt. lib/NODEFAULTLIB: libcd. lib/NODEFAULTLIB: libcmtd. lib/NODEFAULTLIB: msvcrtd. lib
========================================================== ======================================
LINK: warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use/NODEFAULTLIB: library
LINK: warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use/NODEFAULTLIB: library


Linker Tools Warning LNK4098
Defaultlib "library" conflicts with use of other libs; use/NODEFAULTLIB: library


You are trying to link with incompatible libraries.


Important The run-time libraries now contain ctictives to prevent mixing different types. you'll receive this warning if you try to use different types or debug and non-debug versions of the run-time library in the same program. for example, if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, you'll get this warning. you shoshould compile all source files to use the same run-time library. see the Use Run-Time Library (MD,/ML,/MT,/LD) compiler options for more information.


You can use the linker's/VERBOSE: LIB switch to determine which libraries the linker is searching. if you receive LNK4098 and want to create an executable file that uses, for example, the single-threaded, non-debug run-time libraries, use the/VERBOSE: LIB option to find out which libraries the linker is searching. the linker shoshould print LIBC. LIB and not LIBCMT. LIB, MSVCRT. LIB, LIBCD. LIB, LIBCMTD. LIB, or MSVCRTD. LIB as the libraries searched. you can tell the linker to ignore the incorrect run-time libraries by typing the incorrect libraries in the Ignore Libraries text box on the Link tab of the Settings dialog box in Developer's Studio or by using the/nodefalib Lib: library option with LINK for each library you want to ignore. see the Ignore Libraries (/NODEFAULTLIB) linker option for more information.


The table below shows which libraries shoshould be ignored depending on which run-time library you want to use.


To use this run-time library Ignore these libraries
Single-threaded (libc. lib) libcmt. lib, msvcrt. lib, libcd. lib, libcmtd. lib, msvcrtd. lib
Multithreaded (libcmt. lib) libc. lib, msvcrt. lib, libcd. lib, libcmtd. lib, msvcrtd. lib
Multithreaded using DLL (msvcrt. lib) libc. lib, libcmt. lib, libcd. lib, libcmtd. lib, msvcrtd. lib
Debug Single-threaded (libcd. lib) libc. lib, libcmt. lib, msvcrt. lib, libcmtd. lib, msvcrtd. lib
Debug Multithreaded (libcmtd. lib) libc. lib, libcmt. lib, msvcrt. lib, libcd. lib, msvcrtd. lib
Debug Multithreaded using DLL (msvcrtd. lib) libc. lib, libcmt. lib, msvcrt. lib, libcd. lib, libcmtd. lib




For example, if you have Ed this warning and you want to create an executable file that uses the non-debug, single-threaded version of the run-time libraries, you cocould use the following options with the linker:


/NODEFAULTLIB: libcmt. lib/NODEFAULTLIB: msvcrt. lib/NODEFAULTLIB: libcd. lib/NODEFAULTLIB: libcmtd. lib/NODEFAULTLIB: msvcrtd. lib


The default library "library" conflicts with other libraries. Use/NODEFAULTLIB: library


You are attempting to link to an incompatible library.


Important: The Runtime Library now contains instructions to prevent mixing different types. This warning is reported if you try to use different types of runtime libraries in the same program or use runtime libraries of debug and non-DEBUG Versions. For example, if you compile a file to use one Runtime Library, and compile another file to use another Runtime Library (for example, single-thread Runtime Library for multi-thread Runtime Library ), and try to link them, this warning will be obtained. All source files should be compiled to use the same Runtime Library. For more information, see use the Runtime Library (/MD,/ML,/MT,/LD) compiler options.
You can use the/VERBOSE: LIB switch of the linker to determine the library to search. If you receive LNK4098 and want to create executable files that use a single thread or a non-Debug Runtime Library, use the/VERBOSE: LIB option to determine the library that the linker searches. The linker outputs LIBC. lib as the Search Library, instead of LIBCMT. lib, MSVCRT. lib, LIBCD. lib, LIBCMTD. lib, and MSVCRTD. lib. You can use/nodefalib Lib for each library to be ignored to notify the linker to ignore the wrong Runtime Library.


The following table shows the databases to be ignored Based on the Runtime library to be used.


To use this Runtime Library, ignore these libraries.
Single-threaded (libc. lib) libcmt. lib, msvcrt. lib, libcd. lib, libcmtd. lib, msvcrtd. lib
Multithreading (libcmt. lib) libc. lib, msvcrt. lib, libcd. lib, libcmtd. lib, msvcrtd. lib
Use multi-threaded DLL (msvcrt. lib) libc. lib, libcmt. lib, libcd. lib, libcmtd. lib, and msvcrtd. lib
Debug single-thread (libcd. lib) libc. lib, libcmt. lib, msvcrt. lib, libcmtd. lib, and msvcrtd. lib
Debug multiple threads (libcmtd. lib) libc. lib, libcmt. lib, msvcrt. lib, libcd. lib, and msvcrtd. lib
Use DLL debugging multithreading (msvcrtd. lib) libc. lib, libcmt. lib, msvcrt. lib, libcd. lib, libcmtd. lib


For example, if you receive this warning and want to create an executable file that uses a non-debug, single-threaded version of The Runtime Library, you can use the following options with the linker:


/NODEFAULTLIB: libcmt. lib/NODEFAULTLIB: msvcrt. lib/NODEFAULTLIB: libcd. lib/NODEFAULTLIB: libcmtd. lib/nodefalib lib

Error 4: LINK: fatal error LNK1123: failed during COFF conversion: Invalid or corrupt file


Ultimate solution:
After some updates, the "error LNK1123" error occurs when the Win32 Console Project is created, solution: Change "project", "Project property", "configuration property", "configuration tool", "input", and "output" to "no, however, if you do not create a new project, you must set it once.
When creating the VS2010 Win32 Project, the error "error LNK1123" still occurred according to the above solution. After going online to check information, the solution is:
Step 1: Same as above.
Step 2: Change "project", "Project property", "configuration property", "connector", "inventory file", "embedded configuration", to "no ".
Step 3: Generally, the computer can solve the problem after the last two steps. However, if there is still a problem, click here to solve it:
Whether the computer is a 64bit operating system. If yes, continue 2.
Check that two cvtres.exe exist in the region. One is C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ vc \ bin \ cvtres.exe, and the other is C: \ Windows \ Microsoft. NET \ Framework \ v
4.0.30319 \ cvtres.exe. Right-click Properties | view the version numbers of both, delete or rename an older version, or reset the Path variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.