Why can't Visual Studio compile my QT Project because it doesn't find the libraries? - c++

I have a project that compiles perfectly at school. However, when I try to compile it, it says: "fatal error C1083: unable to open the include file: 'QtCore/QDate' : No such file or directory"
I've installed QT properly, the environment variables are set and in the project I included this: "C:\Qt\4.7.4\include"
Does someone have any clue?

Well the error is pretty clear: it can't find the header file.
So make sure that you have added the correct include path to the projects properties (Configuration Properties -> C/C++ -> General -> Additional Include Directories). Double check that you did this for all the build targets (debug, release, etc).
Next do a manual check, by appending the included 'QtCore/QDate' to the path you added to the project properties, and if the resulting full file path points to the actual file you want to include.
Also check the global visual studio settings for any conflicting include paths: Tools -> Options -> Project and Solutions -> VC++ Directories -> Include files

Related

How to add Include directories in Visual Studio while cross-compiling to a Raspberry Pi?

I'm working on a c++ project on my Raspberry Pi. I'm using Visual Studio 2017 to cross-compile the project to my Raspberry.
But when I try to compile the project, I get the error"cannot open source file" in lots of header files.
I already managed to compile simple projects, but now I need to Include Directories and I don't know the proper syntax to set, on Visual Studio's project properties page, the Include Directories to tell the compile where the header files are stored.
For the PCL library, e.g., I was able to include directories using '$(INCLUDE_PCL)'.
But when I try to include pi's directory '/usr/Include/ni' I can't correctly set the absolute path. Here's an screenshot of my properties page (https://ibb.co/G2dszrx). I haven't set the Linker directories yet, since I'm currently getting errors on the compiling phase.
Does anyone knows how to set absolute path to include directories correctly?
EDITED:
Trying to figure this out, I created a new project (Proj) in which I include the file 'try.cpp' stored in the raspberry's "home/pi/projects" folder. This project is in the "/home/pi/projects/Proj" folder.
In the project property page, I have:
Configuration Properties>General>Remote Build Root Directory --> ~/projects
Configuration Properties>General>Remote Build Project Directory --> $(RemoteRootDir)/$(ProjectName)
C/C++>General>Additional Include Directories --> $(RemoteRootDir)
When I compile the project this path gets created correctly, and the project is saved at the correct place, even if go further into more folders in the remote build project directory, but it can't find the include file "try.h".
How can Visual Studio know where to save the project using '$(RemoteRootDir)', but is not able to add that path include directory?
After some searching I managed to correctly add the Additional Include Directories, and Additional Libraries.
Firstly I was also using OpenNI, to work with the PCL. After many tries, I discovered that OpenNI was not correctly installed. So I managed to install it with apt-get.
Secondly, If you want to include the "/home/pi/someDIR" directory at the Raspberry device, just add "/home/pi/someDIR" to Visual Studio's additional include directories.
For you still trying to achieve this, Merlyn Oppenheim, from visual studio, set up a sample project using VS 2019 and Raspberry PI template -> https://github.com/merlynoppenheim/sample-rasp-inc-headers
For this sample project the Visual Studio properties page should have:
C/C++ -> General -> Additional Include Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/include;%(AdditionalIncludeDirectories)'
C/C++ -> Linker -> General -> Additional Library Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/debug/lib;%(AdditionalLibraryDirectories)'
C/C++ -> Linker -> Input -> Library Dependencies = 'wiringPi;sqlite3;pthread;dl'

Boost C++ Libaries in Visual Studio 2017 C++ Project - "Cannot open include file"

I'm trying to add the Boost C++ Libraries to my C++ project created with Visual Studio 2017.
I have followed the instructions here.
When that didn't work I tried the advice in this post. Neither solutions worked for me.
What I have done:
Downloaded boost_1_69_0-msvc-14.1-64.exe from this precompiled boost libraries page
Installed to D:\local\boost_1_69_0
In my project I added D:\local\boost_1_69_0 to Properties > VC++ Directories > Include Directories and added D:\local\boost_1_69_0\lib64-msvc-14.1 to Properties > VC++ Directories > Library Directories
I have my project set to x64 and the above settings were set in the x64 configuration
When I try to build my project I get this error:
Error C1083 Cannot open include file: 'boost/regex.hpp': No such file or directory
Which points to this line of code in one of my .cpp files:
#include <boost/regex.hpp>
Please go to D:\local\boost_1_69_0 folder and see if you have a sub-folder named include in there. If you do, then instead of D:\local\boost_1_69_0 you need to set D:\local\boost_1_69_0\include in Properties > VC++ Directories > Include Directories
In other words, try to find the file you are including on your hard drive. Look at the full path to the file. Compare that full path with the path you added to the list of include directories (Properties > VC++ Directories > Include Directories) concatenated with the relative path you provided just before the filename in your include directive (boost). See if the two are the same.
If that does not help, then make sure you changed list of include directories for the same build configuration as you are attempting to build (if you build Debug, make sure you changed configuration for Debug too). Since VS 2015 IDE stopped making sure the two are selected in sync, which is annoying.
If your files are copied, then you have to compile the regular library.... If the same version of the compiler copies the machine.
Found out it was failing because I had included the same .cpp file which has the boost include into my unit test project which did NOT have the Include/Library folders set. The settings in my original question work now.

