Compiling C++ file with CMAKE (Unrecognized '-rdynamic') - c++

I am trying to add a single C++ file to a working CMAKE project.
The project is building fine when I only have C files in the project. However, as soon as I add a cpp file to the ADD_EXECUTABLE section of CMakeLists.txt I get the following error: arm-none-eabi-gcc: error: unrecognized command line option '-rdynamic'.
Does anyone have any idea what might be going on here? Or what I could do to fix it?
Thanks so much for the help!
PS - I have a section at the top of the CMakeLists.txt that says SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # get rid of -rdynamic, but it doesn't seem to be doing that.

Check the armgcc.cmake (or equivalent). I found a field there named CMAKE_SYSTEM_NAME and CMAKE_SYSTEM. These need to be renamed to 'Generic'. This took care of the problem for me.

Related

LNK1181 Error while compiling the core after adding a module

I'm trying to compile my core with some modules but i'm getting the following error when building worldserver:
cannot open input file '..\..\..\modules\RelWithDebInfo\modules.lib' worldserver
This error only happens when compiling with the mod-gain-honor-guard module. I've installed a repack before that came with this module pre-installed, which makes me think that i'm the one missing something.
Any ideas?
Thanks!
I've compiled the core succesfully with only one module, then i've added the one mentioned before and that error came up. CMake didn't show me any error when i regenerated the source for building after adding the module
You always need to regenerate the source in CMake when you add or remove any files to the source.
Did you get the module via git clone? If not, and it's a direct download, you need to remove the -master or any other branch name from the folder name.

Emacs - LSP compile_command.json file?

I m in Arcolinux guyz, I am using clang-lsp in my Emacs.
I m new to programming but I need to prepare a project about Opencv(C++). Whenever I try a script , there is always warning like #include <opencv2/opencv.hpp> file not found ? I have found some things in the internet like command_compile.json but they all uses cmake, when I try to do that, I got following error:
cmake -DCMAKE_EXPORT_COMPILE_COMMDANS=ON /usr/include/opencv4/opencv2/
CMake Error: The source directory "/usr/include/opencv4/opencv2" does not appear to contain CMakeLists.txt.
Can anyone help me ? it is really annoying.
One more question:
My opencv folder is in /usr/include/opencv4/opencv2/ , but my project folder is in ~/Projects/opencv++/
Thanks for attention.
Regards.

CMake + VSCode: configure_file and linting

This may already have been asked and answered, but I couldn't find it if so.
I have VSCode and CMake setup and working fine and I am also using the ms-vscode.cmake-tools extension, and my c_cpp_properties.json has "configurationProvider": "ms-vscode.cmake-tools".
As part of my project CMakeLists.txt file I have:
configure_file(app_version.hpp.in app_version.hpp)
Obviously the actaul app_version.hpp file does not exist until cmake is run on the project and even then the actual file is placed into the build directory. The result of this is that the linter cannot find the file and so lots of red squiggles appear.
Is there a nice way to deal with this to make the linter happy, or do I have to specify a "fake" app_version.hpp with blank #defines etc?
You can tell CMake where to put the result of configure_file(), even back into your source tree. You'll still have to run cmake first. As an example...
configure_file(${CMAKE_SOURCE_DIR}/templates/app_version.hpp.in ${CMAKE_SOURCE_DIR}/include/app_version.hpp)
I can't think of a project that I work on that doesn't write back like this to the source directory, so running cmake at least once after checkout is second nature to me. Remember to set up your version control to ignore the output file, otherwise you get a different kind of "red squiggly line".

How to place header and ui file in different folders using autouic in cmake

According to the documentation, regarding autouic:
If a preprocessor #include directive is found which matches ui_.h, and a .ui file exists, then uic will be executed to generate the appropriate file.
But what if the .ui file is in another folder? I currently get the following error when trying to build:
AUTOUIC : error : process for ui_module.h failed:
File 'C:/app/source/headers/module.ui' is not valid
The ui file is actually located here:
C:/app/source/forms/module.ui
I've tried to add the C:/app/source/forms/ to the include_directories()-macro without success. Any ideas?
Issue mentioned in this answer is now resolved.
This worked in CMake v3.9.0-rc6:
set(CMAKE_AUTOUIC_SEARCH_PATHS your/folder/here)
See documentation of AUTOUIC_SEARCH_PATHS.
Update
A search path, CMAKE_AUTOUIC_SEARCH_PATHS, has been added to CMake
version 3.9.
After further investigation, it seems like it's not possible to do. There is an open issue in their tracking system, but it is so far not implemented:
Add Search path for AUTOUIC

Qt - qstring.h include string error

I am an admitted noob when it comes to Qt and compiling on linux, so forgive me if this is a simple mistake.
I am attempting to compile a program on Ubuntu 14.04 LTS using:
qmake myprogram.pro && make
This application uses Qt4. I am getting a strange error that appears to originate in Qt itself.
In file included from /usr/include/qt4/QtCore/qobject.h:48:0,
from /usr/include/qt4/QtCore/qiodevice.h:46,
from /usr/include/qt4/QtCore/QIODevice:1,
from src/qt/fervor/quazip/zip.c:22:
/usr/include/qt4/QtCore/qstring.h:54:20: fatal error: string: No such file or directory
# include <string>
^
I am guessing this is an environment issue rather than an issue with my program. I have poked around the web and some people have suggested c++ build essentials aren't installed. I have verified the Ubuntu build-essentials package is installed.
Thanks in advance!
EDIT
So I went into the core qt header file, qstring.h, and found a constant that needed to be defined for my environment (QT_NO_STL). When I define that, I get a new error:
In file included from /usr/include/qt4/QtCore/qlist.h:45:0,
from /usr/include/qt4/QtCore/qobject.h:50,
from /usr/include/qt4/QtCore/qiodevice.h:46,
from /usr/include/qt4/QtCore/QIODevice:1,
from src/qt/fervor/quazip/zip.c:14:
/usr/include/qt4/QtCore/qiterator.h:50:79: fatal error: new: No such file or directory
# include <new>
The credit really belongs to #KubaOber, but in the interest of helping others I am posting the answer that solved my problem.
Turns out that I added a dependency (library) and didn't re-create the .pro file with qmake -project.
Thanks!
In my case it worked by just adding the following in the <project>.pro file:
CONFIG += qt
OR add instead:
CONFIG += qt
QT += svg