Delphi 10.1 Build includes file not in project - build

Using a project group including two projects A and B. I'm building project A but it tries to compile a file from project B. The remove file from project option in A does not list the B file I'm trying to exclude.
Tried making a new groupproj including only the A project, but the problem remains -- which causes the Build to fail with errors from the wrongly included B file. Checked the project DPR file also. B-File not there either.
Also tested the presence of the wrong B-File in include statements in project A. No luck with this either. That file is not searchable in a comprehensive Find across all files in the A project.
Project A used to compile and run- but something changed unbeknownst to me.
My answer: Somehow I managed to share a file from project A in Project B. Don't know how I did it, but this tangled everything up quite thoroughly since the shared file had USES statements that the compiler tried to compile.
A LESSON LEARNED! AND THANKS FOR THE HELP.
All explained above.

Related

How to use the GLOP Linear Solver with Visual Studio 2017 [C++]

I've been trying to get this to work for a while but cant figure it out for the life of me.
Here's my situation right now:
I have a Visual Studio project (and solution) up and running, and would like to modify it as little as possible. I now feel the need to use GLOP Linear solver within my project, and was wondering how I'd go about doing this.
The code that I've written that uses GLOP works perfectly as a standalone .cpp file :
[ this .cpp file is placed in the same directory as the resources for GLOP, and compiles and runs perfectly after creating and using the make command as mentioned here https://developers.google.com/optimization/introduction/cpp
]
I would now like include this code in my project, and run it as a part of my project rather than as standalone code. As I'm currently using MSVS 2017, I was wondering how I'd go about doing this as the current tricks I've used (copying and pasting all the resources for GLOP in the project folder, among other things) don't seem to be working and my error list keeps growing, and using the make commands is obviously not an option as the code needs to embedded amongst other code.
Please explain to me like I'm five years old - what files are supposed to go where, what linkages am I supposed to perform and what other.
I suppose you have already downloaded and extracted the binary archive:
or-tools_VisualStudio2017-64bit_v6.8.5452.zip
When running the make rcc command to build a C++ example, you should have spotted the needed flags to use in your project.
First you need to configure your project to add the include directory:
Configuration Properties>>VC++ Directories>>Include Directories
Then you must add some preprocessor flags e.g. -DUSE_GLOP
note: you can find here what we use in the Makefile:
Configuration Properties>>C/C++>>Preprocessor>>Preprocessor Definitions
Then add the static library libortools.lib to your linker:
Configuration Properties>>Linker>>Input
Note: Images come from various sites on the internet please adapt it.

Copy Visual Studio project settings to new project?

Background
I'm running Visual Studio Community 2015 on Windows 10, writing C++ code.
I have been handed a solution with two projects in it. I need to create a duplicate of one of the projects, but using different source and header files (containing roughly identical code, but located in another place in the file system).
The project that I want to duplicate uses a lot of libraries, and I don't know how that was set up. All I know is that it works for that project, and I need it to work for the duplicate project too.
Problem
The problem I'm having is that at least one of the libraries does not seem to be recognized. This results in code with a red squiggly line under it, no auto-complete, etc. etc.. (This is not relevant anymore, see Edit 1)
Attempted solutions
I have tried creating a new project with the new source files, adding it to the solution, and manually copying project settings by right-clicking on the existing project, selecting Properties, and copying anything that is not set to its default value. This did not work.
I have tried copying the existing .vcxproj files, adding them to the solution, removing old and re-adding new source and header files. This did not work.
In both cases, when expanding External Dependencies in the Solution Explorer, the old project has a much longer list than the duplicate.
I am aware of this question, but the accepted answer relies on knowing which settings need to be changed. I don't know that, and I don't know how to find out.
Questions
So, is there a way to copy the entire set of settings that controls this?
Alternatively, is there a way I can check in the existing project precisely why it is able to resolve a particular external reference, so that I can find out which setting I need to change in the duplicate?
Edit 1
Well, now I feel stupid. I've been fighting this issue for a few days now, but I've made a few incorrect assumptions about the files I have.
It turns out, the second set of header files (located at a new place in the file system) are similar, but not identical, to the old ones. So at first glance, they look identical, and I never bothered to check.
The new header files has #if defined(WIN64) before the relevant #include statements, which of course is why the library wasn't being included.
So, my new question is, what's a sensible way to #define WIN64 without modifying the header file? Where can I put that definition so that it's valid in that header file, without changing that header file?
The correct way to use the same project properties for multiple projects would be not copy-pasting properties between them but to use Property Manager. You should figure out how exactly you original project is configured (note that properties for particular file can differ from project properties) and create a corresponding property sheet(s). Then apply this sheet for the new project.

