C++ Compilation error against GNU's Multi-precision library - c++

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.

Related

C++ compiler errors compiling libpqxx basic exmaple, what is wrong and how to solve it?

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?

par2tbb fails to compile with an "auto_ptr is not a member of std" error

I am trying to compile par2tbb on Gentoo Linux kernel 3.18.12, and I keep getting the following compilation error:
par2cmdline.cpp: In function ‘int main(int, char**)’:
par2cmdline.cpp:88:3: error: ‘auto_ptr’ is not a member of ‘std’
std::auto_ptr<CommandLine> commandline(new CommandLine);
^
I already checked that #include <memory.h> was present on the source code, I already added CXXFLAGS = -std=c++11 to the makefile, and it still won't compile.
Looking up online, these two measures are the only fixes I could find. Any idea on what's going on?

OpenGL errors finding certain libraries

I am learning about OpenGL and am having great difficulty opening a file with openGL. This is what my reference says to do:
"Compile and run the program
To compile the sample program, you need to link to the OpenGL and freeglut libraries. You will also need the GLEW library to be able to use many OpenGL functions, including shaders.
The exact names of these libraries vary from system to system, for example:
Linux
: libGL.a, libglut.a
Compile with
g++ main.cpp -lGL -lglut -lGLE"
I have run this code in my linux terminal (I'm using Redhat) and I get a whole bunch of errors about not being able to locate the files
[a1649446#ingb24w027 code]$ g++ main.cpp -lGL -lglut -lGLEW
main.cpp:46:23: error: glm/glm.hpp: No such file or directory
main.cpp:47:40: error: glm/gtc/matrix_transform.hpp: No such file or directory
main.cpp:48:32: error: glm/gtc/type_ptr.hpp: No such file or directory
main.cpp:62: error: ‘glm’ has not been declared
main.cpp:62: error: expected constructor, destructor, or type conversion before ‘cameraMatrix’
main.cpp: In function ‘int setShaderData(const unsigned int&)’:
main.cpp:102: error: ‘glm’ has not been declared
main.cpp:102: error: expected ‘;’ before ‘projection’
main.cpp:105: error: ‘glm’ has not been declared
main.cpp:105: error: ‘projection’ was not declared in this scope
main.cpp:109: error: ‘glm’ has not been declared
main.cpp:109: error: expected ‘;’ before ‘modelview’
main.cpp: In function ‘void render()’:
main.cpp:187: error: ‘cameraMatrix’ was not declared in this scope
main.cpp:187: error: ‘glm’ has not been declared
main.cpp:200: error: ‘glm’ has not been declared
I'm sure the answer is painfully obvious, but I am an OpenGL noob. I have even located all the openGL libraries and copy-pasted them into the folder with my main.cpp and all associated files, to no avail.

Turtle (mock framework) compilation errors

I'm trying to compile a simple example in Turtle (with boost unit test framework) and am getting compilation errors from within Turtle.
I'm assuming that Turtle doesn't really have errors and it's something that I'm doing wrong or have incompatible.
Any help would be appreciated.
The example:
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <turtle/mock.hpp>
BOOST_AUTO_TEST_CASE(trutletest){
BOOST_CHECK(1 == 4);
}
** I've distilled it so it doesn't even uses any Turtle features, just including it causes errors.
The errors I get:
In file included from ../turtle/include/turtle/detail/../matcher.hpp:14,
from ../turtle/include/turtle/detail/function.hpp:16,
from ../turtle/include/turtle/detail/functor.hpp:12,
from ../turtle/include/turtle/reset.hpp:14,
from ../turtle/include/turtle/mock.hpp:14,
from test.cpp:5:
../turtle/include/turtle/detail/../detail/is_functor.hpp:22: error: expected constructor, destructor, or type conversion before ‘(’ token
In file included from ../turtle/include/turtle/detail/function.hpp:16,
from ../turtle/include/turtle/detail/functor.hpp:12,
from ../turtle/include/turtle/reset.hpp:14,
from ../turtle/include/turtle/mock.hpp:14,
from test.cpp:5:
../turtle/include/turtle/detail/../matcher.hpp:87: error: ‘is_functor’ is not a member of ‘mock::detail’
../turtle/include/turtle/detail/../matcher.hpp:87: error: ‘is_functor’ is not a member of ‘mock::detail’
../turtle/include/turtle/detail/../matcher.hpp:87: error: template argument 1 is invalid
../turtle/include/turtle/detail/../matcher.hpp:88: error: template argument 3 is invalid
../turtle/include/turtle/detail/../matcher.hpp:89: error: expected unqualified-id before ‘>’ token
The compilation line:
g++ test.cpp -o test -I ../turtle/include/ -lboost_unit_test_framework
I'm using:
g++ (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4)
Turtle 1.2.4
As cv_and_he commented, the problem was using an old boost version.
Updating to the latest boost (1.54.0) fixed the problem.

Boost Asio GCC Link Error

I've just installed a clean vm with xubuntu 12.10 and I'm trying to port over some C++ code which works perfectly on Windows. First off, I've installed Virtualbox guest additions and GCC and I can compile code.
I've downloaded the boost library from the internet (boost_1_52) and I've dropped in the asio library from the asio website (boost_asio_1_4_8) and I've installed the multi-threading, shared link version using these instructions:
./bootstrap.sh --prefix=/usr &&
./b2 stage threading=multi link=shared
as root:
I know for a fact that boost works because I've been able to compile the test application here (linking with lboost_regex) and it works perfectly:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
So I'm trying to build one of the ASIO examples, which I've built before with no problems on Windows. The files are here:
http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/examples.html
See:
boost_asio/example/serialization/client.cpp
boost_asio/example/serialization/connection.hpp
boost_asio/example/serialization/server.cpp
boost_asio/example/serialization/stock.hpp
I throw my compiler this:
gcc client.cpp -I /usr/include/boost -lboost_system -lboost_thread -lboost_serialization
Which gives me this error:
connection.hpp:75:35: error: template argument 1 is invalid
connection.hpp:75:35: error: template argument 2 is invalid
connection.hpp:75:44: error: invalid type in declaration before ‘;’ token
connection.hpp:76:13: error: request for member ‘push_back’ in ‘buffers’, which is of non-class type ‘int’
connection.hpp:76:23: error: ‘asio’ is not a class or namespace
connection.hpp:77:13: error: request for member ‘push_back’ in ‘buffers’, which is of non-class type ‘int’
connection.hpp:77:23: error: ‘asio’ is not a class or namespace
connection.hpp:78:5: error: ‘asio’ is not a class or namespace
connection.hpp:78:23: error: ‘socket_’ was not declared in this scope
connection.hpp: In member function ‘void s11n_example::connection::async_read(T&, Handler)’:
connection.hpp:87:15: error: ‘asio’ does not name a type
connection.hpp:87:31: error: expected unqualified-id before ‘&’ token
connection.hpp:87:31: error: expected ‘)’ before ‘&’ token
connection.hpp:87:31: error: expected initializer before ‘&’ token
connection.hpp:90:5: error: ‘asio’ has not been declared
connection.hpp:90:22: error: ‘socket_’ was not declared in this scope
connection.hpp:90:31: error: ‘asio’ has not been declared
connection.hpp:91:21: error: ‘f’ was not declared in this scope
connection.hpp:92:17: error: ‘asio’ has not been declared
client.cpp: At global scope:
client.cpp:26:10: error: ‘asio’ has not been declared
client.cpp:26:26: error: expected ‘)’ before ‘&’ token
client.cpp:43:29: error: ‘asio’ does not name a type
client.cpp:43:45: error: expected unqualified-id before ‘&’ token
client.cpp:43:45: error: expected ‘)’ before ‘&’ token
client.cpp:43:35: error: expected ‘;’ at end of member declaration
client.cpp:43:47: error: ISO C++ forbids declaration of ‘e’ with no type [-fpermissive]
client.cpp:43:47: error: expected ‘;’ at end of member declaration
client.cpp:43:48: error: expected unqualified-id before ‘)’ token
client.cpp:125:1: error: expected ‘}’ at end of input
client.cpp:125:1: error: expected unqualified-id at end of input
client.cpp:125:1: error: expected ‘}’ at end of input
I'm really confused, its as if I've not built boost or I'm missing another link. I've also tried linking with Winsock, with no results. Please help!
Cheers
You are using gcc and g++ interchangeably. The line which doesn't work uses gcc, but the line which works uses g++. Using g++ instead of gcc may effect which default include path is used. Your initial error was not linking. It was compiling. Also, if you use the boost version, asio namespace is not asio. It's boost::asio.
Looks like boost/asio.hpp didn't get included correctly.
I don't remember exactly what the prefix option does, but I think your problem may be somewhere in there. The boost directory may not be in /usr/include/boost, but instead possibly /usr/boost.
That's one possibility. The second is that, instead of passing /usr/include/boost, you need to pass /usr/include, i.e.
gcc client.cpp -I /usr/include -lboost_system -lboost_thread -lboost_serialization
If you look at the example files, e.g. the connection.cpp example, it includes boost/asio.hpp. The boost/ part refers to a folder that should be looked for by the compiler in the include path(s) you specify using -I. So if you specified /usr/include/boost, the compiler is going to look for /usr/include/boost/boost/asio.hpp (notice the 2 occurrences of boost).
I think I've fixed the problem now. Using bjam and the auto-installer doesn't seem to accomplish much (it won't resolve to those paths for some reason).
Anyway, I downloaded the ASIO source code (non-boost this time) and put that in a directory on my desktop. In a similar fashion to how I do it on windows in Visual Studio, I managed to get it to link:
g++ client.cpp -I/home/devbox/desktop/asio-1.5.3/include - L/home/devbox/Desktop/boost_1_53_0/stage/lib -lboost_system -lboost_thread -lboost_serialization -o test
Cheers all