String regex replace need 6 args but..MinGW , CMake , w7 - c++

I'm trying to build in w7 an aplication that I use on CentOS 6.5 without problems, but i need to compile for Windows 32 and 64 bits.
This program is using RTi libs, but Win libs are made for VS2010, I'm tryng to build with MinGW Gcc 4.x.x , CMake 2.8.12 and Maven 3.02. I corrected some data types incompatibilities but i think that may there are some problems with slash and forward slash between MinGW and Windows 7.
Base program was compiled succesfully, now its time for binaries.
When i execute cmake -G "MinGW Makefiles" expression, I get this errors.
CMake Error at C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:43 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:116 (RemoveCXXComments)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:12 (HasInterfaces)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:59 (GetDDSGeneratedFiles)
CMakeLists.txt:6 (GenerateIDLLibrary)
CMake Error at C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:43 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:65 (RemoveCXXComments)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:74 (FindIncludes)
CMakeLists.txt:6 (GenerateIDLLibrary)
Includes for 'C:/MinGW/msys/1.0/home/blcoalla/trunk/Example/TestProfiles/TestPayload.idl' are
CMake Error at C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:43 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:65 (RemoveCXXComments)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:111 (FindIncludes)
CMakeLists.txt:6 (GenerateIDLLibrary)
Here is an extract from utils.cmake:
Macro to get the content of a file
-----------------------------------------------------------------
macro (GetFileContent OutFile)
#message("Called GetFileContent '${ARGN}'")
SET(cat_prog cat)
IF(WIN32)
IF(NOT UNIX)
SET(cat_prog type)
ELSE(NOT UNIX)
message (FATAL_ERROR "cannot determine the system to call to proper 'cat/type' method")
ENDIF(NOT UNIX)
ENDIF(WIN32)
set (Out)
set (tmp)
foreach(gfcfile ${ARGN})
if (NOT EXISTS ${gfcfile})
message(FATAL_ERROR "Cannot find file '${gfcfile}'")
endif(NOT EXISTS ${gfcfile})
EXECUTE_PROCESS(COMMAND ${cat_prog} ${gfcfile}
OUTPUT_VARIABLE tmp)
set (Out ${Out} ${tmp})
endforeach(gfcfile ${ARGN})
set(${OutFile} ${Out})
#message("Leaving GetFileContent")
endmacro(GetFileContent)
#-----------------------------------------------------------------
# Macro to get includes from an IDL file
#-----------------------------------------------------------------
macro (RemoveCXXComments Output Input)
#message("RemoveCXXComments Input: '${Input}'")
# Remove single line comments
string(REGEX REPLACE "(//[^\n]*\n)" "" ${Output} ${Input})
#message("RemoveCXXComments without single line: '${${Output}}'")
# Remove several line comments in file
string(REGEX REPLACE "(/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/)" "" FileContent ${FileContent})
#message("RemoveCXXComments without multi line: '${${Output}}'")
endmacro (RemoveCXXComments)
#-----------------------------------------------------------------
from CMakeLists.txt6:
GenerateIDLLibrary(TestPayload TestPayload.idl)
from IB.DDS.cmake:59:
# Get expected generated files
GetDDSGeneratedFiles(DDSCXXGeneratedFiles DDSHGeneratedFiles ${IdlFile})
# message("CXX Files expected to be generated: '${DDSCXXGeneratedFiles}'")
#message("H Files expected to be generated: '${DDSHGeneratedFiles}'")

The error message is a hint that one of your variables is empty. You can output the variables and check which one is empty and should not be empty. I'd guess something fails for Windows and a variable is not set. If a variable is empty or not set, CMake cannot see that you gave an argument at all.
If you want to force your regex, you can make quotation marks around the arguments. Then CMake knows that you gave the right number of arguments and it does not complaint about "" as a argument. But that does not fix your real problem, but only calm your current issue. I do not advise you to do so, until you really know that it is ok.

