visual c++ 6.0 - rebuild all throw error C2259 - visual-c++

The project was created using Visual C++ 6.0 and I'm new to using Visual C++. Now in my project, I set up Visual C++ on Windows 10, but when rebuild all below error C2259 throw. Please help me how to fix this error C2259. Thanks in advance.
D:\VS98\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members:
D:\VS98\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject >::CreateInstance(void *,const struct _GUID &,void ** )'

At last, found the issue. One of the method definitions is different.
To resolve,
Check the function declarations and definitions prototypes in the .cpp,.h and .idl files. Also, check if they are same in all the 3 files.
.idl file we usually miss out on modifying since the search result doesn't show the method.

Related

Possible to use older vc6 .lib built in VS2003 in a VS2010 or newer project? Getting LNK2001 errors on one repeated function call (type_info::name)

I'm working on an older c++ Visual Studio 2003 project which uses a static .lib (of which the source code is lost to time) that I would like to move to Visual studio 2010 or newer. There are a bunch of LNK2001 linker errors, all to the same symbol, when trying to build in 2010:
LNK2001: unresolved external symbol "__declspec(dllimport) >public: char const * >__thiscall type_info::name(void)const " (__imp_?>name#type_info##QBEPBDXZ)
After doing some digging, it appears that trying to build with an older static library in a newer version of MS c++ is troublesome or possibly impossible and this particular error occurs because the newer MSVCRT.dll used by VS2005+ has a different definition for type_info::name(void):
type_info::name(__type_info_node*)
There is an MSDN forum issue here with the same problem, which it appears the original poster may have gotten a solution to - he at least got it to build, which I was not able to do using the workaround given of putting the following code into the project:
#include "stdafx.h"
#pragma warning(disable:4273)
struct __type_info_node {
void *memPtr;
__type_info_node* next;
};
extern __type_info_node __type_info_root_node;
class type_info {
public:
__declspec(dllimport) const char* name() const;
__declspec(dllimport) const char* name(__type_info_node*) const;
};
const char* type_info::name() const {
return name(&__type_info_root_node);
}
I tried building in different ways with that code - inserted into an existing file, a new file, and compiling it into a .obj and using the lib.exe tool to update the original .lib with said .obj and then building, but all attempts ended up with the original errors or different ones - redefinition errors for type_info::name. I'm fairly new to c/c++ & VS so maybe I'm missing something.
Does anyone know of a way to workaround this and build in a newer version of VS? Or am I stuck using the 2003 version?

"error C2228: left of '.ToString' must have class/struct/union"

So I recently got Visual Studio 2012. I converted a Visual Studio 2010 solution to a Visual Studio 2012 project. It was working before I converted it.
I have this line of code:
this->Text = global::ProjectName + " (" + global::Type.ToString() + ") - Path Creator 2.0";
where global::Type is:
ref class global {
public:
static Rct3PathType Type;
...
};
...and Rct3PathType is:
enum class Rct3PathType {
Basic = 0x02060206,
Extended = 0x05060506,
Queue = 0x01070107
};
I get an error at compile time where ever I have called global::Type.ToString() saying "error C2228: left of '.ToString' must have class/struct/union". Considering this all compiled completely well BEFORE switching to Visual Studio 2012, I'm not sure what the issue is! :(
Also, when I try to run the last successful build (which was built with Visual Studio 2010), I get runtime error at startup saying "The program can't start becayse MSVCR100D.dll is missing from your computer." I know this probably doesn't relate to the issue at hand, but does anyone know why this may be happening as well?
Thanks for your help,
Alex
"error C2228: left of '.ToString' must have class/struct/union": enum class is also the syntax for a C++11 enum. To make it a C++/CLI enum, give it an accessibility specifier, which is not allowed on a C++11 enum. In other words, private enum class or public enum class will change it from a C++11 enum to a C++/CLI enum. This wasn't a problem in VS2010 because it doesn't support C++11 enums.
"The program can't start because MSVCR100D.dll is missing from your computer.": VS2012 uses a different C runtime than VS2010. MSVCR100D is the Microsoft Visual C Runtime version 10.0, Debug version. This DLL is installed with VS2010, there is no other way to get it. If you have an old Release build, you can get the runtime redistributable from Microsoft (x86 or x64), and install that to make it run. (That will be MSVCR100.dll, no "D" at the end.)

Compiling a program without the the Multi Threaded DLL (Visual C++ 2010)

By default, Visual Studio compiles a project to use the Multi Threaded DLL, found in the Visual Studio runtime. I want to compile my program using only /MT instead of /MD. Granted, that most systems already have this installed, and it's also available as a re-distributable.
When I change /MD to /MT, I get an error:
MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
And four or five similar errors.
To try and fix this I removed LIBCMT.LIB from the default libraries.
I then get the error:
libcpmt.lib(_tolower.obj) : error LNK2019: unresolved external symbol __calloc_crt referenced in function __Getctype
Removing MSVCRTD.lib from the default list leads to similar errors?
It should be noted that:
-This is an OpenGL project, using the glfw library.
-I am using the SOIL image library by lonesock for texture loading.
Without any further precise information, I would say your first problem is that you're somehow mixing release and debug versions of libraries. MSVCRTD.lib is the debug version of MSVCRT.lib.
Either you have some debug settings hanging around in your own projects, or you're linking against debug versions of libraries you're using.
Never ever mix debug and release versions. If you're lucky you get an error like this. In some rare situations all magically seems to work until it doesn't.

fatal error C1001: An internal error has occurred in the compiler

While compiling on x64 plattform I am getting following error:
c:\codavs05\hpsw-sc\ovpacc\tools\codaaccesstest\coda_access.cpp(1572): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\sizeopt.c', line 55)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
------ Build started: Project: asyncexample, Configuration: Release Win32 ------
If I change settings to preprocessor file (Yes) i am not getting any error.
About my environment: Upgrading Microsoft Visual Studio 2005 to 2010
Please help.
I have had this problem with VS2015 while building locally in Windows.
In order to solve it, I deleted my build folder (Output Directory as seen in Properties/General) and rebuilt the project.
This always seems to help when strange things happen during the build.
I’ve encountered this error many times in VC++. Do the following steps. They’ve sometimes helped me with this issue:
Take a look at the exact location, pointed out by compiler error.
Find any external types or classes used there at that location.
Change the order of “include path” of those files found in step 2 and rebuild the solution.
I hope that help !!!!
I am getting same error with VC2012. Setting up the project properties Optimization to Disabled (/Od) resolved the issue.
In my solution, i've removed output dll file of the project, and I've made project rebuild.
I encountered the same error and spent quite a bit of time hunting for the problem. Finally I discovered that function that the error was pointing to had an infinite while loop. Fixed that and the error went away.
In my case was the use of a static lambda function with a QStringList argument. If I commented the regions where the QStringList was used the file compiled, otherwise the compiler reported the C1001 error. Changing the lambda function to non-static solved the problem (obviously other options could have been to use a global function within an anonymous namespace or a static private method of the class).
I got this error using boost library with VS2017. Cleaning the solution and rebuilding it, solved the problem.
I also had this problem while upgrading from VS2008 to VS2010.
To fix, I have to install a VS2008 patch (KB976656).
Maybe there is a similar patch for VS2005 ?
I got the same error, but with a different file referenced in the error message, on a VS 2015 / x64 / Win7 build. In my case the file was main.cpp. Fixing it for me was as easy as doing a rebuild all (and finding something else to do while the million plus lines of code got processed).
Update: it turns out the root cause is my hard drive is failing. After other symptoms prompted me to run chkdsk, I discovered that most of the bad sectors that were replaced were in .obj, .pdb, and other compiler-generated files.
I got this one with code during refactoring with a lack of care (and with templates, it case that was what made an ICE rather than a normal compile time error)
Simplified code:
void myFunction() {
using std::is_same_v;
for (auto i ...) {
myOtherFunction(..., i);
}
}
void myOtherFunction(..., size_t idx) {
// no statement using std::is_same_v;
if constexpr (is_same_v<T, char>) {
...
}
}
I had this error when I was compiling to a x64 target.
Changing to x86 let me compile the program.
Sometimes helps reordering the code. I had once this error in Visual Studio 2013 and this was only solved by reordering the members of the class (I had an enum member, few strings members and some more enum members of the same enum class. It only compiled after I've put the enum members first).
In my case, this was causing the problem:
std::count_if(data.cbegin(), data.cend(), [](const auto& el) { return el.t == t; });
Changing auto to the explicit type fixed the problem.
Had similar problem with Visual Studio 2017 after switching to C++17:
boost/mpl/aux_/preprocessed/plain/full_lambda.hpp(203): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'msc1.cpp', line 1518)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
Solved by using Visual Studio 2019.
I first encountered this problem when i was trying to allocate memory to a char* using new char['size']{'text'}, but removing the braces and the text between them solved my problem (just new char['size'];)
Another fix on Windows 10 if you have WSL installed is to disable LxssManager service and reboot the PC.

Link Error while compiling vc++ project

I am getting the following error.
error LNK2001: unresolved external symbol __localtime64_s
On searching on the internet i found that there is a library WINMM.LIB which is needed to be included. So i added this library in the project options.
But,it still does not help.
Can somebody help in this?
The _s suffix indicates that its actually probably one of the "safe" apis added to Visual Studio 2005 or 2008. There are two leading _'s - the first indicates the function decoration - an extern "C" function using the __cdecl calling convention. The next '_' inidcates that the functions is an OEM (Microsoft in this case) extension to the c-runtime library.
Specifically it seems to be a worker function invoked from 'Program Files\Visual Studio\VS\include\time.inl' when the safe 'localtime' function is called.
So, at a guess I would say that you are not linking in the c-runtime libraries correctly into your application. Are you using any options like "exclude default libraries" or are excluding any specific libraries in your projects settings?

Resources