How do i use a bunch of .h and .cpp files to create a static library that can be used in another c++ Project

I am trying to learn C++ from some Stanford Course and they have a custom library which contains a bunch of header files(.h) and their associated source (.cpp) files.
I want to create new C++ projects in xcode 6.x to try out code and include those custom header files in my new projects.
I have no freaking idea how to include those files in my project so that i can peacefully #include "blahblahblah.h" and use functions from that header file without issues.
I am new to both xcode, c++(although i know some coding part) and anything else with this process.
Summary:
I have a folder Library which contains a series of .h and .cpp
files.
I have XCode 6.x.x/Eclipse installed.
I want to create a new C++ project and use #include
"OneOfThoseHeaderFiles.h" and then use a function or something from
those header files.
Also assume i have no clue how to run some command line codes that i see a lot of.
If someone can please tell me in the most simple way(preferably step-by-step) i would be so eternally grateful and sing praises to you until the day i die :)
Note: Either XCode or Eclipse is fine. I really just want to start coding.
I have spent the better part of a whole week trying out xcode, eclipse etc and trying to follow a ton of steps to get it working but i just cant get how to add the files without issues. Either the info seems to be for Xcode 4.x and every menu seems changed or the suggestions are so complicated that a novice like me cant figure it out.
First off, almost all the information for Xcode will be available on the Apple Developer's portal:
https://developer.apple.com/library/prerelease/ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/start_project.html#//apple_ref/doc/uid/TP40010215-CH2-SW5
To create a simple static library on Xcode 6 you start by creating a new project, then under OS X - Framework and Library select Library, on the next window change the Framework to None (Plain C/C++ Library) and static (since that is what your are stating).
Once your project is created, add the existing headers and sources to your project, either by dragging them with the mouse or with the add files drop menu from the right click functionality, you can create a new group in Xcode if you want some order for them.
When adding the files, on the add window shown you can select to either copy them or use their current location.
If needed you might have to change the "header search path" in your target configuration under "Build Settings", if it is the first time you are using Xcode some of this will sound weird but I am sure you will find most of it on the Apple Developers portal in great detail.
If you want to test the files without having to create an external static library you could create a command line project and test them faster and easier.

How can codeblocks go from finding header files to not being able to find them, when none of the source code has changed?

