Including files in VS 2012 - visual-studio-2012

I want to include a library - I've downloaded it and found exactly four files inside:
.h
.lib
.dll
.def
I've put the header file inside of my project. That's the only thing I did - and the visual throws an error that it cannot open the .lib file.
So I immediately wanted to beg for help on stackoverflow, but I've decided to do a little research first. I've found out that the .dll file should be placed inside of the windows/SYSWOW64 location (for my 64-bit windows 7), I placed it there but VS still displays the same error.
How should I deal with that? Did I missed some step during the "installation"? If so, which ones?

You have to specify the path to the library (*.lib) in your project settings.
(You can put it also into your directory with sources)
The presence of DLL file during build is not required.

Related

Why VTK invoke cmake/vtkobjectfactory.h.ini

I am using VS2017 to compile VTK 8 Example, Cone.cxx, screen as attached. But I do not know how the error show vtkobjectfactory.h.in been invoked?enter image description here
I trace the program and find it initiated by Common/DataModel/vtkPolyData.h
But I can not understand how it worked. Can anyone help on this?
It can't find some include files. Judging by how your #includes are written, you haven't set path to the vtk include files - you have set correct paths for the few files you are including, but those files are including additional files and they are using relative path - for example, if you open your vtkCamera.h, which you are including, you will find it starts with lines like #include "vtkRenderingCoreModule.h", while in your environment, the "vtkRenderingCoreModule.h" is probably somewhere like "Rendering/Core/vtkRenderingCoreModule.h", so it can't find it. If you wanted to do it this way, you would have to change the paths also in all the files that are being included and that is just not reasonable.
A simple solution is to go to your project properties (right click in the solution explorer on your project name -> properties) -> C/C++ ->General: The first line should be "Additional Include Directories". There, you add a new line with path to the include folder of your vtk installation, probably something like "C:\program files\VTK 8.0\include\vtk-8.0\" - if you look in that folder you should find all the vtk's .h files in one place.
Then you can change your code by removing all the folder specifications from the #include paths and simply write #include vtkConeSource.h etc. and all files should be found without issues.

Set up CMakeLists to not change the include statements from TFS project in Android Studio

From a previous question a new one have arisen. I want to include 2 native TFS project libraries stored in two different folders, dependant from each other in my Android Studio project (stored in another folder). If i not specify "../my_lib_path/libFile.h" instead of simply the "libFile.h" i get the error the file is not found. But i dont want to change all includes since it is a TFS project and there are lots of file contained in the libraries!
Your help is highly appreciated!
Add the given directories to those the compiler uses to search for include files. Relative paths are interpreted as relative to the current source directory. So you have to specify "../my_lib_path/libFile.h", that means you need to change all includes, otherwise it will not work.
#Andy Li-MSFT is absolutely right! Though what worked for me in a similar project now was to set a different relative CMakeLists.txt path in the app .gradle file outside the specific Android Studio Project directory:
externalNativeBuild {
cmake {
path "../../whatever_path/my_C_files/CMakeLists.txt"
}
}
After that i was able to compile my C sources flawlessly without changing the include paths of the C project!

Check that no file is forgotten for the installshield project

we actually build an InstallShield project for our application with the functionality to include files dynamic into a component. All files will be taken which are in a specific place.
Because of problems, which are not part of this question, we want to change this to components where we add files explicit to custom separated components.
The question is, is there a best practice for this? We have the small fear that we easily can forget to add files to the component we new created. These can be dll files, .config files, pdfs or just xml.
(We build the installer every night using TFS.)
We found a solution for the problem.
What we wanted to solve:
During the build we want to be informed if files got removed
During the build we want to be informed if new files are missing
we solved this by two more or less easy things.
1. Information if a file is removed
This is easy sone, we have all files added explicitly, each single file is an own component now, if one file is missing the whole project does not build with the exact error message.
2. Information for missing files
For this we wrote a small tool which runs by a prebuild event of the installshield project.
There it opens the *.ism file as an xml file and searches for the "Files" table.
Than it takes all files from the drop folder and looks if all files are in there.
If there are files missing but we don't expect them, like pdb files or test dlls, we have an additional text file we just called "IgnoreList".
The tool skips these files by the check.
Now we are on a very good state to get informed directly on the next morning if the project was able to build or not, and if not what happened, so we can be sure that in the final target application are files are there :-)

MSBuild error "CSC : error CS2001: Source File 'x' could not be found" with Linked Files after upgrading to Visual Studio 2012

