How to fix 'memmove' not declared error in log4cxx - log4cxx

I am trying to cross-compile log4cxx for ARM from a x86_64 machine. During compilation, there is an error saying 'memmove' was not declared in this scope.
I am using a Linaro GCC cross-compiler version 4.9.4. In order to prevent a different issue with the cross-compilation, I am giving CPPFLAGS=-DAPR_IOVEC_DEFINED to the configure command. This is version 0.10.0 of the log4cxx source, as downloaded from the Apache Logging Services website.
The full error message is below:
inputstreamreader.cpp:66:64: error: 'memmove' was not declared in this scope
memmove(buf.data(), buf.current(), buf.remaining());
I know that the "not declared" error usually indicates that the file with the declaration was not included, but it seems unlikely that this would be an issue in the released code.

This error is due to missing include paths in the file, although commit messages in the log4cxx Git repository suggest that the error only occurs with certain versions of the GCC compiler.
To fix the error, add the following includes to src/main/cpp/inputstreamreader.cpp:
#include <cstdio>
#include <cstring>
These includes are present in the most recent version of the file, found on the log4cxx Github repo. The addition of those includes is the only non-formatting change to the file since version 0.10.0. In the commit history of the file, there are mentions of issues with GCC 4.3 and 4.4 due to those missing includes.
I also experienced other not declared errors from other files in log4cxx. They can be fixed in the same fashion and have been fixed in the Github repo.

Related

No rule to make target in QtCreator compilation on Windows with LLVM

I need to compile a cocos2dx project on Windows 10 which has some objective-c++ code, and all that using QtCreator. I've managed to set the compilers in the kit to LLVM (so that objective-c++ code can be compiled), as well as change the qmakespec to win32-clang-g++, however, I'm still getting this error when trying to compile:
error: No rule to make target 'C:/Qt/Qt5.12.9/5.12.9/msvc2017_64/lib/libQt5OpenGLd.a', needed by 'debug/libcocos2d.a'. Stop.
The folder in question contains file Qt5OpenGLd.lib, but doesn't have libQt5OpenGLd.a.
How do I fix this? I can provide more info, but I'm not sure what info is relevant.
I had to use win32-clnag-msvc in order to have it compile a .lib file instead of .a file.

Qt cannot find the standard header

The compilation is failing due to standard Qt include files/ library missing, why?
I have custom toolchain for devices. My compilation fails with messages:
In file included from /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/QtCore/QString:1:0,
from ./menuitems/Item.h:5,
from ./appmessages/AppMessageAgeLimit.h:4,
from appmessages/AMessageDispatcher.cpp:2:
/opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/QtCore/qstring.h:60:22: fatal error: string: No such file or directory
It guess that this toolchain has been configured wrong but I don't know how to fix it. Below is output from "/opt/STM/STLinux-2.3/devkit/sh4/bin/sh4-linux-g++ -v" command - may be it will be useful:
Using built-in specs.
COLLECT_GCC=/opt/STM/STLinux-2.3/devkit/sh4/bin/sh4-linux-g++
COLLECT_LTO_WRAPPER=/opt/STM/STLinux-2.3/devkit/sh4/libexec/gcc/sh4-linux/4.8.2/lto-wrapper
Target: sh4-linux
Configured with: /home/viatcheslavvgavrilov/qt/gcc-4.8.2/configure --target=sh4-linux --prefix=/opt/STM/STLinux-2.3/devkit/sh4 --exec-prefix=/opt/STM/STLinux-2.3/devkit/sh4 --bindir=/opt/STM/STLinux-2.3/devkit/sh4/bin --sbindir=/opt/STM/STLinux-2.3/devkit/sh4/sbin --sysconfdir=/opt/STM/STLinux-2.3/devkit/sh4/etc --datadir=/opt/STM/STLinux-2.3/devkit/sh4/share --includedir=/opt/STM/STLinux-2.3/devkit/sh4/include --libdir=/opt/STM/STLinux-2.3/devkit/sh4/lib --libexecdir=/opt/STM/STLinux-2.3/devkit/sh4/libexec --localstatedir=/opt/STM/STLinux-2.3/devkit/sh4/var --sharedstatedir=/opt/STM/STLinux-2.3/devkit/sh4/share --mandir=/opt/STM/STLinux-2.3/devkit/sh4/man --infodir=/opt/STM/STLinux-2.3/devkit/sh4/info --enable-checking=assert --program-prefix=sh4-linux- --with-local-prefix=/opt/STM/STLinux-2.3/devkit/sh4 --with-sysroot=/opt/STM/STLinux-2.3/devkit/sh4/target --enable-languages=c,c++ --enable-threads=posix --enable-nls --enable-c99 --enable-long-long --with-system-zlib --enable-shared --disable-libgomp --enable-multilib --with-multilib-list=m4,m4-nofpu --enable-symvers=gnu --with-gxx-include-dir=/target/usr/include/c++/4.2.4 --enable-__cxa_atexit
Thread model: posix
gcc version 4.8.2 20131016 (GCC)
The compilation is failing due to standard Qt include files/ library missing, why?
Checking on qt.conf file section Paths prefix usually helps:
[Paths]
Prefix=/some/path
With my several statically built Qt flavors it is usually set to one of:
[Paths]
Prefix=/specific_prebuilt_qt/src/qtbase
And the default prefix may point to one directory up which can be the valid case but then make sure the path to Qt tool-chain is correct. Or where's bin folder for the Qt you intend to use? The folder where qmake tool is.
[Paths]
Prefix=..
Make sure after the prefix path fixed qmake executed for your project before building again.

