size of array '__curl_rule_01__' is negative - compilation

I'm struggling with an error whilst trying to compile GIT. I've searched Google and the GIT source issues/bugs for similar issues but i've not found anything to help me.
Originally I received the following error
root#teemo:/usr/src/git# make prefix=/usr install install-doc install-html install-info;
CC http-push.o
In file included from cache.h:39:0,
from http-push.c:1:
/usr/include/zlib.h:34:19: fatal error: zconf.h: No such file or directory
#include "zconf.h"
^
compilation terminated.
make: *** [http-push.o] Error 1
I created a symbolic link inside /usr/include/ to the missing file as follows (after I had installed/compiled the latest/development version)
root#teemo:/usr/src/git# ln -s /usr/include/x86_64-linux-gnu/zconf.h /usr/include
Which brings me to the current issue, which I am confused as to how to solve. If someone could advise it would be greatly appreciated.
root#teemo:/usr/src/git# make prefix=/usr install install-doc install-html install-info;
CC http-push.o
In file included from /usr/include/curl/curl.h:35:0,
from http.h:6,
from http-push.c:5:
/usr/include/curl/curlrules.h:142:3: error: size of array '__curl_rule_01__' is negative
__curl_rule_01__
^
/usr/include/curl/curlrules.h:152:3: error: size of array '__curl_rule_02__' is negative
__curl_rule_02__
^
make: *** [http-push.o] Error 1

Read higher up in curlrules.h. That error is intentionally forced as part of a test that checks the size of data types.
* NOTE 2
* ------
*
* Some of the following compile time checks are based on the fact
* that the dimension of a constant array can not be a negative one.
* In this way if the compile time verification fails, the compilation
* will fail issuing an error. The error description wording is compiler
* dependent but it will be quite similar to one of the following:
*
* "negative subscript or subscript is too large"
* "array must have at least one element"
* "-1 is an illegal array size"
* "size of array is negative"
*
* If you are building an application which tries to use an already
* built libcurl library and you are getting this kind of errors on
* this file, it is a clear indication that there is a mismatch between
* how the library was built and how you are trying to use it for your
* application. Your already compiled or binary library provider is the
* only one who can give you the details you need to properly use it.
Your version of libcurl was built with different options than you're using in your current git build. (it could be 32 vs 64 bit)
Knowing what platform you're on and your build options might be enough others to help resolve it. If this is the common case, and you're on Linux or another supported platform, it'd be easier just to install a prebuilt binary using the native software management. Git downloads

In case system reports __curl_rule_01__ or __curl_rule_02__ is negative make the following changes to /usr/include/curl/curlbuild.h:
Add the following lines:
define CURL_SIZEOF_LONG 4
define CURL_SIZEOF_CURL_OFF_T 4
(Or replace similar lines if these are already defined)

Related

What should the configure.win file contain in the cplex API package?

I'm trying to install cplex API in windows. I'm not super familiar with the programme so I've been using this link from R bloggers
https://www.r-bloggers.com/2017/01/using-cplex-in-r-installing-cplexapi-in-windows-10/
After using the windows command prompt I get the following responses:
R CMD build --no-build-vignettes --no-manual --md5 C:\Users\Rharris\Desktop\cplexAPI
* checking for file 'C:\Users\RHARRIS\Desktop\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
Warning in cleanup_pkg(pkgdir, Log) :
unable to run 'make clean' in 'src'
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.4.0.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected
C:\Users\RHARRIS>R CMD INSTALL --build --no-multiarch .\cplexAPI_1.4.0.tar.gz
* installing to library 'C:/Users/RHARRIS/Documents/R/win-library/4.0'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** using staged installation
Warning in system("sh ./configure.win") : 'sh' not found
ERROR: configuration failed for package 'cplexAPI'
* removing 'C:/Users/RHARRIS/Documents/R/win-library/4.0/cplexAPI'
It seems I have an error in the configure.win file, however I haven't edited it at all after downloading it. When I open it up its a blank file, I'm not sure if thats what I'm supposed to be.
If anyone has any insight to offer here it's be much appreciated.
Looking at this error message "'sh' not found" I suspect you should install cygwin so that the install can use the BourneShell.
If this fails, I guess you can contact the author of the package https://www.th-koeln.de/personen/gabriel.gelius-dietrich/.
Cheers,

