Premise: I'm new to this. Anyway, I'm trying to bootstrap the boost library through the command bootstrap.bat mingw. As you guessed, I'm on windows 64-bit and using the MinGW toolchain. But when I run the command, the output is
Building Boost.Build engine
builtins.cpp: In function 'FILE* windows_popen_wrapper(const char*, const char*)':
builtins.cpp:2483:18: error: '_popen' was not declared in this scope; did you mean '_lopen'?
2483 | result = _popen( command, "r" );
| ^~~~~~
| _lopen
builtins.cpp: In function 'LIST* builtin_shell(FRAME*, int)':
builtins.cpp:2418:20: error: '_pclose' was not declared in this scope; did you mean '_lclose'?
2418 | #define pclose _pclose
| ^~~~~~~
builtins.cpp:2549:19: note: in expansion of macro 'pclose'
2549 | exit_status = pclose( p );
| ^~~~~~
debugger.cpp: In function 'char* debug_string_read(FILE*)':
debugger.cpp:110:14: error: 'strdup' was not declared in this scope; did you mean 'strcmp'?
110 | result = strdup( buf->value );
| ^~~~~~
| strcmp
debugger.cpp: In function 'void debug_init_handles(const char*, const char*)':
debugger.cpp:1073:21: error: '_fdopen' was not declared in this scope; did you mean '_wsopen'?
1073 | command_input = _fdopen( read_fd, "r" );
| ^~~~~~~
| _wsopen
debugger.cpp: In function 'void init_parent_handles(HANDLE, HANDLE)':
debugger.cpp:1091:21: error: '_fdopen' was not declared in this scope; did you mean '_wsopen'?
1091 | command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
| ^~~~~~~
| _wsopen
execnt.cpp: In function 'int is_parent_child(DWORD, DWORD)':
execnt.cpp:1085:23: error: 'stricmp' was not declared in this scope; did you mean 'strncmp'?
1085 | if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) &&
| ^~~~~~~
| strncmp
execnt.cpp:1088:23: error: 'stricmp' was not declared in this scope; did you mean 'strncmp'?
1088 | if ( !stricmp( pinfo.szExeFile, "smss.exe" ) &&
| ^~~~~~~
| strncmp
jam.cpp: In function 'int main(int, char**, char**)':
jam.cpp:200:22: error: 'environ' was not declared in this scope; did you mean 'union'?
200 | # define use_environ environ
| ^~~~~~~
jam.cpp:561:37: note: in expansion of macro 'use_environ'
561 | var_defines( root_module(), use_environ, 1 );
| ^~~~~~~~~~~
jam.cpp: In function 'char* executable_path(const char*)':
jam.cpp:729:54: error: 'strdup' was not declared in this scope; did you mean 'strcmp'?
729 | return ( !ret || ret == sizeof( buf ) ) ? NULL : strdup( buf );
| ^~~~~~
| strcmp
sysinfo.cpp: In function 'unsigned int {anonymous}::std_thread_hardware_concurrency()':
sysinfo.cpp:93:21: error: 'std::thread' has not been declared
93 | return std::thread::hardware_concurrency();
| ^~~~~~
File Not Found
Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.
Contents of bootstrap.log:
'###
'###Using 'mingw' toolset.
'###
C:\Users\lenerdv\Desktop\cpp\training\lib\boost_1_72_0\tools\build\src\engine>g++ -x c++ -std=c++11 -s -O3 -o b2.exe -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp filent.cpp filesys.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jambase.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp regexp.cpp rules.cpp scan.cpp search.cpp strings.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp
C:\Users\lenerdv\Desktop\cpp\training\lib\boost_1_72_0\tools\build\src\engine>dir *.exe
Volume in drive C is Windows
Volume Serial Number is 727E-472A
Directory of C:\Users\lenerdv\Desktop\cpp\training\lib\boost_1_72_0\tools\build\src\engine
C:\Users\lenerdv\Desktop\cpp\training\lib\boost_1_72_0\tools\build\src\engine>copy /b .\b2.exe .\bjam.exe
The system cannot find the file specified.
BTW, I'm following this tutorial
Download MinGW_w64 instead.
Looks like support for MinGW has dropped while boost has continued active. For latest versions of boost use MinGW_w64.
I removed MinGW path and added a new MinGW_64 containing the files from https://winlibs.com/#download-release in C:\MinGW_64 and added to PATH. Could build the b2.exe afterwards.
Related
I have a RcppEigen project that I'm trying to update documentation for. This project only exports one c++ function into R.
Unfortunately, I get a problem when I run either devtools::document(pkg = "~/pfexamplesinr/") or roxygen2::roxygenize(roclets="rd", package.dir = "pfexamplesinr/") The error message is below.
It says something about System command 'R' failed. The entire build output is too large to paste (I go over the character limit). If I search for the first error, it's RcppExports.cpp:15:21: error: ‘Map’ was not declared in this scope. Is there some funny business about the order of #include directives and // [[Rcpp::depends(RcppEigen)]] statements?
Note: the code builds fine when I use Rcpp::sourceCpp('pfexamplesinr/src/likelihoods.cpp')
Edit: this problem goes away when I remove the #using statements, and prepend Eigen:: whenever necessary.
#include <RcppEigen.h>
#include "svol_sisr_hilb.h"
#include "resamplers.h"
// [[Rcpp::depends(RcppEigen)]]
// choose number of particles, and number of bits for inverse Hilbert curve map
#define NP 500
#define NB 5
#define debug_mode false
using Eigen::Map;
using Eigen::MatrixXd;
using Eigen::VectorXd;
using hilb_sys_resamp_T = pf::resamplers::sys_hilb_resampler<NP,1,NB,double>;
using svol_pfilter = svol_sisr_hilb<NP,NB, hilb_sys_resamp_T, double, debug_mode>;
// helpful notes:
// 1.
// parameters passed to svol_pfilter() ctor are in the following order: phi, beta, sigma
// 2.
// uProposal will be dimension (time X (particles + 1))
// first NP columns will be used for state sampling
// last column will be used for resampling at each time point
// 3.
// choosing NP or NB too large will result in stackoverflow
// number of particles is set in two places: in the #define directive and also used in your R script
// [[Rcpp::export]]
double svolApproxLL(const Map<VectorXd> y, const Map<VectorXd> thetaProposal, const Map<MatrixXd> uProposal) {
// construct particle filter object
svol_pfilter pf(thetaProposal(0), thetaProposal(1), thetaProposal(2)); // order: phi, beta, sigma
// iterate over the data
double log_like(0.0);
Eigen::Matrix<double,1,1> yt;
std::array<Eigen::Matrix<double,1,1>, NP> uStateTransition;
Eigen::Matrix<double,1,1> uResample;
for(int time = 0; time < y.rows(); ++time){
// change types of inputs
yt(0) = y(time);
for(unsigned particle = 0; particle < NP; ++particle) {
uStateTransition[particle] = uProposal.block(time,particle,1,1);
}
uResample(0) = uProposal(time,NP);
// std::cout << yt.transpose() << "\n";
// for(unsigned int i = 0; i < NP; ++i)
// std::cout << uStateTransition[i] << ", ";
// std::cout << "\n----------\n";
// update particle filter and log-likelihood
pf.filter(yt, uStateTransition, uResample);
log_like += pf.getLogCondLike();
}
//return es.eigenvalues();
return log_like;
}
// You can include R code blocks in C++ files processed with sourceCpp
// (useful for testing and development). The R code will be automatically
// run after the compilation.
/*** R
numTime <- 3
numParts <- 500 # make sure this agrees with NP
u <- matrix(rnorm(numTime*(numParts+1)), ncol = numParts+1)
params <- c(.9, 1, .1) # -1 < phi < 1, beta, sigma > 0
hist(replicate(100, svolApproxLL(rnorm(numTime), params, u)))
*/
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E> /home/taylor/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/MatrixBase.h:48:34: required from ‘class Eigen::MatrixBase<Eigen::Matrix<double, -1, 1> >’
E> /home/taylor/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/PlainObjectBase.h:98:7: required from ‘class Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1> >’
E> /home/taylor/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/Matrix.h:178:7: required from ‘class Eigen::Matrix<double, -1, 1>’
E> /home/taylor/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include/Rcpp/InputParameter.h:77:11: required from ‘class Rcpp::ConstReferenceInputParameter<Eigen::Matrix<double, -1, 1> >’
E> RcppExports.cpp:43:74: required from here
E> /home/taylor/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:5
Thanks for providing the URL to the repro. This error, as it happens not infrequently, appears to be one deeper down 'hidden' by devtools::document().
When I clone your repo onto a machine with 'current everything' from CRAN running Ubuntu 21.04 and doing my usual two-step of
compAttr.r # shell wrapper for Rcpp::compileAttributes
roxy.r -f # shell wrapper for roxygenize()
(using these helper scripts from my littler package),
I end in tears because your code uses C++17 statements without specifying C++17 as a compilation standard.
In other words, a vanilla bug at your end, independent of Rcpp or other tools.
edd#rob:~/git/stackoverflow/68985867/pfexamplesinr(master)$ compAttr.r
edd#rob:~/git/stackoverflow/68985867/pfexamplesinr(master)$ roxy.r -f
ℹ Loading pfexamplesinr
Exports from /home/edd/git/stackoverflow/68985867/pfexamplesinr/src/likelihoods.cpp:
double svolApproxLL(Eigen::Map<Eigen::VectorXd> y, Eigen::Map<Eigen::VectorXd> thetaProposal, Eigen::Map<Eigen::MatrixXd> uProposal)
Exports from /home/edd/git/stackoverflow/68985867/pfexamplesinr/src/rcppeigen_hello_world.cpp:
Eigen::MatrixXd rcppeigen_hello_world()
Eigen::MatrixXd rcppeigen_outerproduct(const Eigen::VectorXd& x)
double rcppeigen_innerproduct(const Eigen::VectorXd& x)
Rcpp::List rcppeigen_bothproducts(const Eigen::VectorXd& x)
Exports from /home/edd/git/stackoverflow/68985867/pfexamplesinr/src/resamplers.h:
Exports from /home/edd/git/stackoverflow/68985867/pfexamplesinr/src/rv_eval.h:
Exports from /home/edd/git/stackoverflow/68985867/pfexamplesinr/src/rv_samp.h:
/home/edd/git/stackoverflow/68985867/pfexamplesinr/src/RcppExports.cpp updated.
/home/edd/git/stackoverflow/68985867/pfexamplesinr/R/RcppExports.R updated.
Re-compiling pfexamplesinr
─ installing *source* package ‘pfexamplesinr’ ...
** using staged installation
** using staged installation
** libs
ccache g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -fpic -g -O3 -Wall -pipe -pedantic -Wno-misleading-indentation -Wno-unused -Wno-ignored-attributes -Wno-class-memaccess -c RcppExports.cpp -o RcppExports.o
ccache g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -fpic -g -O3 -Wall -pipe -pedantic -Wno-misleading-indentation -Wno-unused -Wno-ignored-attributes -Wno-class-memaccess -c likelihoods.cpp -o likelihoods.o
In file included from svol_sisr_hilb.h:8,
from likelihoods.cpp:1:
sisr_filter.h: In member function ‘void pf::filters::SISRFilter<nparts, dimx, dimy, resamp_t, float_t, debug>::filter(const osv&, const std::vector<std::function<const Eigen::Matrix<float_t, -1, -1>(const Eigen::Matrix<float_t, dimx, 1>&)> >&)’:
sisr_filter.h:229:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
229 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h:262:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
262 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h:288:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
288 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h:320:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
320 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h: In member function ‘void pf::filters::SISRFilterCRN<nparts, dimx, dimy, dimu, dimur, resamp_t, float_t, debug>::filter(const osv&, const arrayUs&, const usvr&, const std::vector<std::function<const Eigen::Matrix<float_t, -1, -1>(const Eigen::Matrix<float_t, dimx, 1>&)> >&)’:
sisr_filter.h:559:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
559 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h:592:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
592 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h:618:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
618 | if constexpr(debug)
| ^~~~~~~~~
sisr_filter.h:650:16: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
650 | if constexpr(debug)
| ^~~~~~~~~
In file included from likelihoods.cpp:2:
resamplers.h: In member function ‘void pf::resamplers::sys_hilb_resampler<nparts, dimx, num_hilb_bits, float_t>::resampLogWts(pf::resamplers::sys_hilb_resampler<nparts, dimx, num_hilb_bits, float_t>::arrayVec&, pf::resamplers::sys_hilb_resampler<nparts, dimx, num_hilb_bits, float_t>::arrayFloat&, const usvr&) [with long unsigned int nparts = 500; long unsigned int dimx = 1; long unsigned int num_hilb_bits = 5; float_t = double]’:
resamplers.h:1089:36: warning: ‘idx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1089 | tmpPartics[i] = sortedParts[idx];
| ~~~~~~~~~~~^
ccache g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -fpic -g -O3 -Wall -pipe -pedantic -Wno-misleading-indentation -Wno-unused -Wno-ignored-attributes -Wno-class-memaccess -c rcppeigen_hello_world.cpp -o rcppeigen_hello_world.o
ccache g++ -std=gnu++14 -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -Wl,-z,relro -o pfexamplesinr.so RcppExports.o likelihoods.o rcppeigen_hello_world.o -L/usr/lib/R/lib -lR
installing to /tmp/devtools_install_2dc74d5a52ad61/00LOCK-pfexamplesinr/00new/pfexamplesinr/libs
** checking absolute paths in shared objects and dynamic libraries
─ DONE (pfexamplesinr)
edd#rob:~/git/stackoverflow/68985867/pfexamplesinr(master)$
I'm from VN so my English is not good.Sorry about that. My problem occurs when I try to compile my code C++ in sublime text 3 but it failed. Someone help me pls! I'm thanks a lots
#include <iostream>
using namespace std;
int main() {
cout << "Your"<<endl;
return 0;
}
ERROR:
In file included from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\postypes.h:40,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\iosfwd:40,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\iostream:39,
from demo.cpp:1:
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\cwchar:166:11: error: '::"vfwscanf"' has not been declared
166 | using ::**vfwscanf**;
| ^~~~~~~~
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\cwchar:172:11: error: '::vswscanf' has not been declared
172 | using ::vswscanf;
| ^~~~~~~~
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\cwchar:176:11: error: '::vwscanf' has not been declared
176 | using ::vwscanf;
| ^~~~~~~
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\cwchar:193:11: error: '::wcstof' has not been declared
193 | using ::wcstof;
| ^~~~~~
In file included from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\locale_facets.h:39,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\iostream:39,
from demo.cpp:1:
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\cwctype:89:11: error: '::iswblank' has not been declared
89 | using ::***iswblank***;
| ^~~~~~~~
[Finished in 0.6s]
I am trying to reuse my C++ (OpenCV 4) program in my web app. To do that I am trying to compile a very basic C++ OpenCV code which just returns the version of the OpenCV. But I am facing some compilation issues shown below.
For reference here is my code repository: https://github.com/KishoreKaushal/nodeopencv
Given below is my code which I want to compile as a node add-on module.
#include <node.h>
#include <bits/stdc++.h>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
void print_opencv_version(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
string s = "OpenCV version : ";
s += CV_VERSION ;
v8::Local<v8::String> version =
v8::String::NewFromUtf8(isolate, s.c_str(), v8::String::kNormalString);
args.GetReturnValue().Set(version);
}
void Sum(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
double a = 3.14159, b = 2.718;
for (int i = 0; i < 100000; ++i) {
a += b;
}
auto total = v8::Number::New(isolate, a);
args.GetReturnValue().Set(total);
}
// this exports your custom function just like your module.exports in JS
void Initialize(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "sum", Sum);
NODE_SET_METHOD(exports, "print_opencv_version", print_opencv_version);
}
NODE_MODULE(addon, Initialize)
This is my binding.gyp file:
{
"targets" : [
{
"target_name" : "addon",
"cflags" : ["`pkg-config --cflags opencv4`", '-std=c++11'],
"link_settings" : {
"libraries" : ["`pkg-config --libs opencv4`"]
},
"sources" : ["addon.cc"]
}
]
}
And I am compiling it using this command: node-gyp clean configure build --verbose
And I am getting the following error:
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/kaushal/Documents/git/nodeopencv/build'
g++ -o Release/obj.target/addon/addon.o ../addon.cc '-DNODE_GYP_MODULE_NAME=addon' '-DUSING_UV_SHARED=1'
'-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS'
'-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS'
'-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' -I/home/kaushal/.cache/node-gyp/12.18.2/include/node -I/home/kaushal/.cache/node-gyp/12.18.2/src -I/home/kaushal/.cache/node-gyp/12.18.2/deps/openssl/config
-I/home/kaushal/.cache/node-gyp/12.18.2/deps/openssl/openssl/include -I/home/kaushal/.cache/node-gyp/12.18.2/deps/uv/include
-I/home/kaushal/.cache/node-gyp/12.18.2/deps/zlib -I/home/kaushal/.cache/node-gyp/12.18.2/deps/v8/include
-fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 `pkg-config --cflags opencv4` -std=c++11 -O3
-fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++1y -MMD -MF ./Release/.deps/Release/obj.target/addon/addon.o.d.raw -c
In file included from /usr/local/include/opencv4/opencv2/flann/params.h:35,
from /usr/local/include/opencv4/opencv2/flann/flann_base.hpp:42,
from /usr/local/include/opencv4/opencv2/flann.hpp:48,
from /usr/local/include/opencv4/opencv2/opencv.hpp:65,
from ../addon.cc:10:
/usr/local/include/opencv4/opencv2/flann/any.h: In member function ‘virtual const std::type_info& cvflann::anyimpl::typed_base_any_policy<T>::type()’:
/usr/local/include/opencv4/opencv2/flann/any.h:60:71: error: cannot use ‘typeid’ with ‘-fno-rtti’
60 | virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); }
| ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function ‘T& cvflann::any::cast()’:
/usr/local/include/opencv4/opencv2/flann/any.h:276:39: error: cannot use ‘typeid’ with ‘-fno-rtti’
276 | if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
| ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function ‘const T& cvflann::any::cast() const’:
/usr/local/include/opencv4/opencv2/flann/any.h:285:39: error: cannot use ‘typeid’ with ‘-fno-rtti’
285 | if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
| ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function ‘bool cvflann::any::empty() const’:
/usr/local/include/opencv4/opencv2/flann/any.h:293:59: error: cannot use ‘typeid’ with ‘-fno-rtti’
293 | return policy->type() == typeid(anyimpl::empty_any);
| ^
/usr/local/include/opencv4/opencv2/flann/any.h: In member function ‘bool cvflann::any::has_type()’:
/usr/local/include/opencv4/opencv2/flann/any.h:313:42: error: cannot use ‘typeid’ with ‘-fno-rtti’
313 | return policy->type() == typeid(T);
| ^
In file included from /usr/local/include/opencv4/opencv2/flann/flann_base.hpp:43,
from /usr/local/include/opencv4/opencv2/flann.hpp:48,
from /usr/local/include/opencv4/opencv2/opencv.hpp:65,
from ../addon.cc:10:
/usr/local/include/opencv4/opencv2/flann/saving.h: In function ‘cvflann::IndexHeader cvflann::load_header(FILE*)’:
/usr/local/include/opencv4/opencv2/flann/saving.h:115:63: error: exception handling disabled, use ‘-fexceptions’ to enable
115 | throw FLANNException("Invalid index file, cannot read");
| ^
../addon.cc: In function ‘void print_opencv_version(const v8::FunctionCallbackInfo<v8::Value>&)’:
../addon.cc:22:82: warning: ‘static v8::Local<v8::String> v8::String::NewFromUtf8(v8::Isolate*, const char*, v8::String::NewStringType, int)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
22 | v8::String::NewFromUtf8(isolate, s.c_str(), v8::String::kNormalString);
| ^
In file included from /home/kaushal/.cache/node-gyp/12.18.2/include/node/v8-internal.h:14,
from /home/kaushal/.cache/node-gyp/12.18.2/include/node/v8.h:27,
from /home/kaushal/.cache/node-gyp/12.18.2/include/node/node.h:67,
from ../addon.cc:8:
/home/kaushal/.cache/node-gyp/12.18.2/include/node/v8.h:3032:21: note: declared here
3032 | Local<String> NewFromUtf8(Isolate* isolate, const char* data,
| ^~~~~~~~~~~
/home/kaushal/.cache/node-gyp/12.18.2/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
328 | declarator __attribute__((deprecated(message)))
| ^~~~~~~~~~
../addon.cc:22:82: warning: ‘static v8::Local<v8::String> v8::String::NewFromUtf8(v8::Isolate*, const char*, v8::String::NewStringType, int)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
22 | v8::String::NewFromUtf8(isolate, s.c_str(), v8::String::kNormalString);
| ^
In file included from /home/kaushal/.cache/node-gyp/12.18.2/include/node/v8-internal.h:14,
from /home/kaushal/.cache/node-gyp/12.18.2/include/node/v8.h:27,
from /home/kaushal/.cache/node-gyp/12.18.2/include/node/node.h:67,
from ../addon.cc:8:
/home/kaushal/.cache/node-gyp/12.18.2/include/node/v8.h:3032:21: note: declared here
3032 | Local<String> NewFromUtf8(Isolate* isolate, const char* data,
| ^~~~~~~~~~~
/home/kaushal/.cache/node-gyp/12.18.2/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
328 | declarator __attribute__((deprecated(message)))
| ^~~~~~~~~~
In file included from ../addon.cc:8:
../addon.cc: At global scope:
/home/kaushal/.cache/node-gyp/12.18.2/include/node/node.h:608:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
608 | (node::addon_register_func) (regfunc), \
| ^
/home/kaushal/.cache/node-gyp/12.18.2/include/node/node.h:642:3: note: in expansion of macro ‘NODE_MODULE_X’
642 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
| ^~~~~~~~~~~~~
../addon.cc:49:1: note: in expansion of macro ‘NODE_MODULE’
49 | NODE_MODULE(addon, Initialize)
| ^~~~~~~~~~~
make: *** [addon.target.mk:113: Release/obj.target/addon/addon.o] Error 1
make: Leaving directory '/home/kaushal/Documents/git/nodeopencv/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.0-40-generic
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "clean" "configure" "build" "--verbose"
gyp ERR! cwd /home/kaushal/Documents/git/nodeopencv
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v7.0.0
gyp ERR! not ok
Looks like there is some error related to -fno-rttii.
Does anyone have any idea of what is going on here?
I'm trying to install a custom fork of bitcoin core from HERE And when compiling, I get the following error:
I have installed all the prerequisites i think
Making all in src
make[1]: Entering directory '/home/muhammad/Programs/SimorghCoin/src'
make[2]: Entering directory '/home/muhammad/Programs/SimorghCoin/src'
CXX bitcoind-bitcoind.o
CXX libbitcoin_server_a-addrdb.o
CXX libbitcoin_server_a-addrman.o
CXX libbitcoin_server_a-bloom.o
CXX libbitcoin_server_a-blockencodings.o
CXX libbitcoin_server_a-blockfilter.o
CXX libbitcoin_server_a-chain.o
CXX libbitcoin_server_a-checkpoints.o
CXX consensus/libbitcoin_server_a-tx_verify.o
CXX libbitcoin_server_a-httprpc.o
CXX libbitcoin_server_a-httpserver.o
httpserver.cpp:74:10: error: ‘deque’ in namespace ‘std’ does not name a template type
74 | std::deque<std::unique_ptr<WorkItem>> queue;
| ^~~~~
httpserver.cpp:33:1: note: ‘std::deque’ is defined in header ‘<deque>’; did you forget to ‘#include <deque>’?
32 | #include <support/events.h>
+++ |+#include <deque>
33 |
httpserver.cpp: In member function ‘bool WorkQueue<WorkItem>::Enqueue(WorkItem*)’:
httpserver.cpp:92:13: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
92 | if (queue.size() >= maxDepth) {
| ^~~~~
| Enqueue
httpserver.cpp:95:9: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
95 | queue.emplace_back(std::unique_ptr<WorkItem>(item));
| ^~~~~
| Enqueue
httpserver.cpp: In member function ‘void WorkQueue<WorkItem>::Run()’:
httpserver.cpp:106:35: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
106 | while (running && queue.empty())
| ^~~~~
| Enqueue
httpserver.cpp:110:31: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
110 | i = std::move(queue.front());
| ^~~~~
| Enqueue
make[2]: *** [Makefile:6520: libbitcoin_server_a-httpserver.o] Error 1
make[2]: Leaving directory '/home/muhammad/Programs/SimorghCoin/src'
make[1]: *** [Makefile:10888: all-recursive] Error 1
make[1]: Leaving directory '/home/muhammad/Programs/SimorghCoin/src'
make: *** [Makefile:774: all-recursive] Error 1
and this is my configuration:
Options used to compile and link:
with wallet = yes
with gui / qt = no
with zmq = yes
with test = yes
with bench = yes
with upnp = auto
use asm = yes
sanitizers =
debug enabled = no
gprof enabled = no
werror = no
target os = linux
build os =
My OS is Manjaro 20.0.3 Lysia and i use gcc (GCC) 10.1.0.
Can anyone help me?
The include for deque is missing in /home/muhammad/Programs/SimorghCoin/src/httpserver.cpp. You can add a line
#include <deque>
after line 32.
I'm trying to write a linter for openmp code, but libclang hides the body of openmp directives. My problem is essentially the same as this unanswered issue from the llvm mailing list.
I took a look at clang's textual ast-dump, and the information I need seems to be present. However, when I use the binary dump to create a CXCursor to iterate over the tree using the libclang library, the subtrees captured by openmp directives seem to turn into "unexposed statements."
I have tried using clang's parseTranslationUnit function to generate the AST internally, but the result is the same. Is this a limitation of libclang, or could I be doing something wrong? Below are snapshots of my code, the textual AST dump and the command I used to generate it, and the output I get from walking the AST with libclang. Thanks!
AST Walker:
#include <iostream>
#include <stdlib.h>
#include <clang-c/Index.h>
using namespace std;
int main(int argc, char** argv)
{
CXIndex index = clang_createIndex(0, 0);
CXTranslationUnit unit = clang_createTranslationUnit(index, argv[1]); //.ast filename
if (unit == nullptr)
{
cerr << "Unable to parse translation unit. Quitting." << endl;
exit(-1);
}
printf("%d\n",clang_getNumDiagnostics(unit));
for (unsigned I = 0, N = clang_getNumDiagnostics(unit); I != N; ++I) {
CXDiagnostic Diag = clang_getDiagnostic(unit, I);
CXString String = clang_formatDiagnostic(Diag, clang_defaultDiagnosticDisplayOptions());
fprintf(stderr, "%s\n", clang_getCString(String));
clang_disposeString(String);
}
CXCursor cursor = clang_getTranslationUnitCursor(unit);
clang_visitChildren(
cursor,
[](CXCursor c, CXCursor parent, CXClientData client_data)
{
if(clang_Location_isFromMainFile(clang_getCursorLocation(c))){
unsigned loc = -1;
clang_getExpansionLocation(clang_getCursorLocation(c),NULL,&loc,NULL,NULL);
printf("%d: ",loc);
cout << clang_getCString(clang_getCursorSpelling(c))<< '+' << clang_getCString(clang_getCursorKindSpelling(clang_getCursorKind(c))) << endl;
}
return CXChildVisit_Recurse;
},
nullptr);
clang_disposeTranslationUnit(unit);
clang_disposeIndex(index);
}
Test File:
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int nthreads, tid;
/* Fork a team of threads giving them their own copies of variables */
#pragma omp parallel
{
/* Obtain thread number */
tid = omp_get_thread_num();
printf("Hello World from thread = %d\n", tid);
/* Only master thread does this */
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
} /* All threads join master thread and disband */
}
Textual AST:
`-FunctionDecl 0x7fbcd785a140 <helloworld.c:17:1, line:38:1> line:17:5 main 'int (int, char **)'
|-ParmVarDecl 0x7fbcd7859f38 <col:11, col:15> col:15 argc 'int'
|-ParmVarDecl 0x7fbcd785a020 <col:21, col:32> col:27 argv 'char **':'char **'
`-CompoundStmt 0x7fbcd785cd18 <line:18:1, line:38:1>
|-DeclStmt 0x7fbcd785a308 <line:19:1, col:18>
| |-VarDecl 0x7fbcd785a208 <col:1, col:5> col:5 used nthreads 'int'
| `-VarDecl 0x7fbcd785a288 <col:1, col:15> col:15 used tid 'int'
`-OMPParallelDirective 0x7fbcd785cce0 <line:22:1, col:44>
|-OMPPrivateClause 0x7fbcd785c538 <col:22, col:43>
| |-DeclRefExpr 0x7fbcd785a320 <col:30> 'int' lvalue Var 0x7fbcd785a208 'nthreads' 'int'
| `-DeclRefExpr 0x7fbcd785a340 <col:40> 'int' lvalue Var 0x7fbcd785a288 'tid' 'int'
`-CapturedStmt 0x7fbcd785ccb8 <line:23:3, line:36:3>
`-CapturedDecl 0x7fbcd785c650 <<invalid sloc>> <invalid sloc> nothrow
|-CompoundStmt 0x7fbcd785cc90 <line:23:3, line:36:3> openmp_structured_block
| |-BinaryOperator 0x7fbcd785c8f0 <line:26:3, col:28> 'int' '='
| | |-DeclRefExpr 0x7fbcd785c848 <col:3> 'int' lvalue Var 0x7fbcd785a288 'tid' 'int'
| | `-CallExpr 0x7fbcd785c8d0 <col:9, col:28> 'int'
| | `-ImplicitCastExpr 0x7fbcd785c8b8 <col:9> 'int (*)(void)' <FunctionToPointerDecay>
| | `-DeclRefExpr 0x7fbcd785c868 <col:9> 'int (void)' Function 0x7fbcd781f590 'omp_get_thread_num' 'int (void)'
| |-CallExpr 0x7fbcd785c9d0 <line:27:3, col:47> 'int'
| | |-ImplicitCastExpr 0x7fbcd785c9b8 <col:3> 'int (*)(const char *, ...)' <FunctionToPointerDecay>
| | | `-DeclRefExpr 0x7fbcd785c910 <col:3> 'int (const char *, ...)' Function 0x7fbcd7847550 'printf' 'int (const char *, ...)'
| | |-ImplicitCastExpr 0x7fbcd785ca18 <col:10> 'const char *' <NoOp>
| | | `-ImplicitCastExpr 0x7fbcd785ca00 <col:10> 'char *' <ArrayToPointerDecay>
| | | `-StringLiteral 0x7fbcd785c930 <col:10> 'char [30]' lvalue "Hello World from thread = %d\n"
| | `-ImplicitCastExpr 0x7fbcd785ca30 <col:44> 'int' <LValueToRValue>
| | `-DeclRefExpr 0x7fbcd785c968 <col:44> 'int' lvalue Var 0x7fbcd785a288 'tid' 'int'
| `-IfStmt 0x7fbcd785cc78 <line:30:3, line:34:5>
| |-BinaryOperator 0x7fbcd785caa0 <line:30:7, col:14> 'int' '=='
| | |-ImplicitCastExpr 0x7fbcd785ca88 <col:7> 'int' <LValueToRValue>
| | | `-DeclRefExpr 0x7fbcd785ca48 <col:7> 'int' lvalue Var 0x7fbcd785a288 'tid' 'int'
| | `-IntegerLiteral 0x7fbcd785ca68 <col:14> 'int' 0
| `-CompoundStmt 0x7fbcd785cc58 <line:31:5, line:34:5>
| |-BinaryOperator 0x7fbcd785cb38 <line:32:5, col:36> 'int' '='
| | |-DeclRefExpr 0x7fbcd785cac0 <col:5> 'int' lvalue Var 0x7fbcd785a208 'nthreads' 'int'
| | `-CallExpr 0x7fbcd785cb18 <col:16, col:36> 'int'
| | `-ImplicitCastExpr 0x7fbcd785cb00 <col:16> 'int (*)(void)' <FunctionToPointerDecay>
| | `-DeclRefExpr 0x7fbcd785cae0 <col:16> 'int (void)' Function 0x7fbcd781f090 'omp_get_num_threads' 'int (void)'
| `-CallExpr 0x7fbcd785cbe0 <line:33:5, col:48> 'int'
| |-ImplicitCastExpr 0x7fbcd785cbc8 <col:5> 'int (*)(const char *, ...)' <FunctionToPointerDecay>
| | `-DeclRefExpr 0x7fbcd785cb58 <col:5> 'int (const char *, ...)' Function 0x7fbcd7847550 'printf' 'int (const char *, ...)'
| |-ImplicitCastExpr 0x7fbcd785cc28 <col:12> 'const char *' <NoOp>
| | `-ImplicitCastExpr 0x7fbcd785cc10 <col:12> 'char *' <ArrayToPointerDecay>
| | `-StringLiteral 0x7fbcd785cb78 <col:12> 'char [24]' lvalue "Number of threads = %d\n"
| `-ImplicitCastExpr 0x7fbcd785cc40 <col:40> 'int' <LValueToRValue>
Command to generate AST (change to emit-ast for the binary file):
clang -fopenmp -Xclang -ast-dump -L/usr/local/lib helloworld.c
Program Output:
0
13: omp.h+inclusion directive
14: stdio.h+inclusion directive
15: stdlib.h+inclusion directive
17: main+FunctionDecl
17: argc+ParmDecl
17: argv+ParmDecl
18: +CompoundStmt
19: +DeclStmt
19: nthreads+VarDecl
19: tid+VarDecl
22: +OMPParallelDirective
23: +UnexposedStmt
26: tid+DeclRefExpr
32: nthreads+DeclRefExpr