Cannot find -lQt5Guid and -lQt5Cored

I am currently trying to compile a Qt application that I downloaded from github on my windows machine. I did not have any trouble compiling this on Ubuntu so I was hoping someone could help shed some light on my problem.
I am using Qt-Creator to compile the program.
The exact error messages are:
:-1: error: cannot find -lQt5Guid
:-1: error: cannot find -lQt5Cored
collect2.exe:-1: error: error: ld returned 1 exit status
My first idea when reading those messages was that the windows PATH variable does not include the locations of the libraries. But when I checked, my PATH contained the following:
C:\Qt\Qt5.1.0\5.1.0\mingw48_32\bin;C:\Qt\Qt5.1.0\Tools\mingw48_32\bin;...
Which exists and contains what looks like the correct Dlls.
I am using MingGW rather than the visual studio compiler (although i have it available if needs be).
How can I fix this error and what could be causing it?
EDIT: When I run qmake there does not seem to be any problem. The errors come up when I try to build the project.
Cored is a fundimental part of Qt so it looks like the linker can't see any of the Qt libraries.
Did you install Qt 5.1.0 SDK?
A few things to check:
Do you have a line like this in your .pro file?:
QT += core
You mentioned "Projects section my path" are you talking about the windows PATH variable? these paths should also be in that. You can check with dos command:
echo %PATH%
If these paths are not there, for a test, add them in if this works then something has gone wrong with the local PATH setup (i.e. when running qt creator - if you are using qt creator?)
Finally just check that the debug version of the Qt5Cored.dll exists in that folder (C:\Qt\Qt5.1.0\5.1.0\mingw48_32\bin) because it looks like you are building a debug build (which is why your program is looking for 'd' post-fixed name Qt5Cored and not Qt5Core).

Qt compile error bits/c++config.h not found

I just installed Qt, Qt creator and g++ on the latest version of Mint, and attempted to compile the default hello world project. After configuring a compiler kit I get the following error:
bits/c++config.h: No such file or directiry
/usr/include/c++/4.7/utility
No surprise there is no such file at that location. It appears this is some sort of config file where you specify what architecture you're compiling for.
What package do I install, or how do I write or generate this config file?
c++config.h is not in /usr/include, but rather in an architechture-dependent path. What you need is one of the libstdc++ development packages. You have not specified your platform details but my guess is that what you need is libstdc++6-4.7-dev as the error message refers to 4.7. See full list of packages containing c++config.h under Ubuntu and Ubuntu-likes here.
I don't know of a specific package search for Mint but the Ubuntu one has hit the nail on the head for me.
edit: ah drat, I only noticed this was 8 months old immediately after I posted the answer. Is this bad?

