I've been handed an ancient C++ application and asked to see if I can get it building and running again. I first tried building it using Visual Studio 2022 and ran into a lot of problems, so thought I would try building it in the environment it was used to.
The VCPROJ starts with this:
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="FsxApp"
ProjectGUID="{D0B8B3A6-3037-46F2-93D2-40318F591EEE}"
RootNamespace="FsxApp"
Keyword="MFCProj"
TargetFrameworkVersion="131072"
>
Looking up Visual C++ 9.0 in wikipedia, it says that version maps to "Visual Studio 2008 9.0" so I installed Visual Studio 2008. For some reason, Visual Studio can't find the files that are right in front of it so I had to add $(ProjectDir) to the "Additional Include Directories".
Now, VS complains because it can't find afxwin.h so I added the path of my modern MFC folder, and then it couldn't find winsdkver.h and winapifamily.h, and I found those in subfolders of a folder titled "Windows Kits" that I added to the list.
And now it's complaining because
#if (WINVER < 0x0501)
#error MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header.
#endif
and sure enough, my stdafx.h says
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0500 // Windows 2000 or later. (Necessary to use GetTitleBarInfo())
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0500 // Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0500 // Windows 2000 or later.
#endif
and if I change all of those to 0x0501, it is very unhappy:
winnt.h(7063) : warning C4163: '_InterlockedExchangeAdd8' : not available as an intrinsic function
winnt.h(7349) : warning C4163: '__cpuidex' : not available as an intrinsic function
atltrace.h(92) : error C2065: 'nullptr' : undeclared identifier
atlwinverapi.h(714) : error C2159: more than one storage class specified
atlwinverapi.h(714) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
atlwinverapi.h(714) : error C2440: 'initializing' : cannot convert from 'PFNLCMAPSTRINGEX' to 'volatile int'
atlwinverapi.h(714) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
atlwinverapi.h(714) : error C2440: 'initializing' : cannot convert from 'PFNLCMAPSTRINGEX' to 'int'
atlwinverapi.h(714) : error C2446: '==' : no conversion from 'PFNLCMAPSTRINGEX' to 'int'
atlwinverapi.h(714) : error C2040: '==' : 'int' differs in levels of indirection from 'PFNLCMAPSTRINGEX'
atlwinverapi.h(714) : error C2440: '=' : cannot convert from 'PFNLCMAPSTRINGEX' to 'int'
atlwinverapi.h(714) : error C2440: '=' : cannot convert from 'PFNLCMAPSTRINGEX' to 'volatile int'
atlwinverapi.h(714) : error C2440: '=' : cannot convert from 'PFNLCMAPSTRINGEX' to 'int'
atlwinverapi.h(714) : error C2446: '!=' : no conversion from 'PFNLCMAPSTRINGEX' to 'int'
atlwinverapi.h(714) : error C2040: '!=' : 'int' differs in levels of indirection from 'PFNLCMAPSTRINGEX'
atlwinverapi.h(716) : error C2100: illegal indirection
atlwinverapi.h(716) : error C2064: term does not evaluate to a function taking 9 arguments
atlcore.h(37) : fatal error C1083: Cannot open include file: 'type_traits': No such file or directory
which isn't surprising at all, when one grabs random include folders.
So then I wondered if I could find the correct version of MFC. According to wikipedia, the MFC in use during Visual Studio 2008 was mfc90.dll but if you google "download mfc90.dll" you get a bunch of questionable links, and those that look semi-possible just have the DLLS, not the H files.
Is finding an old version of MFC my best bet? Is there some other way to get an old application building?
Related
I am trying to compile (by porting) some code in Windows 10 that was originally developed for Linux.
The code depends on 2 external libraries: cppkafka and librdkafka.
I saw that vcpkg is able to get the libraries, compile them, and then make them automatically available in Visual Studio 2015 (through the vcpkg integrate install command).
I see that the vcpkg compiles the dependencies for windows 64 (cppkafka and librdkafka) properly, as the .dll, .lib... are all made available on the install folder of vcpkg.
When I try compiling my code in Visual Studio 2015, I see errors concerning the dependencies headers, which for me is unexpected. If vcpkg compiled them, why Visual Studio doesn't? From the vcpkg documentation, I assume they use the same compiler. Next I show some example errors I am getting:
1>------ Build started: Project: AndreKafkaDriver, Configuration: Release x64 ------
1>C:\...\vcpkg\installed\x64-windows\include\librdkafka/rdkafka.h(64): error C2371: 'ssize_t': redefinition; different basic types
1> C:\Siemens\Automation\WinCC_OA\3.16\api\include\winnt\win32.h(47): note: see declaration of 'ssize_t'
1>c:\...\vcpkg\installed\x64-windows\include\cppkafka\header_list.h(265): warning C4267: 'argument': conversion from 'size_t' to 'ssize_t', possible loss of data
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2065: 'queue1': undeclared identifier
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2065: 'queue2': undeclared identifier
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2065: 'mutex': undeclared identifier
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2275: 'std::mutex': illegal use of this type as an expression
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): note: see declaration of 'std::mutex'
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2182: 'swap_queues': illegal use of type 'void'
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2470: 'cppkafka::BufferedProducer<BufferType,Allocator>::swap_queues': looks like a function definition, but there is no parameter list; skipping apparent body
1>C:\...\vcpkg\installed\x64-windows\include\cppkafka/utils/buffered_producer.h(1035): error C2072: 'cppkafka::BufferedProducer<BufferType,Allocator>::swap_queues': initialization of a function
1>kafkaHWService.cxx(29): fatal error C1083: Cannot open include file: 'execinfo.h': No such file or directory
...
Thanks in advance,
Nerea
After migrating my c++ project from QT version 4.2.8 to version 5.5.0 I get the following errors while compiling for some of my files:
C:\program files (x86)\microsoft sdks\windows\v7.0a\include\rpcndr.h(162): error C2632: 'char' followed by 'int' is illegal
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wtypes.h(1123): error C2371: 'BOOLEAN' : redefinition; different basic types
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(959) : see declaration of 'BOOLEAN'
95% of my project is compiling, but the last piece is missing and I don't know where to look anymore.
When I open file rpcndr.h, the error is thrown on the last line of this piece of code.
define small char
typedef unsigned char byte;
typedef byte cs_byte;
typedef unsigned char boolean;
Nowhere in the whole project I use the word boolean, so I don't know where the error message is coming from.
Does anybody have has the same problem? Or maybe kowns the solution?
I don't know anymore.
I have been banging my head on this for a few days now. I tried downloading and compiling the latest boost 1.67.0, to include
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/process.hpp>
But I got the errors seen below when trying to compile (one thing I noticed about it is that the path has slashes going the wrong way in the error log and Im not sure how to fix that?
I tried compiling with standard cmd and also Visual Studio 2013 prompt (same result).
I then tried grabbing the precompiled version from boost site
boost_1_67_0-msvc-12.0-32.exe
And am still getting the same problem. The #include text is not underlined in the editor. And I have additional include directories pointing to:
C:\VisualStudioLibraries\boost_1_67_0
and Linker Additional Library Directories to
C:\VisualStudioLibraries\boost_1_67_0\stage\lib
Does anyone know how to resolve this? If I comment out the #include lines for boost the code compiles without any issues and program runs. My code doesnt use anything from boost yet, so the only boost related stuff in there are the 3 #include lines.
Errors are:
1> MyForm.cpp
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(65): error C3646: 'noexcept' : unknown override specifier
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(72): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(77): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(82): error C2440: '' : cannot convert from 'std::error_code' to 'boost::process::process_error'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(88): error C2440: '' : cannot convert from 'const std::error_code' to 'boost::process::process_error'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(94): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C2146: syntax error : missing ';' before identifier 'Char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C2146: syntax error : missing ';' before identifier 'null_char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(98): error C2144: syntax error : 'char' should be preceded by ';'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(98): error C2143: syntax error : missing ';' before '<'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(99): error C2143: syntax error : missing ';' before '{'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(99): error C2447: '{' : missing function header (old-style formal list?)
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C2146: syntax error : missing ';' before identifier 'Char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C2146: syntax error : missing ';' before identifier 'equal_sign'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thank you all very much.
Well, Im sure this is not the answer most will want to hear, but after trying for over a week to get it to work the only thing that ended up working was to move on to Visual Studio 2017. Everything linked and compiled fine there. Perhaps there is an issue with my VS2013 install (but everything else works flawlessly on it).
I would like to create a project use to call c++ method using c#. So, I need to create a dll file for all of my c++ function. But when i get an error in y sqlite source code such as "AreFileApisASNSI undeclared identifier". So, i import winbase.h which is part of the mingw-w64 runtime package to my visual studio 2012 express DLL project. After import the file, I get many errors such as below:-
error c4430: missing type specifier - int assumed. Note: C++ does not support default - int
error C2143: syntax error : missing ';' before '_stdcall'
error c1003 error count exceeds 100; stopping compilation
error c2061: syntax error: identifier ' WINBOOL'
error c2086: 'int_CRT_INLINE' : redefinition
error c2143: syntax error: missing ';' before ''
error C2146: syntax error : missing ';' before identifier 'LONGLONG'
error C2146: syntax error : missing ';' before identifier 'PVOID'
any solution for those error? please help!!
The documentation for the function has this header requirement:
WinBase.h (include Windows.h)
This is telling you that the function is declared in WinBase.h, but that you should include Windows.h which in turn will include WinBase.h. So, you need to change your include to
#include <Windows.h>
I also wonder why you are talking about mingw considering that your compiler is MSVC. That compiler ships with a comprehensive Windows SDK. Why would you be using an SDK from mingw?
I'm working on windows XP with Visual C++ 2008 Express Eition.
Im trying to include:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
and getting alot of errors like:
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C2146: syntax error : missing ';' before identifier 'glAccum'
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C2182: 'APIENTRY' : illegal use of type 'void'
etc.
My question is: can i use those includes or do i need to get those libraries from somewhere at first?
Thanks.
For reasons known to Microsoft only, the OpenGL headers provided with the various Windows SDKs require that you
#include <windows.h>
before.
You are probably trying to compile it as C++ instead of C, or something along those lines.
Why are you using SDKs named 'v6.0a' with VC++2K8? Are you sure that's the latest OpenGL headers you have? You should be using latest Platform SDK and OpenGL headers whenever possible.