Click here to Skip to main content
14,666,484 members
Rate this:
Please Sign up or sign in to vote.
See more:
how to disable LNK4049 error warning?
Posted

Rate this:
Please Sign up or sign in to vote.

Solution 4

The best is not to disable (i.e. ignore) the linker warning, but fix the issue that the linker is prompting: the LNK4049 warning means that you have declare something as __declspec(dllexport) inside a module of your project, and as __declspec(dllimport) on another module of the same project.

If what you want is to reference something that you have instantiated on another module (i.e. another .c or .cpp file), simply declare it using extern.

If you really need to import or export that symbol to/from another executable, you should declare the symbol with the same linkage on both your modules (i.e. or as __declspec(dllexport) on both, or as __declspec(dllimport) on both).
   
Rate this:
Please Sign up or sign in to vote.

Solution 5

Instead of using __declspec(dllimport) and __declspec(dllexport) in header file, which would (most probably) be common for both DLL and the EXE (or another DLL); you can define a common macro:

#ifdef DLL_PROJECT
#define IMPORT_EXPORT __declspec(dllexport)
#else
#define IMPORT_EXPORT __declspec(dllimport)
#endif


For the you need to define DLL_PROJECT in DLL project. You should name this macro to something meaningful, like MP3CODEC_DLL, so that it doesn't clash with some other projects/header files:
#ifdef MP3CODEC_DLL
#define CODEC_IMPORT_EXPORT __declspec(dllexport)
#else
#define CODEC_IMPORT_EXPORT __declspec(dllimport)
#endif</pre>
And then use CODEC_IMPORT_EXPORT in your header file.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

See here[^].
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Add the following as a additional linker option:

/ignore:4049

This is in Properties->Linker->Command Line
   
Rate this:
Please Sign up or sign in to vote.

Solution 6

I found the huge number of 4049 errors in the standard libraries to be due to the COMPILER setting (Only microsoft would put this under compiler settings) "Runtime Library" mismatch. My included library was built with 'MultiThreaded Debug DLL' but my main program was built with 'Multithreaded Debug'. Making 'em match got rid of all those issues.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100