I have a c++ project in a unix environment, that has a CMakeLists.txt. I used Cmake to convert it into an Eclipse project and import it in Eclipse CDT. Now, it says it can't find files in #include "file.h" statements.
This project has more than 20 folders and some of these folders contain the headers. I went to Project Properties -> Include Path and Symbols and added them there, but they don't appear in the Includes folder in my project, after rebuild. I don't understand why is it such a heavy task to do something so simple..
You can specify include directories in the original CMakeLists.txt using the include_directories command and re-generate the Eclipse project. This has the advantage over specifying the include directories in Eclipse because it will work for other CMake targets as well.
Related
I cloned a github C++ repository. The repository is not a VS project. So I manually created a VS C++ blank project and added the files from the repo to the project. The files are not copied. This is not the problem.
The repo directory looks like this:
include\NTL\*.h
src\*.cpp
*.h means a bunch of header files and *.cpp means a bunch of .cpp source files.
The problem is that the .cpp files have #include <NTL/*.h> and when I build, VS fails to locate the header files (No such file or directory). Adding the path to the include to the Include Directories in project properties didn't help.
EDIT: After some experimenting, I've found that the error has nothing to do with the prefix NTL in #include <NTL/*.h> but with whether the files are copied into project directory. Even though the files appear in VS project view, they must be copied into the project directory.
EDIT: The only way I've managed to get the project to compile is to put the whole NTL directory containing header files in project directory. Include Directories and Additional Include Directories in project properties don't seem to have any effect.
All previous No such file or directory errors were the result of some combination of:
Mismatching project properties Configuration and Platform
Some .h files were actually missing from NTL github repo, e.g. mach_desc.h.
The solution to the problem consists of the following:
Under project Properties > C/C++, add the path to the include to Additional Include Directories.
VS project has a separate set of properties for each combination of Configuration and Platform. Make sure that step 1 applies to the active Configuration and Platform. E.g. If the project's currently configured to build for Debug x64 (active Configuration:Debug and Platform:x64), make sure that step 1 applies to Debug x64, and not something like Release Win32 or Release x64, etc.
Use the Windows/Linux-specific zip package from the Downloads page of the official website https://libntl.org/download.html
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.
I'm new with CLion and CMakeList. I'd like to have different locations for:
CLion project files
Build Files
Source and Header Files
When opening default projects all are located under the same directory tree
What are the steps to create such project ('Hello world')?
CLion project files
AFAIK, you can only set one global path for each jetbrains' IDE, by writing IDE_HOME\bin\idea.properties file.
Details can be found here.
Build Files
Settings -> Build, Execution, Deployment -> CMake -> Generation path
You can also set several paths for different build profiles there.
Source and Header Files
Add sources and include directories in CMakeLists.txt .
I'm having problems importing my custom static library into my project. I have my library in the same solution as the project that I am trying to include it in.
In the VC++ Directory section of the project properties I have put "$(SolutionDir);" in the Include Directories and "$(SolutionDir)Debug\;" in the Library Directories. It is my understanding that the "$(SolutionDir);" is a macro that defines the root directory right? As the library shares the same solution as the project it also shares the same root directory and the .lib file that is created is in the Debug folder of the root directory.
In the Linker/Input section, I have put "GameEngine.lib;" in the Additional Dependencies. "GameEngine.lib" is the file name of the .lib that is in the Debug folder of the root directory.
When I'm trying to include anything from the library it just doesn't even recognise it as existing when writing:
#include <GameEngine/Rendering/Model.h>
Doing it the way below shows that it can actually find the file, meaning the path exists and is correct but I get linker errors doing it this way.
#include "../GameEngine/Rendering/Model.h"
I am using Visual Studios 2017.
Link to GitHub repo: https://github.com/TheHoester/OpenGLGameEngine.git
Thank you
You need to make sure you set the directories for all build configurations. You have only set the include directories for the "x64" platform so building the "Win32" platform won't work. After adding the directories to the "Win32" platform your project builds correctly.
Note that it is more usual to use "VC++ Directories" for system includes and libraries and to use "C/C++/General/Additional Include Directories" and "C/C++/Linker/General/Additional Library Directories" for linking to your own libraries. There isn't any problem that I'm aware of for using the "VC++ Directories" settings though, just make sure not to modify any of the existing paths in there.
My work mate has shared a project that compiles correctly on his machine. But I have to manually set include folders that are 'sub-folders' of project and 'libs' using Tools / Options / Projects and Solutions / VC++ Directories / Include (or Lib) files.
I am wondering why my work mate is not getting an include or lib file compilation error while I am getting compilation errors? Why I have to correct it as said above? Is there any other location/file than VC++ Directories to specify lib and include folders that my work mate is using?
You can set directories that will be searched by #include <> in:
Project Properties -> Configuration Properties -> VC++ Directories -> Include Directories
You can set directories that will be searched by #include "" in:
Project Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories
the former is for system headers and the latter is for you're own or additional third party headers.
be aware these settings are Configuration (Debug/Release etc.) & Platform (Win32/x86/arm etc.) specific.
If I understand it right your work mate include a file like "file.h" from a project subfolder in the project like:
#include "file.h"
and set the subfolder in the project settings. If you not use the project settings you have to set the settings on your self like you do.
If you write:
#include "subfolder/file.h"
it also should work on yout system without setting the project settings (onlye maybe setting $(ProjectDir))
If you use extern libs which are not saved in the project directory you can set SystemVariabel (google for windows) and use this in the project to make it easier to share.
e.g.
You want to load a lib from folder C:/somelib so you can set up a system variabel "SomeLibPath" with this directory and setup yout project settings with $(SomeLibPath). So over workers have only to setup this system variabel for correct include.
Hope it helps.