How can I specify a minimum compute capability to the mexcuda compiler to compile a mexfunction?

I have a CUDA project in a .cu file that I would like to compile to a .mex file using mexcuda. Because my code makes use of the 64-bit floating point atomic operation atomicAdd(double *, double), which is only supposed for GPU devices of compute capability 6.0 or higher, I need to specify this as a flag when I am compiling.
In my standard IDE, this works fine, but when compiling with mexcuda, this is not working as I would like. In this post on MathWorks, it was suggested to use the following command (edited from the comment by Joss Knight):
mexcuda('-v', 'mexGPUExample.cu', 'NVCCFLAGS=-gencode=arch=compute_60,code=sm_60')
but when I use this command on my file, the verbose option spits out the following line last:
Building with 'NVIDIA CUDA Compiler'.
nvcc -c --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -
gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -
gencode=arch=compute_60,code=sm_60 -
gencode=arch=compute_70,code=\"sm_70,compute_70\"
(and so on), which signals to me that the specified flag was not passed to the nvcc properly. And indeed, compilation fails with the following error:
C:/path/mexGPUExample.cu(35): error: no instance of overloaded function "atomicAdd" matches
the argument list. Argument types are: (double *, double)
The only other post I could find on this topic was this post on SO, but it is almost three years old and seemed to me more like a workaround - one which I do not understand even after some research, otherwise I would have tried it - rather than a true solution to the problem.
Is there a setting I missed, or can this simply not be done without a workaround?
I was able to work my way around this problem after some messing around with the standard xml-files in the MatLab folder. The following steps allowed me to compile using -mexcuda:
-1) Go to the folder C:\Program Files\MATLAB\-version-\toolbox\distcomp\gpu\extern\src\mex\win64, which contains xml-files for different versions of msvcpp;
-2) Make a backup of the file that corresponds to the version you are using. In my case, I made a copy of the file nvcc_msvcpp2017 and named it nvcc_msvcpp2017_old, to always have the original.
-3) Open nvcc_msvcppYEAR with notepad, and scroll to the following block of lines:
COMPILER="nvcc"
COMPFLAGS="--compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD $ARCHFLAGS"
ARCHFLAGS="-gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\" $NVCC_FLAGS"
COMPDEFINES="--compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,$MATLABMEX"
MATLABMEX="/DMATLAB_MEX_FILE"
OPTIMFLAGS="--compiler-options=/O2,/Oy-,/DNDEBUG"
INCLUDE="-I"$MATLABROOT\extern\include" -I"$MATLABROOT\simulink\include""
DEBUGFLAGS="--compiler-options=/Z7"
-4) Remove the architectures that will not allow your code to compile, i.e. all the architecture flags below 60 in my case:
ARCHFLAGS="-gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\" $NVCC_FLAGS"
-5) I was able to compile using mexcuda after this. You do not need to specify any architecture flags in the mexcuda call.
-6) (optional) I suppose you want to revert this change after you are done with the project that required you to make this change, if you want to ensure maximum portability of the code you will compile after this.
Note: you will need administrator permission to make these changes.

What is this error Compiling a Fortran (f95) Code in OSX with gcc

I am trying to compile a Fortran (.f95) code in a Mac using gcc.
The code is an open source code. When I contacted the developers, they do not have the budget to provide a compiled application so they provide the files and let the user do the compiling.
Nevertheless I have failed at several attempts.
The code does come with a disclaimer of which files to compile and in which order. Nevertheless, just the first files encounters an error at a first pass.
This is the first section of the code that calls an error
TYPE(GasParV), PARAMETER :: Methane = GasParV
& ("CH4 ", 2.514d1, ! Name, AtomDV
The error is
HRS_RealGasEOS.f95:85:54:
TYPE(GasParV), PARAMETER :: Methane = GasParV
1
Error: Function 'gasparv' requires an argument list at (1)

clang: error: no such file or directory: ...PrecompiledHeaders..../...pch

I have a project building correctly in one machine, but i am getting the following error when i try to build it in another. Both machines have the same version of OS X and XCode, and exactly the same source files.
clang: error: no such file or directory: '/Users/Cristian/Library/Developer/Xcode/DerivedData/MadGoose-alcvoermelusildxepcbneygiwbk/Build/Intermediates/PrecompiledHeaders/MadGoose_Prefix-afbukpnsoecegqeiiuwhfersynbx/MadGoose_Prefix.pch'
I have the following files on that directory
MadGoose_Prefix.pch.data
MadGoose_Prefix.pch.pch
MadGoose_Prefix.pch.dia
MadGoose_Prefix.pch.pch.hash-criteria
Anyone knows what could it be?
Or what should i compare between the machines?
I found the problem, i had this in the Build Settings
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"${FACEBOOKSDK}\"",
);
Since we don't use Facebook on the project anymore the variable ${FACEBOOKSDK} was empty in the machine with the problem, i remove it from there and problem solved.
An extra tip for others with build problems, check the XCBuildConfigutation section of the .pbxproj directly (Everything between /* Begin XCBuildConfiguration section */ and /* End XCBuildConfiguration section */), it was easy to spot the problem there, in XCode the variables are replaced with their value unless you edit them.