Old versions of Qt in the CmakeMakeFiles that do not exist

I am attempting to compile a software that I have built using Qt, ITK, VTK, using mingw32 on Windows 7. I have successfully done this on many computers, but I am having trouble on my laptop.
I made a mistake when I first installed Qt on this machine, in that I installed the "msvc2010" or visual studio verision of Qt. I had VS installed, and this is what it defaulted to, and I did not change it. Realizing my mistake, I uninstalled all traces of this Qt, and installed the Mingw32 version. The exact version I downloaded was: Qt libraries 4.8.3 for Windows (minGW 4.4, 317 MB)
I installed mingw32, installed qt, all nice and dandy, and now I am compiling my software. It builds beautifully, but during the linking stage I get the following nasty error:
mingw32-make[2]: *** No rule to make target 'C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/
lib/QtOpenGL4.dll', needed by 'x.exe'. Stop.
CMakeFiles\Makefile2:62: recipe for target 'CMakeFiles/x.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/x.dir/all] Error 2
Makefile:74: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Where x is the name of my project.
Note the make target: C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/lib/QtOpenGL4.dll. This is NOT the correct place to look for the DLLs. It is looking at the lib location of my first installation of Qt. The QtSDK folder does not even exist anymore, the new version is under a different folder.
This is sadly also reflected in the link.txt under CMakeFiles that is generated in the build folder by cmake. One of the entries is:
C:\QtSDK\Desktop\Qt\4.8.1\msvc2010\lib\QtGui4.dll
along with many other DLLs.
Clearly, the problem is that Cmake is generating targets for the previous version of Qt.
How can I erase whatever ridiculous cache this is originating from, so that it does not do this? I have reinstalled Cmake, I have reinstalled Qt, I have done everything I can think of. I have verified that the Cmake variable are all pointing to the correct Qt folder (the other one does not exist, so no way we could get to the linking stage if they were incorrect).
Thank you so much.
EDIT:
I get this very pertinent warning, that has the wretched file path in it:
CMake Warning (dev) at CMakeLists.txt:22 (ADD_EXECUTABLE):
Policy CMP0003 should be set before this line. Add code such as
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
as early as possible but after the most recent call to
cmake_minimum_required or cmake_policy(VERSION). This warning appears
because target "x" links to some libraries for which the linker must
search:
comctl32, vfw32, ws2_32, wsock32, -lgdi32, opengl32
and other libraries with known full path:
C:/Qt/4.8.3/lib/libQtGui4.a
C:/ITK/lib/libitksys-4.1.dll.a
C:/VTK/bin/libQVTK.a
C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/lib/QtOpenGL4.dll
CMake is adding directories in the second list to the linker search path in
case they are needed to find libraries from the first list (for backwards
compatibility with CMake 2.4). Set policy CMP0003 to OLD or NEW to enable
or disable this behavior explicitly. Run "cmake --help-policy CMP0003" for
more information.
This warning is for project developers. Use -Wno-dev to suppress it.
I added the "NEW" policy, and the warning went away, but I still have the same problem.
The problem turned out to be that I had installed VTK while I had the old Qt (configured for VS2010 installed). When I included VTK's libraries, it also included DLLs from Qt--but it was still pointing to the old Qt.
I reinstalled VTK, and we got past this step.
Try to regenerate cmake files, :
mingw32-make clean
cmake .
Short version: You need to delete your CMakeCache.txt file in your build directory.
Long version: Whenever CMake searches for external libraries/programes etc (eg. by FIND_LIBRARY which is called when searching for Qt, for example), it saves the result in the cache. On subsequent runs, it simply uses the cached value (if any) instead of searching for the libraries again. Therefore, you need to remove these cache entries so that CMake really searches for the libraries again. Simply delete the CMakeCache.txt and start over. If both versions are installed in parallel, make sure that QTDIR environment variable is set correctly and the path includes <QTDIR>/bin, as CMake relies on qmake to find the relevant libraries.
Note: If you don't want to delete the whole cache, deleting the Qt relevant variables should work, too.
cmake -U *QT_* .
should do the trick.
However, deleting the whole cache is the cleanest solution.

Resources