Either Output or Input or FileContent is undefined. The error must be somewhere else, you might use
if( DEFINED ${Output} )
message( "Output defined")
to check for their consistency.
-> As a hint, if you wrote this code, you might substitute
${variable}
with
"${variable}
to avoid using undefined variables (if a "" string is preferable, you still need to address why you're using an undefined variable)

Related

opencv crosscompile:Unexpected CMake generator expression

When doing opencv cross-compilation for embedded devices, in order to use muslc c++, etc., I used this sentence in cmakelists.txt:
set(SYSTEM_LIBRARY_FOR_OPENCV
muslc
muslcsys
stdc++
supc++)
ocv_target_link_libraries(${the_module} PRIVATE
"$<BUILD_INTERFACE:${SYSTEM_LIBRARY_FOR_OPENCV}>")
Compilation can be successful, but there is such a warning:
CMake Warning at third_party/utils/opencv-4.6.0/cmake/OpenCVUtils.cmake:1675 (message):
Unexpected CMake generator expression: $<LINK_ONLY:$<BUILD_INTERFACE:muslc
Call Stack (most recent call first):
third_party/utils/opencv-4.6.0/CMakeLists.txt:1221 (ocv_get_all_libs)
I have verified that if you write directly like this:
ocv_target_link_libraries(${the_module} PRIVATE
"${SYSTEM_LIBRARY_FOR_OPENCV}")
it will appear error:
cmake error: includes target which requires target that is not in the export set
After searching, I didn't find any news related to this warning. Have you ever encountered it? How to eliminate it?
thanks

CMAKE_CXX_CLANG_TIDY: avoid clang-diagnostic-error interrupting build

I am building a C++ project using clang-tidy as linter (cmake -DCMAKE_CXX_CLANG_TIDY=clang-tidy).
After updating my system (Fedora 28->29, cmake 3.11->3.12 I believe), I cannot build any more when clang-tidy reports some clang-diagnostic-error (which I cannot fix right now...). I am pretty sure that clang-diagnostic-error's did not interrupt the build earlier... But I cannot be hundred percent sure.
Edit: The change happened in clang-tidy, now it returns a non-zero exit code when errors are found.
Is it possible to suppress those errors, something like the opposite of "-warnings-as-errors"?
Not sure if a solution or a workaround, but this does the trick (in my OS...):
cmake -DCMAKE_CXX_CLANG_TIDY="${PATH_TO_SCRIPT}/suppress_exit_status.sh;clang-tidy"
PATH_TO_SCRIPT to script is the absolute path to suppress_exit_status.sh, which looks like:
#!/bin/sh
$#||echo Command \"$#\" failed with exit code $?
|| is the "or" operator, the second operands is only executed if the first one fails. It seems that cmake captures standard error from the command and throws it way, hence the error message.
I could not figure out a more elegant way to do this, it is not possible to throw || directly into CMAKE_CXX_CLANG_TIDY.

Building U-Boot is failing

I am trying to build u-boot
Toolchain:
http://web.archive.org/web/20130823131954/http://www.angstrom-distribution.org/toolchains/
U-boot: git.denx.de
I am following this site to build this u-boot
http://beagleboard.org/linux
It says to put cross compiler path before building.
export PATH=/usr/local/angstrom/arm/bin:$PATH
1) I can see angstrom folder in /usr/local. Also I think that we need the toolchain's actual place of binaries. Let suppose in /home/myhome/BBB/angtrom_x_y_z/usr/local/angstrom/arm/bin
So which path actually i should export?
2)I have tried to put both paths, but I am getting errors.
3)I have downloaded three toolchains
angstrom-2011.03-i686-linux-armv5te-linux-gnueabi-toolchain
angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3
angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3
1st gives errors as
CROSS_COMPILE=arm-angstrom-linux-gnueabi- make am335x_evm
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config.h
GEN include/autoconf.mk
arm-angstrom-linux-gnueabi-gcc: 0: No such file or directory
arm-angstrom-linux-gnueabi-gcc: unrecognized option '-G'
cc1: error: unrecognized command line option "-mabicalls"
make[1]: *** [include/autoconf.mk] Error 1
make: *** No rule to make target `am335x_evm'. Stop.
second one is I think for 64 bit processor, I have i386 one, so it also doesn't worked
Third one is corrupted.
Can anybody tell me how to compile it as the site says. Maybe the site is outdated but still if anybody can tell me a straightforward way how to do this.
It looks like Angstorm toolchian is too old to deal with recent U-Boot. I tried your procedure and get other errors. I'm not sure why you try to use that old toolchain and if you have to use it. But I quickly check Linaro toolchain gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux, which I use for boards like Cubietruck and A20-OLinuXino-MICRO and it works fine.
git clone git://git.denx.de/u-boot.git
cd u-boot
export PATH=${PATH}:${PATH_TO_TOOLCHAIN}/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin
CROSS_COMPILE=arm-linux-gnueabihf- make am335x_evm_defconfig
CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)

Is there a way to work with ODBC by MinGW?

First I tried to download iODBC.
My MSYS console can't configure it, even if it "INSTALL" document orders to do it, because it has just configure.in, that have to be parsed by autoconf.
I downloaded GnuWin32 autoconf (2.63) to parse it. But it can't parse, because when I start autoconf in MSYS with path to configure.in, it can't find some files:
./autoconf: line 615: C:/PROGRA~2/GnuWin32/autoconf/bin/autom4te: No such file or directory
./autoconf: line 615: exec: C:/PROGRA~2/GnuWin32/autoconf/bin/autom4te: cannot execute: No such file or directory
Fun, that autoconf already placed in GnuWin32/bin directory, and autom4te lays near.
I tried just rename configure.in to configure, but I receive syntax error at first line with "AC_PREREQ(2.59)". Also I found in internet that 2.63 may not work with 2.59, and lost any wish to continue my attempts.
I also tried to run bootstrap, but it falls with "line 145: --force: command not found".
Then I decide to try unixODBC. I downloaded library 2.3.2 from home link, and started to configure it. It was done well.
Then I run "make check". It failed with:
iniOpen.c: In function 'iniOpen':
iniOpen.c:401:43: error: 'EOVERFLOW' undeclared (first use in this function)
( errno != ENOSPC ) && ( errno != EOVERFLOW ) &&
^
iniOpen.c:401:43: note: each undeclared identifier is reported only once for each function it appears in
iniOpen.c:402:20: error: 'EWOULDBLOCK' undeclared (first use in this function)
( errno != EWOULDBLOCK ))
I found that EWOULDBLOCK and EOVERFLOW never met in sources anywhere else. Also I found that it guess take them from MinGW\include\errno.h, where I found all other constaints (such as ENOSPC). Also I found EWOULDBLOCK and EOVERFLOW in boost "cerrno.hpp" and other files with errors. I fixed problem, insterting #ifndef - #define - #endif.
Now I have problem with "ld.exe: cannot find -lpthread" - Linker is trying to link posix threads that are not available at system. I can remove it, but what should I add instead? Or better would be to download and build pthread_win32 from posix thread for Win link?
It was built with adding definition for EWOULDBLOCK, EOVERFLOW and configuring with flag --enable-threads=no
So, my question is: is there right way to work with ODBC from MinGW WITH threads? If I was moving right way, how to solve those strange (at least because I downloaded releases marked as "stable") troubles?

openssl-1.0.1f msys/mingw64 build fail

I am getting an error building openssl-1.0.1f with msys/mingw64:
installing libcrypto.a
/bin/sh: line 5: mingw64bin/ranlib.exe: No such file or directory
installing libssl.a
/bin/sh: line 5: mingw64bin/ranlib.exe: No such file or directory
make: *** [install_sw] Error 1
when I run .Configure I get:
ENGINES_OBJ =
PROCESSOR =
RANLIB =\mingw64\bin/ranlib.exe
ARFLAGS =
PERL =perl
Soooooo seems pretty easy I just need to change the backslashes to slashes
I open .Configure and search for Ranlib and I get:
my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
Farther down:
\$\(CROSS_COMPILE\)$cc/;
s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/;
s/^NM=\s*/NM= \$\(CROSS_COMPILE\)/;
s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/;
Oookkeeee why not change \s*/RANLIB= \$(CROSS_COMPILE)/; to \s*/RANLIB= /$/(CROSS_COMPILE)/;
Scalar found where operator expected at ./Configure line 1619, near "s/^RANLIB=\s*/RANLIB= /$/"
Backslash found where operator expected at ./Configure line 1619, near "CROSS_COMPILE\"
syntax error at ./Configure line 1619, near "s/^RANLIB=\s*/RANLIB= /$/"
Execution of ./Configure aborted due to compilation errors.
How I feel:
http://i0.kym-cdn.com/photos/images/original/000/234/765/b7e.jpg
For those still wondering, yes I am a beginner.
Soooo my questions:
Is ranlib path the real problem here? If so, how can I make msys see slashes instead of backslashes? If you know the answer, do you think you can use concise and clear explanations?
I suspect you are trying to build OpenSSL not from the MSYS console.
You should run these commands from the MSYS console (to start it, use C:\msys64\msys.bat):
perl Configure mingw64 --prefix=/wherever-you-need-to-put-it
make
make test
make install
P.S. MSYS should be configured for using MinGW: you should create a file C:\msys64\etc\fstab with a line like this (adjust the first part if it is different on your machine).
c:/mingw64 /mingw