Once I added the following include to my app:
#include <boost/regex.hpp>
It spits out some errors I have no idea what they are about (newbie to c++):
In file included from /usr/include/boost/regex/regex_traits.hpp:27,
from /usr/include/boost/regex/v4/regex.hpp:39,
from /usr/include/boost/regex.hpp:31,
from my_app.c:28:
/usr/include/boost/regex/v4/regex_traits.hpp:80:1: error: macro "test" passed 2 arguments, but takes just 1
/usr/include/boost/regex/v4/regex_traits.hpp:80: error: template declaration of âchar (& boost::re_detail::test)[2]â
/usr/include/boost/regex/v4/regex_traits.hpp:80: error: expected unqualified-id before â...â token
/usr/include/boost/regex/v4/regex_traits.hpp:80: error: expected `)' before â...â token
/usr/include/boost/regex/v4/regex_traits.hpp:80: error: expected `)' before â...â token
/usr/include/boost/regex/v4/regex_traits.hpp:80: error: expected unqualified-id before â(â token
/usr/include/boost/regex/v4/regex_traits.hpp:80: error: âboost::re_detail::has_boost_extensions_tag<T, fallback_>::valueâ is not a valid template argument for type âboolâ because it is a non-constant expression
I installed boost on centos using:
yum install boost boost-devel boost-doc
I compile the app using:
g++ -o my_app my_app.c $(mysql_config --libs --cflags
Headers:
#include <stdio.h>
#include <my_global.h>
#include <mysql.h>
#include <string.h>
#include <stdlib.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <dirent.h>
#include <regex.h>
#include <iterator>
#include <boost/regex.hpp>
#include <sstream>
#include <fstream>
#include <iostream>
#include <vector>
Can someone help me out?
Is this accidential or are you compiling C code with a C++ compiler?
Try to rename your file to my_app.cc or so to see if that helps.
Related
I am trying to compile the sources of a chess program which includes these, I think, relevant lines:
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include "timectrl.h"
#include "search.h"
#include "plp.h"
#include "uci.h"
#include "util.h"
#include <winsock2.h>
...
signal(SIGALRM, timectrl_alarm);
However, the compilation fails and I get these messages:
timectrl.c: In function 'timectrl_go':
timectrl.c:59:12: error: 'SIGALRM' undeclared (first use in this function); did you mean 'SIGABRT'?
59 | signal(SIGALRM, timectrl_alarm);
| ^~~~~~~
| SIGABRT
timectrl.c:59:12: note: each undeclared identifier is reported only once for each function it appears in
timectrl.c:63:5: warning: implicit declaration of function 'alarm' [-Wimplicit-function-declaration]
63 | alarm(1);
| ^~~~~
I don't understand why these are undeclared when they must be in the included libraries.
Can you help please?
I'm building a small project (I'm running windows 7 with cygwin64 ). here is how my "header of program" looks like
#ifndef Win32_H
#define Win32_H
#define USE_LSA
#include <winsock2.h>
#include <windows.h>
#include <psapi.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <string.h>
#define SECURITY_WIN32
#include <ntstatus.h>
#include <Sspi.h>
#include <Ntsecapi.h>
#include <Ntsecpkg.h>
#include <sddl.h>
#include <algorithm>
#include "Class1.h"
#include "Class2.h"
#include <Class3.h>
#include <errno.h>
I downloaded this project to examine. But the problem I have is that I ran into a compiling error which says
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/Sspi.h:10:0,
from main.cpp:61:
/usr/i686-w64-mingw32/sys-root/mingw/include/ntsecapi.h:594:22: error: expected unqualified-id before string constant
typedef LSA_STRING STRING,*PSTRING;
^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/Sspi.h:10:0,
from TokenServer.cpp:61:
/usr/i686-w64-mingw32/sys-root/mingw/include/ntsecapi.h:707:5: error: expected unqualified-id before string constant
STRING CaseSensitiveChallengeResponse;
^
/usr/i686-w64-mingw32/sys-root/mingw/include/ntsecapi.h:708:5: error: expected unqualified-id before string constant
STRING CaseInsensitiveChallengeResponse;
^
/usr/i686-w64-mingw32/sys-root/mingw/include/ntsecapi.h:718:5: error: expected unqualified-id before string constant
STRING AuthenticationInfo1;
^
/usr/i686-w64-mingw32/sys-root/mingw/include/ntsecapi.h:719:5: error: expected unqualified-id before string constant
STRING AuthenticationInfo2;
^
I've googled a little bit but found nothing that would help me this is the same problem as mine. and also this one. But as I've said they didn't help. Hope you can help me. thanks.
I'm new to C++, I got error: '__locale_t' has not been declared when I included some header files, like #include "ruby.h" , #include <string.h> and so on, but there's no problem for #include <stdio.h>, I'm using eclipse under Linux, the detailed error for #include "ruby.h" and #include <string.h> is:
/usr/include/string.h:548: error: '__locale_t' has not been declared
/usr/include/string.h:549: error: nonnull argument references non-pointer operand (argument 1, operand 3)
/usr/include/string.h:552: error: '__locale_t' has not been declared
/usr/include/string.h:553: error: nonnull argument references non-pointer operand (argument 1, operand 4)
The order of the include is:
#include "Abc.h"
#include <string.h>
#include "ruby.h"
#include <stdio.h>
Where Abc is the class name.
This is the Abc class, nothing added except the include:
#include "Abc.h"
#include <stdio.h>
#include <string.h>
#include "ruby.h"
#include "ose_gw.h"
namespace a {
Abc::Abc() {
// TODO Auto-generated constructor stub
}
Abc::~Abc() {
// TODO Auto-generated destructor stub
}
} /* namespace a */
Try compiling with:
g++ -D__USE_XOPEN2K8 ...
(see also https://sourceware.org/bugzilla/show_bug.cgi?id=10456 which mentions that xlocale.h is only included from string.h when __USE_XOPEN2K8 is defined)
This is apparently a known issue, which was logged as a bug but is actually some kind of subtle configuration error.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52922
I'm a Windows guy and this is out of my league, but the answer is in there somewhere (I think).
One of my script file(.scnp)included the following headers as follows.
#include <stdio.h>
#include "kel.h"
#include "process.h"
#include "sigtypes.h"
#include "ScriptInterface.h"
#include "../saf/SAF_Scripts.h"
This type of header files include gives an error in GDB saying
"symbol lookup error: /xxx/xxxx.so: undefined symbol:
_Z16KEL_MEM_AllocateP19KEL_MEM_tPoolHandlej.
Included file after
#include <stdio.h>
#include "ScriptInterface.h"
#include "kel.h"
#include "process.h"
#include "sigtypes.h"
#include "../saf/SAF_Scripts.h"
ScriptInterface.h
extern "C"
{
#include "kel.h"
#include "process.h"
#if defined()
#include "sigtypes.h"
#endif
}
The scripts run successfully. What could be the problem? I have found the responsible method for this problem by using "c++filt" but don't know how to proceed further. Please help
Im trying to use NormalBayesClassifier in my code to apply bag of words. The pre-training matrix is ready and given to the trainme matrix. I am using it as follows:
NormalBayesClassifier classifier;
classifier.train(trainme, labels);
And I am getting the following error:
error C2065: 'NormalBayesClassifier' : undeclared identifier
I have added all the correct libraries and all other opencv functions work, including the features2d functions.
Here are my libraries:
#include <stdafx.h>
#include <stdlib.h>
#include <cv.hpp>
#include <cxcore.hpp>
#include <highgui.h>
#include <iostream>
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include <fstream>
#include <windows.h>
using namespace cv;
using namespace std;
That should cover the NormalBayesClassifier function, then why am I getting this error?
According to the documentation, the class for the Normal Bayes Classifier is actually called CvNormalBayesClassifier.
The corresponding header file is:
#include "opencv2/ml/ml.hpp"