Eclipse "Makefile Project with Existing Code" can't view nor open source files - c++

I'm using Eclipse 2020-12 release under Linux. I installed C/C++ support.
I have a project that is configured by CMake, using Unix Makefiles generator.
Note that the source files are not in a sub-folder of the folder containing CMakeLists.txt and Makefile:
sde/
code/
cpp and header files
build/
CMakeLists.txt and generated Makefile
From Eclipse, I do File New -> Makefile Project with Existing Code, and then I pickup the folder where my Makefile was generated by CMake (sde/build).
Eclipse opens the project and I can build it from here. But the problem is that the "Project Explorer" tab of Eclipse does not list my source and header files. I see here the CMakeLists.txt and MakeFile, and if I open Makefile I see it has valid absolute paths to my source code files (.cpp and .h), however they are not present in the "Project Explorer". Is there any trick to have them be displayed?
Note: I see the same issue with every Eclipse release I could test (see comments)

Related

Visual Studio C++ how to add header files in a prefix folder

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

How to create a simple CLion C++ CMake project with different locations for Project itself, build products and source files

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 .

How to compile/build/link - the XLNT library?

I downloaded the xlnt library for working with Excel - https://github.com/tfussell/xlnt. Can you please tell me what to do with it further? Honestly, I still can’t understand how among all the files there are in the downloaded archive, and there are 100 of them .hpp and .cpp files, what should I do with them?
1)As far as I understand, they need to be processed by the Cmake program and it seems that the output should appear .lib file, but I absolutely can’t understand how to do it or maybe something else
2)Or how can they be directly processed by Visual Studio 2017?
PS:When I launch Smack, I select the Source folder, the Cmake generates many incomprehensible files, but among them there is not one file with the .lib extension.
Help me please.
With CMake you can obtain the visual studio 2017 project files
and then compile the xlnt library.
Unzip the archive file
Within the xlnt folder, create a new directory and call it build
Launche CMake (GUI)
Browse for the source code folder
Browse for the build folder xlnt/build
With the Configure button select the tool (IDE/compiler) that you want to use
Pressing the Generate button, CMake will generate (inside the build folder)
the visual studio 2017 project files you need to compile the xlnt library
Building the solution, VS 2017 produces the xlnt.lib, xlnt.exp and xlnt.dll files.
The source path you see in the CMake screenshot is incorrect. You must specify the path that contains the "top level" CMakeLists.txt file.
The correct directory is: C:/Users/Zver/source/repos/XLNT Library/xlnt-master.
The CMakeLists.txt file in the above directory tells CMake all necessary subdirectories.
At this point you will see the static compilation option of the library appear.
If you use the MinGW/GCC compiler you must prevent the path from containing empty spaces.
Then you need to rename the directory from "XLNT Library" to "XLNTLibrary". At this point the path would become:
C:/Users/Zver/source/repos/XLNTLibrary/xlnt-master.

CMake Xcode using wrong files in Issue Navigator

I generate an Xcode project from CMake that builds a static library and test executable.
After the library is built, there is a file copy operation that moves the headers to a central directory (an include folder next to the built library).
This directory is not listed in the header search paths for either project (I have verified this inside the Xcode project and CMakeLists files).
When I am working in the generated Xcode project, the Issue Navigator will open the files in the central directory instead of the files used to build the project.
Can anyone tell me why this happens and how I can fix it?
Thanks for your help.
Use a separate build directory. Create a new directory. Navigate to that in terminal and say :
cmake -G Xcode <path_to_source>

GTest with Eclipse CDT - Functions could not be resolved after adding library

I am having an issue getting the Google Test Framework to work in Eclipse CDT, running on Fedora 18.
fuse_gtest_files.py was used to create the gtest.h and gtest-all.cc files in a separate directory (gtest_lib), which was added to the project and excluded from Release/Debug builds
A new build configuration (UnitTests) was made and the .cpp with main() from my src file was excluded
A folder (test) was made to hold my unit test and .cpp with the gtest main(), also excluded from Release/Debug builds
The include path (-l) for the GCC Compiler was updated to include the workspace folder gtest_lib, for both the test and gtest_lib folders. The test folder also includes the src folder.
The library for pthread was added to the GCC Compiler.
Eclipse is now showing that it is able to locate the header gtest/gtest.h, but all the functions that should be contained in gtest-all.cc are coming up as "Could not be resolved". Mainly the InitGoogleTest and RUN_ALL_TEST(). Any suggestions?