Novice to VS/c++: help getting project to compile #94
-
I'm trying hard to get HexCtrl into my own project and getting it compiled. One of the reasons I have issues is that there are tons of settings on project level, linker settings, compiler settings, path settings etc which makes this a hell to get it working. I hope to get a step-by-step explanation for adding HexCtrl into an existing project. Maybe other novice users can be helped by this. So first I tried to use the sample project given in HexCtrl to be sure that one builds and works: HexCtrl\VS Projects\HexCtrl.sln Using VS2020 (having latest updates) this works out-of-the-box. My own project works in VS2020, ISO C++20 Standard (/std:c++20) and has Use MFC in a Static Library. Now reading the docs of HexCtrl:
This is already too vague for me. What I did is copy the folder to my project folder and drag-drop the folder ontpo my project in VS2020. All files are added. I first need my project buildable only having done this. So not using any features of HexCtrl, just place the folder into my project and get this buildable. When building I get these messages:
Which is abracadabra to me and no info I can find on this. Is this a blocking error? After that multiple errors like:
I do not have this file indeed and HexCtrl folder does not contain it. So I used the same file which is present in the Sample Dialog project. Now the list of errors has reduced to:
Searching for DllMain I only get the one method defined in my own project. What can I check so that this works? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
Thanks for your help. I'm happy ! I got my project buildable now. I have stdafx.h placed in the root of my project. For those cpp files to find stdafx.h I needed to include the file like this: #include "../../stdafx.h" The cpp file can find it, no errors at design time.
for each cpp file which has relative include path to that file. Seems that the include needs to be consistent for each cpp file to get rid of this error: Add the root folder containing stdafx.h to your project’s include directories in the Visual Studio project settings. This ensures that the relative path is no longer necessary, and you can use:
Add this to the project settings for Additional Include Directories:
Then all cpp files can access stdafx.h without using relative paths. Another issue I encountered. My project was initially a non MFC project.
I solved this by creating a (static) class which has a constructor/destructor which executes the same code as I have in my DllMain method. Now the project builds and works correctly in my application. Now the next step is to use HexCtrl to add new feature to my application. Thanks again for helping !!! |
Beta Was this translation helpful? Give feedback.
Hi,
Indeed HexCtrl is a bit complex project.
You can ignore these messages all together. It's just the compiler can't handle old stuff with new modules` model, it'll be fixed (I hope) in future VS versions.
Cannot open include file: 'stdafx.h': No such file or directory
This one is pretty standard stuff. HexCtrl uses
stdafx.h
for precompiled headers (until it completely moves to modules).You can check it in your project settings:
The nam…