I have a rather large codebase that includes libSVM and lp_solve libraries. I recently added the Boost Threading library to the code and I continue to get a compilation error that I can't seem to solve.
First, I added the include statement for the threading library:
#include <boost/thread.hpp>
Second, I adjusted the makefile for compilation. The command used to compile the relevant file is:
g++ -I./ -I../Eigen -I../Classification -I../Components -I../include
-I../Individuals -I../Pruning -I../Pruning/AIS -I../Pruning/ACO
-I../Pruning/GA -I../Pruning/PSO -I../Pruning/CFO -I../Random
-I../Samplers -O2 -g -Wall -c -fmessage-length=0 -fopenmp -llpsolve55
-lsvm -lboost_thread -lboost_system -MMD -MP
-MF"Samplers/OMPP_Sampler.d" -MT"Samplers/OMPP_Sampler.d" -o
"Samplers/OMPP_Sampler.o" "../Samplers/OMPP_Sampler.cpp"
The generated error is:
In file included from /usr/local/include/boost/thread.hpp:24,
from ../Samplers/OMPP_Sampler.cpp:15:
/usr/local/include/boost/thread/future.hpp: In constructor
‘boost::packaged_task<R>::packaged_task(R (*)())’:
/usr/local/include/boost/thread/future.hpp:3214: error: expected
unqualified-id before numeric constant
/usr/local/include/boost/thread/future.hpp:3214: error: expected ‘)’
before numeric constant
/usr/local/include/boost/thread/future.hpp:3215: error: type/value
mismatch at argument 1 in template parameter list for ‘template<class
F, class R> struct boost::detail::task_shared_state’
/usr/local/include/boost/thread/future.hpp:3215: error: expected a
type, got ‘0’
/usr/local/include/boost/thread/future.hpp:3215: error: invalid type
in declaration before ‘;’ token
I have dug through the Boost headers, tried to identify any re-definitions from my own code, etc. The Boost code causing the issue is as follows:
explicit packaged_task(R(*f)())
{
typedef R(*FR)();
typedef detail::task_shared_state<FR,R> task_shared_state_type;
task= task_ptr(new task_shared_state_type(f));
future_obtained=false;
}
Thoughts on how I can resolve this issue?
Related
im trying to build the example here https://github.com/jtv/libpqxx#programming-with-libpqxx using c++ compiler on my beagleboneblack, ececuting the command: g++ -o taks tasks.cpp -lpqxx -lpq
I belive i have installed the lpqxx library with success.
Gcc compiler version: gcc (Debian 8.3.0-6) 8.3.0
When compiling i get the following errors (and several other not show here):
warning: structured bindings only available with -std=c++17 or -std=gnu++17
for (auto [name, salary] : tx.query<std::string, int>(
^
tasks.cpp:20:43: error: ‘using work = class pqxx::transaction<>’ {aka ‘class pqxx::transaction<>’} has no member named ‘query’
for (auto [name, salary] : tx.query<std::string, int>(
^~~~~
tasks.cpp:20:60: error: expected primary-expression before ‘,’ token
The first is a warning, but the others error. Not familiar with C#:
What does these errors mean?
How do i get on solving them?
Is it compiler issues or is it code issues?
I just have one file in my direcory and that is copy-paste of the example from the link, am i missing some header files that define some stuff for me?
I'm trying to compile bitcoin on my EC2 instance, and I've run into a problem I can't figure out. The build script stops on the following command
g++ -c -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE -DUSE_UPNP=1 -DUSE_IPV6=1 -I/home/ec2-user/bitcoin/src/leveldb/include -I/home/ec2-user/bitcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -I"/home/ec2-user/bitcoin/src" -I"/home/ec2-user/bitcoin/src/obj" -I"/usr/local/include" -I"/usr/include/openssl" -MMD -MF obj/alert.d -o obj/alert.o alert.cpp
by returning the following error(s)
In file included from /usr/include/sys/socket.h:40:0,
from compat.h:19,
from netbase.h:11,
from util.h:27,
from alert.h:13,
from alert.cpp:11:
/usr/include/bits/socket.h:231:5: error: expected identifier before numeric constant
/usr/include/bits/socket.h:231:5: error: expected ‘}’ before numeric constant
/usr/include/bits/socket.h:231:5: error: expected unqualified-id before numeric constant
In file included from compat.h:19:0,
from netbase.h:11,
from util.h:27,
from alert.h:13,
from alert.cpp:11:
/usr/include/sys/socket.h:254:1: error: expected declaration before ‘}’ token
I've tried compiling with the -std=c++0x option set, but it made no difference. That was the only thing I've been able to come up with.
I'd wager that some header file you have is #defineing a macro that interferes with socket.h. Are you able to compile a program that only includes <sys/socket.h>, with no other inclusions?
The next thing to check is to look at /usr/include/bits/socket.h and see what's on line 231 (where the first error occurs). If the code looks ok, then the next step is to see what the preprocessed source looks like. To get the preprocessed output, replace the -c option with -E on the command line, and change the -o obj/alert.o option to -o alert.ii to put the preprocessor output into the file alert.ii.
If you compare the content of alert.ii with /usr/include/bits/socket.h, you can see if it's getting compiled as expected or not. In particular, if there's a macro which defines something into something unexpected, you'll see code which is clearly wrong at the location the compiler is pointing out.
I'm running into a strange issue when I try to compile the following simple C++11 code on my machine:
#include <boost/thread/thread.hpp>
It compiles fine with g++ foo.cpp -o foo but chokes on g++ -c -std=c++11 foo.cpp -o foo with the following error:
In file included from /usr/local/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/functional:56:0,
from /usr/local/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:81,
from /usr/local/include/boost/config/no_tr1/memory.hpp:21,
from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:27,
from /usr/local/include/boost/shared_ptr.hpp:17,
from /usr/local/include/boost/thread/pthread/thread_data.hpp:10,
from /usr/local/include/boost/thread/thread.hpp:17,
from foo.cpp:1:
./tuple:1:1: error: stray ‘\317’ in program
./tuple:1:1: error: stray ‘\372’ in program
./tuple:1:1: error: stray ‘\355’ in program
./tuple:1:1: error: stray ‘\376’ in program
... Additional lines omitted
I'm at a loss. Especially since I've been able to compile other programs against C++11 without any issue. Any ideas?
I'm running OS X v10.7.4 (Lion) and GCC 4.7.1.
That's because you have a file in your current directory named tuple that is included instead of the standard tuple header. Probably because of some -I. in the compilation line.
The strays characters in the error messages are simply the first bytes of the file not in the allowed character set, in octal.
I run install.packages('mvoutliers', dependencies=TRUE) in R 2.15.0 and fail at package pcaPP. Any ideas?
* installing *source* package ‘pcaPP’ ...
** package ‘pcaPP’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/include/R/ -DNDEBUG -DR_PACKAGE_FILE -I/usr/local/include -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -c L1Median_HoCr.cpp -o L1Median_HoCr.o
In file included from smat.h:28:0,
from L1Median.h:5,
from L1Median_HoCr.cpp:1:
smat.base.h: In instantiation of ‘void SVec<T>::Copy(const tc_this&) const [with T = double; SVec<T>::tc_this = SCVec<double>]’:
L1Median_HoCr.cpp:93:32: required from here
smat.base.h:882:4: error: ‘EqualDims’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
smat.base.h:882:4: note: declarations in dependent base ‘CDimCont<1u>’ are not found by unqualified lookup
smat.base.h:882:4: note: use ‘this->EqualDims’ instead
make: *** [L1Median_HoCr.o] Error 1
ERROR: compilation failed for package ‘pcaPP’
* removing ‘/usr/lib/R/library/pcaPP’
ERROR: dependency ‘rgl’ is not available for package ‘compositions’
* removing ‘/usr/lib/R/library/compositions’
That looks like a genuine error in the file smat.base.h.
You could try to get in contact with the maintainers of pcaPP.
I get the following error when compiling this third-party library (called azove 2.0) which relies on the GNU Multi-precision library:
> make
g++ -Wall -O3 -DFIX_NUMBER_OF_SIGMDDNODE_SONS -DUSE_TIMER -I. -c conBDD.cpp -o conBDD.o
In file included from conBDDnode.hpp:27,
from conBDD.hpp:25,
from conBDD.cpp:22:
/usr/include/gmpxx.h: In destructor ‘__gmp_alloc_cstring::~__gmp_alloc_cstring()’:
/usr/include/gmpxx.h:2096: error: ‘strlen’ was not declared in this scope
conBDD.cpp: In member function ‘void conBDD::build()’:
conBDD.cpp:61: error: ‘numeric_limits’ was not declared in this scope
conBDD.cpp:61: error: expected primary-expression before ‘int’
conBDD.cpp:61: error: expected `;' before ‘int’
conBDD.cpp:68: error: expected primary-expression before ‘int’
conBDD.cpp:68: error: expected `;' before ‘int’
make: *** [conBDD.o] Error 1
I have tried adding either and both of the following lines
#include <cstdlib>
using std::strlen;
to conBDD.cpp, but the error persists.
I can't tell if this is an error comes from GNU's Multi-precision library or from Azove. Any pointers would be greatly appreciated.
I would start by apportioning blame. Create an empty cpp file, say test.cpp, in your project and include only the offending gmpxx.h file. If you can compile test cpp, GMP is off the hook. Then try including only the offending azove header. If you can compile the azove header in an otherwise empty file, azove is off the hook and something you are including/defining is interfering with them. Once you have narrowed down the source of the problem you should find it easier to fix.