Reputation: 93
I'm trying to compile a small .cpp file but running into issues since this file utilizes functions found in many other files. Basically, I cloned the ZCash repo and am currently trying to use specific files in that project to do some testing. When I compile the entire ZCash repo that I cloned everything works perfectly, but when I try to compile the files I'm working with some of them get syntax errors.
My Makefile:
CC = g++
CFLAGS = -std=c++11 -Wall -g -c
IDIR = /home/parallels/zcash/src/
INC = -I /home/parallels/zcash/src/ -I
/home/parallels/zcash/depends/x86_64-unknown-linux-gnu/include/
VPATH = /home/parallels/zcash/src/
all: Main.o KeyGen.o prf.o uint256.o sha256.o
$(CC) Main.o KeyGen.o prf.o uint256.o sha256.o -o keygenerator
Main.o: Main.cpp
$(CC) $(CFLAGS) Main.cpp $(INC)
KeyGen.o: KeyGen.cpp
$(CC) $(CFLAGS) KeyGen.cpp $(INC)
prf.o: prf.cpp
$(CC) $(CFLAGS) prf.cpp $(INC)
uint256.o: uint256.cpp
$(CC) $(CFLAGS) uint256.cpp $(INC)
sha256.o: sha256.cpp
$(CC) $(CFLAGS) sha256.cpp $(INC)
clean:
rm -rf *.o keygenerator
The .cpp files being compiled reference these other files:
Main.cpp:
#include "KeyGen.h"
#include "uint252.h"
#include "uint256.h"
#include <string>
KeyGen.cpp
#include "KeyGen.h"
#include "prf.h"
prf.cpp
#include "prf.h"
#include "crypto/sha256.h"
uint256.cpp
#include "uint256.h"
#include "utilstrencodings.h"
#include <stdio.h>
#include <string.h>
sha256.cpp
#include "crypto/sha256.h"
#include "crypto/common.h"
#include <string.h>
#include <stdexcept>
So, after I try to compile these files I get the following error:
g++ -std=c++11 -Wall -g -c Main.cpp -I /home/parallels/zcash/src/ -I /home/parallels/zcash/depends/x86_64-unknown-linux-gnu/include/
g++ -std=c++11 -Wall -g -c KeyGen.cpp -I /home/parallels/zcash/src/ -I /home/parallels/zcash/depends/x86_64-unknown-linux-gnu/include/
g++ -std=c++11 -Wall -g -c prf.cpp -I /home/parallels/zcash/src/ -I /home/parallels/zcash/depends/x86_64-unknown-linux-gnu/include/
g++ -std=c++11 -Wall -g -c uint256.cpp -I /home/parallels/zcash/src/ -I /home/parallels/zcash/depends/x86_64-unknown-linux-gnu/include/
g++ -std=c++11 -Wall -g -c sha256.cpp -I /home/parallels/zcash/src/ -I /home/parallels/zcash/depends/x86_64-unknown-linux-gnu/include/
In file included from /usr/include/x86_64-linux-gnu/bits/byteswap.h:35:0,
from /usr/include/endian.h:60,
from /usr/include/x86_64-linux-gnu/bits/waitstatus.h:64,
from /usr/include/stdlib.h:42,
from /home/parallels/zcash/src/crypto/sha256.h:9,
from sha256.cpp:5:
/home/parallels/zcash/src/compat/endian.h:111:17: error: expected unqualified-id before ‘__extension__’
inline uint16_t htobe16(uint16_t host_16bits)
^
In the offending file /home/parallels/zcash/src/compat/endian.h:111:17, htobe16 is used as follows:
#if HAVE_DECL_HTOBE16 == 0
inline uint16_t htobe16(uint16_t host_16bits) //line #111
{
return bswap_16(host_16bits);
}
#endif // HAVE_DECL_HTOBE16
There also exists a file: /usr/include/endian.h who references htobe16 as follows.
# include <bits/byteswap.h> //line #60
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define htobe16(x) __bswap_16 (x)
# define htole16(x) (x)
# define be16toh(x) __bswap_16 (x)
# define le16toh(x) (x)
Note: All the .cpp file I am compiling are located in both the ZCash repo that I cloned and the new folder I created (wondering if this might be the issue).
The folder I'm currently working on contains : KeyGen.cpp
KeyGen.h
Main.cpp
Makefile
prf.cpp
prf.h
serialize.h
sha256.cpp
sha256.h
uint252.h
uint256.cpp
uint256.h
Sorry for the long post, I truly appreciate your time and would really appreciate some help!
Upvotes: 0
Views: 421
Reputation: 91
The inline functions are already declared by several macros with the same name. Similar to this question: error: expected unqualified-id before ‘__extension__’ in Linux (Cent OS)
Could have to do with a unconfigured part of the slice you're building from the whole project as this Github discussion seems to indicate: https://github.com/bitcoin/bitcoin/issues/5920
Upvotes: 0