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

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?

Related

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

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)

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

Setting up Aquila for my c++ Project in Visual studio 2012

I want to use Aquila DSP to compute MFCC features in my project and trying to make it work.I followed this tutorial but after mingw32-make install on the source code pulled from Aquila's git repo, it generates only libAquila.a in lib folder. I tried changing my project's include and library dependencies using these generated files after install. Also tried adding FindAquila.cmake and tried building my project with cmake for VS 2012, still no luck. Keep getting "aquila/global.h" no such file or directory when I try to include "aquila/global.h".
I also tried building Aquila with cmake for VS 2012 and able to compile it and it generates .lib files as well, but not sure how to proceed with that.
If anyone knows how to make it work, it will be great help.
So, I made it work with Visual studio 2013. Now what I am doing is I am building Aquila with both Mingw and with VisualStudio. Mingw gives required include files and visual studio build gives required .lib files. I am building Aquila in VS 2013 with configuration type static lib (project properties >> General >> Configuration type) for both debug and release configuration and then I build the project.
For Mingw, first I use cmake GUI with mingw cmakefiles configuration and then run mingw32-make install in the build directory, which will put the include, lib and share files in the installation directory( usually C:\\Programme files\\Aquila.
Now I create a Folder Aquila and put include and share from above path and create a new folder lib with two subfolder debug and release. Here I put two .lib files in each folder (aquila.lib and Ooura_fft.lib) (debug libs in debug and release libs in release folder, they will be VS build folder). Once this is done, in my project setting, I add Additional include directories under C++ >> general, Addiotnal library path under linker >> general and names of libraries under linker >> input for both bebug and release configuration. After doing all these things, now the library works with my project.

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>

How to add specific header folders to Eclipse?

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.