GHC :: Linking agains sqlite3 fails on Windows

I created simple application, which uses sqlite3 as it's datastore back-end. I faced no problems when building and running it on Linux, but after I tried to build it on Windows, I see weird linking error:
Linking dist\build\hnotes\hnotes.exe ...
C:\Documents and Settings\Admin\Application Data\cabal\sqlite-0.5.2.2\ghc-7.0.4/libHSsqlite-0.5.2.2.
a(sqlite3-local.o):sqlite3-local.c:(.text+0x21): undefined reference to `sqlite3_temp_directory'
C:\Documents and Settings\Admin\Application Data\cabal\sqlite-0.5.2.2\ghc-7.0.4/libHSsqlite-0.5.2.2.
a(sqlite3-local.o):sqlite3-local.c:(.text+0x40): undefined reference to `sqlite3_temp_directory'
collect2: v ld 1
cabal.EXE: Error: some packages failed to install:
hnotes-0.1 failed during the building phase. The exception was:
ExitFailure 1
What may be wrong there? I suspect that qalite3.dll has to be added to linking stage, but have no idea how to do that. Adding --extra-lib-dirs=path-to-sqlite-dll doesn't help either (perhaps because I need to update my cabal file somehow, to support this?).
Not sure if It's a bug or not, but the error comes from the sqlite3.h include of the sqlite package.
A look in the file shows this
/*
** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
**
** If this global variable is made to point to a string which is
** the name of a folder (a.k.a. directory), then all temporary files
** created by SQLite will be placed in that directory. If this variable
** is a NULL pointer, then SQLite performs a search for an appropriate
** temporary file directory.
**
** It is not safe to modify this variable once a [database connection]
** has been opened. It is intended that this variable be set once
** as part of process initialization and before any SQLite interface
** routines have been call and remain unchanged thereafter.
*/
SQLITE_EXTERN char *sqlite3_temp_directory;
so it's declared as an extern. So simple test:
module Main where
import Database.SQLite
main
= do hwd <- openConnection "test"
closeConnection hwd
putStrLn "done"
This crashes during linking as expected with the error you have above.
So I created a small C test file foo.c
#include "sqlite-0.5.2.2\\include\\sqlite3-local.h"
char* sqlite3_temp_directory = "C:\\test2";
So I'm defining a temp_directory and then I pass the c file along during compilation of the haskell source
$ ghc test.hs foo.c
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test.exe ...
and then running it also returns the expected result
$ ./test
done
So it seems that you just need to give a value for the sqlite3_temp_directory, which if you set it to a NULL pointer will use the TMP/TEMP etc variables as defined in the SQLLITE manual.
edit, follow up on why it worked on Linux but not on windows
In the sqlite package, there's a file sqlite3.c under the folder sqlite3.6. This provides a bunch of defaults for the sqlite package.
when on linux OS_UNIX is defined and when on linux it uses the defines under OS_WIN.
The function we're interested in is the function which sets the temporary directory. for unix this'll be unixGetTempname and for windows winGetTempname.
If you look at the implementation of both these functions, for the unix one it has list of directories that it'll try
static const char *azDirs[] = {
0,
"/var/tmp",
"/usr/tmp",
"/tmp",
".",
};
it tries to access them in order and the one it can write to it uses to generate a temporary folder in.
For windows however one of the first lines are:
if( sqlite3_temp_directory ){
sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
}else if( isNT() ){
so for windows sqlite3_temp_directory is actually used. This is why it doesn't compile if It can't find it.

Resources