After automatically upgrading the project file for a .Net 4.0 web application to work with Visual Studio 2012 everything worked ok at first however when compiling I got lots of errors like this:
Description : Source File '..\..\..\..\..\File Path' could not be found
File : CSC
And when trying to build using MSBuild (passing just the project full path, with no additional parameters) in the "Developer Command Prompt for VS2012" I got basically the same errors:
"CSC : error CS2001: Source File 'x' could not be found"
All errors refer to Linked Files (aspx,cs,etc) located in other web applications projects located at a different deep in our code Branch (that's why all the '....\' at the beginning of the paths)
To me it looks like a problem with the file Length, I had the same problem a while ago when building the projects on our CI server using MSBuild, I was able to manage it by manipulating the project files before building them using a custom script without the need to move the branch around or reduce the deep of the projects, I didn't have to move anything, the important thing at the time it was that developers using Visual Studio 2010 could compile everything without problems. I learned by this that compiling/Building with MSBuild was different that with DevEnv/VS, and for example MSBuild didn't support building Setup projects and DevEnv did.
Since this is happening now with VS 2012/DevEnv 2012 , plus that VS 2012 doesn't support setup projects anymore (like msbuild), plus VS/DevEnv have the same problem with the file length, it looks like VS 2012 its finally using msbuild under the hood or are more tightly integrated, however I didn't find any article to confirm this.
Changing the branch structure/changing the deep of the projects it’s not an option right now due to several reasons (large code base, high number of projects, risk, timing, effort, etc.).
Does someone have an alternative solution or a fix for this issue in Visual Studio 2012?
Regards,
P.D.: BTW I already checked this post MSBuild error with linked files but like I said before changing the paths its not an option right now.
Try getting the Build Logs,
http://msdn.microsoft.com/en-us/library/vstudio/ms171470.aspx
it seems that csc task could not find the source file. One cause it you import the wrong file.
so you have to edit the project file via normal Text Editor.
I found a solution to this issue, when you linked the file, you relative path is recognized by msbuild and go back from there it become your path in a long path however you can change it in the project definition doing right click/unload the project/ and change the path from ../../../ to $(SolutionDir)/../.. until find the file to link, note: it's extend the character from 255 to 300 character.
Check that you have the latest version of the linked files from the other projects. Visual Studio will NOT automatically get them if they belong to another project.
Check that the linked paths are indeed correct. You can monitor what files VS.NET and MSBUILD are trying to access with the help of the SysInternals ProcMon tool (filter on process names and filter out all successes)
If you suspect that the path length is the problem (this will also be visible in the ProcMon tool), you can try to shorten them by linking to the absolute path (C:\X\Y\Z) instead of a relative path (......\Z). The location of the linked files can then remain unchanged.
My 2 cents to this problem... In my case, I had a file created in one project (i.e. ConfigModel) and I had a link to this file in another project but when I renamed the file ConfigModel in the first project to LoginModel for example, it didn't rename the link in the second project causing this error to occur.
I know that i did this question a while ago but for what is worth, The approach that we finally went for was:
Locating the files that were reported as too long.
Reduce the full path length of those files, by reducing the length of the name and/or
the length of the container folder or reducing the folder nesting
level. Therefore reducing the full path length.
Update the links of the changed files (re-linking) on the dependant projects.
This solved the problem with Visual Studio 2012 on developers workstations and on our CI/Deploy servers that used MSbuild.
For my scenario this approach was less risky,and implied less effort than moving complete projects/solutions to reduce their folder nesting level or reducing the folder names, and have to update all the references of the dependant project/solutions.
Ok, I hit this and solved it today. I found it by following a msdn tutorial (https://msdn.microsoft.com/en-us/library/ms379563%28v=vs.80%29.aspx) and here's the command that broke for me:
csc /t:library /out:MyCodeLibrary.dll simpleType.cs
Giving me the message
error CS2001: Source file 't:librabry' could not be found
Which worked after changing the original command to the following:
csc /target:library /out:MyCodeLibrary.dll simpleType.cs
I'm not sure why the short version of the /target flag causes this error, but I've not found anywhere else online noting this cause specifically so I wanted to record it here.
This problem arose for me when I reverted to an earlier version of a git repository. Apparently I didn't add the project file to the repo so when it reverted it didn't revert the project file also. What I did to clear it up was to exclude the missing .cs file from the project by clicking on the missing file in the project Explorer. It was easy to find since it was marked with a warning triangle. Then rebuild the entire solution.
Verify whether the files mentioned in the error do not exist in the corresponding folder.
If their non-existence is intentional, edit the .csproj files and remove the reference for those files.
Build again.
I inherited this issue from a project somebody else was working on, in my case was a .cs file supposed to be generated by an Entity Framework .tt template, but for some reason it wasn't, so the compiler was going all CS2001 about that. I had to update the template and manually run it, everything worked after that.

Why is the .TLB not being re-compiled by MIDL?

In my main project directory, there is a .TLB file. It has old information in it, and it is compiled into the binary -- which I can tell from looking at the compiled binary in a hex editor.
What's weird is that I updated my .IDL in the main VC++ directory and that's compiled into a .TLB in the project build directory (\Debug), but it's not included into the binary.
I resolved the problem by copying \Debug\Project.TLB into the main directory, but why is the newly compiled .TLB not automatically used for the binary?
The TLB is included via the resource script, so if the .rc file points to the TLB in the main project dir, that's the one that will be used.
Was this project upgraded from an older version of Visual Studio? I seem to recall they changed the default output location at some point.
What you should do is go into the .rc file and adjust the path so it points to the actual output location. It can get a little tricky with separating Debug/Release configurations, though...
Another idea is to change MIDL's output to place the TLB in the main project dir, so that the .rc path points to the right thing.

Resources