use of Log4cxx in visual studio 2012

I tried to build log4cxx for visual 2012 and, after 4 hours of resolving errors, the build was succesful (i'm not sure :)).
As a second step I tried to create a vs project to test logging.
I used this example but it keep tell me that
mainapp.cpp(2): fatal error C1083: Cannot open include file:
'log4cxx\logger.h': No such file or directory
I already specified in the linker the path of directory debug in additional library directories and I added "log4cxx.lib" additional dependencies .
I'm confused and I don't know how to make it work
thanks in advance for your help
You also need to add the directory, where headers for log4cxx are. This is not for linking phase, but for compiler phase.
This can be done with Project Properties -> Compiler -> Preprocessor (I think, I don't have VS opened now)
You don't include .lib. This file is for linking.
You need to add to includes the directory, which contains directory log4cxx, and that (log4cxx) directory must contain logger.h!

Error including boost libs in VS project

I'm trying to compile a VS2008 C++ project on a 64bit platform. In this project I use boost threads. I can correctly compile the project on a 32bit platform.
On the 64bit platform I downloaded a pre-compiled boost libreries (for 64bit). I added the path to the compiled libs directory in C/C++ -> General -> Additional Include Directories. I'm sure the path is the correct.
When i try to compile I get the error:
Error 34 fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-1_49.lib' BioCpp BioCpp
I'm sure I actually have this file on my computer, and that i correctly set the C/C++ -> General -> Additional Include Directories path.
Maybe I'm missing something else...can someone provide some help?
PS: I'm working on a shared server, I cannot build the libraries.
This is a library, not an include file, so the "Additional Include Directories" setting is irrelevant. Add the path to the "Additional Library Directories" setting under "Linker" in the project configuration.

How to make the visual studio 2008 IDE look at the right place for header files. Compiling Qt/C++ program

I am building an app on Qt 4.6.2 using visual studio 2008. I need to include the header <QtGui\QDir>.
Problem : The QDir header includes several headers. Once of them is qfile.h. Now the ide/compiler is unable to include this file and the error I get is this
c:\devprojects\myprojects\nttoolkit\trunk\external\qt\include\qtcore../../src/corelib/io/qfile.h(45)
: fatal error C1083: Cannot open
include file:
'Qt/include/QtCore/qiodevice.h': No
such file or directory
I cannot change the path in the file qfile.h since it is an external file to my project. How do I get it working.
Thanks.
The various places the preprocessor searches for include files is described in the Remarks section here.
Typically for an "SDK" like Qt people will change their VC++ Directories, Projects, Options under Tools | Options | "Projects and Solutions" | "VC++ Directories" so that the Include Files and Library Files lists include suitable Qt directories. That way, when the preprocessor searches for Qt include files, it will look in the right places and when the linker looks for .LIB files it will find them also.
One downside to changing those lists is that they apply to all projects built from that version of Visual Studio. That can be a pain in the neck if you have different projects that use different versions of an SDK. In those sorts of situations one solution is to create environment variables called INCLUDE and LIBPATH and then launch devenv with the /useenv switch to override the VC++ Directories settings from Tools | Options.
Finally, a third option is to provide the additional include and library folders via the project properties. In Project | Properties | C++ | General the first property is "Additional Include Directories". Values placed there are passed to the preprocessor via the /I switch. Similarly the Project | Properties | Linker | General tab has an "Additional Library Directories" property which gets passed to the linker via the /LIBPATH switch.
This third option seems attractive because it lets you set these additional directories on a project by project basis. The downside is that it "hard-codes" some directory names in the project. That can be a real pain if you move the project to a new machine where the Qt files are in a different directory or when you have to move the Qt directories to a different hard-drive, etc.
In VS2010, I go to:
Project Properties -> VC++ Directories -> Include Directories
And set the location of directories containing headers I need to include. I don't currently have access to a VS2008 install, but I think there is a similar configuration option available.