Why would a project be able to compile and find the necessary header files, and then I add a line that it cannot find, it does not compile, I remove that line (the code now looks exactly as it did when it compiled the first time) and now suddenly it cannot find the header files that it could find only a moment ago? I did not change any of the file structures, absolutely nothing changed other than adding a line, removing it, and everything is broken.
I have followed every instruction in the Ogre3D tutorials up to building the first tutorial. Everything works perfectly fine and the first tutorial compiles and runs. So I decide to see if I can get a different tutorial to do the same thing, but alas the compiler throws an error: No such file or directory when looking at the line #include "Ogre.h". So I go back to the first tutorial's framework, I include all the lines and it still compiles as expected and then I decide to remove all of the source files and everything, and I take the very first include directive from the BaseApplication.h, the line is #include <OgreCamera.h>, and I put this lonely line in a single file main.cpp and attempt to compile this 1 line program. The same error occurs, it cannot find OgreCamera.h! What??
So what is so special that the tutorial framework compiles but when I try to do basically the exact same thing it throws a fit.
Update
Even stranger things are happening now... I added the line #include "Ogre.h" to the tutorial framework's BaseApplication.h file, it cannot find Ogre.h. So I remove that line and try to compile the program (which compiled not more than 10 seconds ago) and now it no longer can find OgreCamera.h! But it has literally not changed at all in any shape or form that I can tell. This is confusion of maddening proportions now!
Where the header files are resolved from is not defined in the code itself, but in the IDE and/or code::blocks project preferences. This tutorial is more relevant for setting up the search directories for Ogre header files.
If it was working a short while ago and not now, I would suspect you have probably made a simple mistake like switching from Debug to Release, having only configured the search directories for Debug build in the project properties. (Clicking build options defaults to selecting Debug rather than all configurations). Try to re-add the Ogre directories in both Debug and Release builds.
Code::Blocks also lets you add search directories globally for the IDE, in the compiler and debugger settings for commonly used libraries. You can also create a global variable for the Ogre SDK location to make it simpler to add to each new project. (#ogre.include), rather than adding the full/relative path.
I believe I know what I have done to myself here.. and recreated the problem
I followed the tutorials and setting up an application to the letter, and was having some other problem when I decided to copy the entire project I had already made doing the tedious setup things necessary. Without realizing that copying the entire project by simply copy-pasting the directory does not carry the tedious setup things necessary. And so, probably without paying attention to the "Target is up to date." build message, assuming it compiled I changed the files, it did not compile as expected, and then changed them back to their original state, and it still did not compile because they were no longer up to date.
I am going to remember this... for a long time.

Visual C++ TDD setup

I haven't worked much with Visual Studio before. I've started a personal project in my spare time and I would like to use test-driven development since it has been a huge benefit to me in my Java development. I started this project quite a while ago, and I used CppUnit. I know there are probably other frameworks that are better, but this is what's already in place.
My Visual Stuido 2005 solution has 2 projects in it. It worked fine when the unit tests resided right alongside the application code. As the project grew in size, this became quite cumbersome and inelegant. I created a new project under my solution to house the unit tests (so it now has 3 projects). Everything went fine until I tried to build the solution. Everything compiled, but the unit test project failed to link. The output gives me 51 "unresolved external symbol" errors (LNK2019) for what seems like every function that my tests call.
As far as I can deduce, the problem is the directory structure that Visual Studio creates. Each project gets its own directory, and then below that are the object files and executables that get created. I think the problem is that, while the header files are properly included in each unit test, the linker can't find the cpp files because they are in a different directory. When it fails to find the implementation of a called function, it gives me the 2019 error.
Am I right in my evaluation of the problem? How can I fix it? Do I need to completely reorganize my projects or is it a simple configuration of the linker?
Thanks
Yes, your evaluation sounds pretty good. Try this: In the solution explorer, right click the name of the project that contains your tests and choose "Project Dependencies". Put a check by every project that it is dependent on. That should set up the linker settings so it automatically can find the correct files.
It sounds like the functions/classes that your test project is using from your main projects aren't exported. If code isn't exported, then nothing outside of the DLL/exe that the code lives in can reference it.
A common way that we handle this is to add a define to the project (in the project settings, go to Configuration Properties -> C/C++ -> Preprocessor, the first line has the defines) called something like PROJECTNAME_IMPL (make sure you do this for both Debug and Release configurations!). Then there is a header file (called ProjectNameExport.h) that anything exported includes, which contains something like the following:
#ifdef PROJECTNAME_IMPL
#define PROJECTNAME_API __declspec(dllexport)
#else
#define PROJECTNAME_API __declspec(dllimport)
#endif
Then, when defining a class (for example):
#include "ProjectNameExport.h"
class PROJECTNAME_API Foo
{
};
This has the result of exporting the class when the header file is included in a file within the project, and importing the class when the header file is included in a file in another project (that links to the first project, of course).
I always add the code to be tested to a separate static .lib file, and have the main application EXE and unit tests EXE depend on this. New code is added the .lib project, and the dependency support ensure the EXEs link with no errors. You need to make sure the EXE projects can find the .lib headers, but this will depend on your directory structure. You also have to watch that that the .lib and the EXEs are using the same CRT/MFC library (for example, when using the CRT you can statically link with it or use a DLL).
I find using libs in this way easier to maintain than adding files/headers to multiple projects.
I am using the Boost test framework but I would structure this the same no matter the TDD framework.
A good article on a similar setup can be found here:
http://www.codeproject.com/KB/architecture/Designing_Robust_Objects.aspx