I have 2 separate working projects on a raspberry running raspbian. i am having some problems when joining them together and as i am not that good with the compiler itself(still learning) i don't know how to work it out.
Error (finish_with_error can be ignored):
In file included from main.c:20:0:
/usr/local/include/wiringPi.h:216:21: error: conflicting types for ‘bcm2835_delayMicroseconds’
bcm2835.h:912:17: note: previous declaration of ‘bcm2835_delayMicroseconds’ was here
main.c:200:6: warning: conflicting types for ‘finish_with_error’ [enabled by default]
main.c:124:33: note: previous implicit declaration of ‘finish_with_error’ was here
The command i am using to compile is:
gcc config.c rfid.c rc522.c main.c -o rc522_reader -lbcm2835 -lwiringPi -lwiringPiDev `mysql_config --cflags --libs`
Bcm2835.h(line 912):
extern void bcm2835_delayMicroseconds (uint64_t micros);
wiringPi.h(line 216):
extern void delayMicroseconds (unsigned int howLong) ;
The problem is that i cant see where i there is two declarations the same way, these are libraries so i would prefer not to modify to avoid malfunctioning on the libs, is there something i can do to tell the compiler what to do?
Thanks,
Related
Current Code Base
Os-Linux x64, have perl code, boost 1.42, GCC 4.4.7 and other dependencies as a part of project code.
The build works fine.
After Upgrade of GCC to 4.9.2
We made a copy of existing Linux ec2 instance (which works fine) and upgraded its GCC to 4.9.2.
When we are trying to build the project, getting the below error.
webql/rt/bootstrap: Compiling main.cxx
webql/rt/bootstrap: #/archive/webql/build/al/current/base/dev/general/gfilt -pthread -fPIC -DU_HAVE_NAMESPACE=1 -D_FILE_OFFSET_BITS=64 -D_unix -D_BSD -fexceptions -fmessage-length=0 -I/home/builder/archive/webql/build/al/current/base/dev/perl/core -DQL2_PLATFORM="al" -DJAVA_ARCH="amd64" -fvisibility=hidden -D_XOPEN_SOURCE=500 -I/archive/webql/build/al/current/base/dev/general -I/archive/webql/build/al/current/base/dev/general/include -I. -I/archive/webql/build/al/current/base/dev -I/archive/webql/build/al/current/base/dev/xml -I/archive/webql/build/al/current/base/dev/xml/libxml -I/archive/webql/build/al/current/base/dev/xml/libxslt -I/archive/webql/build/al/current/base/packages/al/inst/include -I/archive/webql/build/al/current/base/dev/zlib -I/archive/webql/build/al/current/base/packages/al/inst/jdk/include -I/archive/webql/build/al/current/base/packages/al/inst/jdk/include/linux -I/usr/java/include -I/usr/java/include/linux -I/mnt/usr/include -ggdb3 -O3 -DNDEBUG -c -o /archive/webql/build/al/current/base/dist/alr/obj/webql/rt/bootstrap/main.o main.cxx
In file included from ../perlapi/perl.h::,
from ../perlapi/Utils.h:,
from main.cxx::
/archive/webql/build/al/current/base/dev/perl/core/perl.h::49: error: declaration of int setresuid(uid_t, uid_t, uid_t) has a different exception specifier
int setresuid(uid_t ruid, uid_t euid, uid_t suid);
In file included from main.cxx::
/mnt/usr/include/unistd.h:: error: from previous declaration int setresuid(__uid_t, __uid_t, __uid_t) throw ()
extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
In file included from ../perlapi/perl.h::,
from ../perlapi/Utils.h:,
from main.cxx::
/archive/webql/build/al/current/base/dev/perl/core/perl.h: error: declaration of int setresgid(gid_t, gid_t, gid_t) has a different exception specifier
int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
In file included from main.cxx::
/mnt/usr/include/unistd.h:: error: from previous declaration int setresgid(__gid_t, __gid_t, __gid_t) throw ()
extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
make: Leaving directory `/archive/webql/build/al/current/base/dev/webql'
Things tried
Re compiled the boost 1.42 and other dependencies
Expectation
Even after trying several things the error remains same. perl.h is part of project code while unistd.h is a system file. Obviously perl.h is C code hence it cannot THROW exception as present in unstd.h function declaration.
Any help would be appreciated.
I'm trying to code the BST ADT, and the specification we were given requires use of 'auto' that is only included in C++14. I'm trying to compile, but I keep getting errors that 'auto' is only included in C++14, so I'm just wondering if there's a different way to compile the code so that it includes C++14? In every previous project I've done (over the last three semesters) I've been able to compile the file (say called main.cpp) just by using the code:
g++ -o main main.cpp
I've tried the following compile code
g++ -std=c++14 -o main main.cpp
but when I do that, I get like 100 errors that look like
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:1002:86: error: member reference base type 'std::__1::basic_string::__self_view' (aka 'int') is not a structure or union
append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:1002:99: error: member reference base type 'std::__1::basic_string::__self_view' (aka 'int') is not a structure or union
append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
What do these even mean?
I figured out the reasons behind the errors (turned out to be templating mistakes), but in the end compiling with g++ -std=c++14 -o main main.cpp is working. I still don't really understand any of the compilation stuff though, so if someone could explain a little bit/ provide a link I would appreciate
(this is not an answer, but too long for a comment)
Where did you get your g++ from? On most modern Mac OS installs, it is a symlink for clang++. What does g++ --version print?
Certainly you're using libc++, not libstdc++. The __1 in the type names is a giveaway, along with the path to <string>.
And the error message ('std::__1::basic_string::__self_view' (aka 'int') is weird, too. basic_string::__self_view is a string_view, not an int.
if you use Unix based operating systems such as Linux and OS X try this:
clang++ -g -std=c++1y main.cpp -o main
We are catching compiler errors when using sigemptyset on Cygwin under Newlib. The error occurs with a C++ compiler, but only when -std=XXX is used. Without a standard option, the test program compiles and executes as expected.
The test program is below, and the Cygwin header of interest follows. I don't see anything suspicious in the Cygwin header.
I've tried tricks like #define _GNU_SOURCE and #define _XOPEN_SOURCE 700. I've also tried tricks like using the global and std namespaces. Related, see What does -D_XOPEN_SOURCE do/mean? and Namespace issues in c++11?.
What is causing the compile failure and how do I fix it?
$ cat ~/test.cxx
#include <signal.h>
int main(int argc, char* argv[])
{
struct sigaction new_handler;
return sigemptyset(&new_handler.sa_mask);
}
Without a -std=XXX, it results in:
$ g++ -c test.cxx
$
With a -std=XXX, it results in:
$ g++ -std=c++03 -c test.cxx
test.cxx: In function int main(int, char**):
test.cxx:6:44: error: sigemptyset was not declared in this scope
return sigemptyset(&new_handler.sa_mask);
And when trying to use sigemptyset in the global namespace:
$ g++ -std=c++03 -c test.cxx
test.cxx: In function ‘int main(int, char**)’:
test.cxx:6:12: error: ‘::sigemptyset’ has not been declared
return ::sigemptyset(&new_handler.sa_mask);
^
Things get worse when using -std=gnu++03 and friends.
The function is an extension over the ISO C standard.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigemptyset.html
as such is protected on /usr/include/sys/signal.h by
__XSI_VISIBLE >= 4
see /usr/include/sys/features.h for details.
As defaults the largest definition set is used, but -std=XXX reduces the definition scope
The issue was worked through at Botan 2.1.0 does not compile under Cygwin 2.8.0 with g++ 5.4.0. Here are the two comments of interest.
First, from noloader:
Cygwin uses Newlib, not GNU's libstdc++. When there's no
-std=c++XX, current GCC defaults to -std=gnu++11 (GCC 6 changes
to gnu++14 by default). I
believe GNU sources ensures expected functions, like sigaction, are
available.
You might consider trying -D_XOPEN_SOURCE=600 or
-D_XOPEN_SOURCE=700.
Also see C++ and feature guards Warning
Question on the
Newlib mailing list.
Second, from SideChannel:
Thanks to #noloader. Until now -std=c++11 was set in Makefile. The
important info is in above mentioned thread on the Newlib mailing
list. Yaakov Selkowitz wrote:
G++ defines _GNU_SOURCE on glibc targets, meaning that -std=c++NN is, contrary to the documentation, not strict ISO C++:
So, applying the patch #987
AND setting -std=gnu++11 works for me. I
did not try the other -D options (I think the other fact is more
fundamental). Summarizing, #randombit please apply the PR #987 and set
-std=gnu++11 for gcc under Cygwin.
I have made an OpenGL project compilable with GCC (version 4.7.3 and newer) and runable on Linux. When trying to compile the same code under Windows using MSYS2 with GCC 4.9.2 installed, I get tons of error reports:
g++ -g --std=c++11 src/*.cpp -Iinclude -Isrc -lIL -lILU -lILUT -lGL -lGLU -lglut -lm -DWIN32 -I/mingw64/include windows/src/*.cpp -o "Achtung, die Kurve 3D!"
In file included from /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/stringfwd.h:40:0,
from /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/string:39,
from include/windows.h:1,
from /usr/include/w32api/GL/gl.h:13,
from /mingw64/include/GL/freeglut_std.h:143,
from /mingw64/include/GL/freeglut.h:17,
from src/controls.cpp:1:
/usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:63:3: error: template with C linkage
template<typename>
^
/usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:66:3: error: template specialization with C linkage
template<>
^
/usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:70:3: error: template with C linkage
template<typename, typename>
^
...
In file included from /mingw64/include/GL/freeglut_std.h:143:0,
from /mingw64/include/GL/freeglut.h:17,
from src/controls.cpp:1:
/usr/include/w32api/GL/gl.h:684:1: error: ‘WINGDIAPI’ does not name a type
WINGDIAPI void APIENTRY glAccum(GLenum op,GLfloat value);
...
/usr/include/w32api/GL/gl.h:1037:24: error: expected ‘)’ before ‘*’ token
typedef void (APIENTRY *PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)(GLenum target,GLenum pname,GLfloat *params);
^
In file included from /mingw64/include/GL/freeglut_std.h:144:0,
from /mingw64/include/GL/freeglut.h:17,
from src/controls.cpp:1:
/usr/include/w32api/GL/glu.h:24:25: error: expected initializer before ‘gluErrorString’
const GLubyte *APIENTRY gluErrorString(GLenum errCode);
^
/usr/include/w32api/GL/glu.h:25:25: error: expected initializer before ‘gluErrorUnicodeStringEXT’
const wchar_t *APIENTRY gluErrorUnicodeStringEXT(GLenum errCode);
^
...
This is taken from just a partial log consisting of 4500 lines of errors. These are the most frequent ones repeated many times.
I previously thought that the problem lied in old MSYS/MinGW (not the MSYS2 port) which I tried first with the same results. However, MSYS2 did not solve the problems which makes me completely clueless since my code is written in C++ and it only requires standard C and C++ header files along with some GL ones. I do not use any extern "C" mangling.
You are using msys2 GCC here, not mingw-w64 GCC.
Please read the MSYS2 wiki [1] where all of this is explained, but briefly:
Run mingw64_shell.bat, not msys2_shell.bat, install the mingw-w64 GCC toolchain package(s). This command installs both the 32-bit and 64-bit ones using the bash curly brace expansion feature:
pacman -S mingw-w64-{x86_64,i686}-toolchain
.. then see that gcc -dumpmachine reports x86_64-w64-mingw32 and not x86_64-pc-msys
[1] https://sourceforge.net/p/msys2/wiki/Home/
The problem turned out not to be related to OpenGL, neither to MSYS(2)/MinGW(-w64) or MS Visual Studio 2013.
For anyone who might be facing the same problems as I was, the vast majority of all the error reports was generated because there was a custom windows.h header file present in my project's include path. A header with the same name is present in standard Windows header library and is essential for proper functionality of other libraries.
Lesson learned: never try to name a file with system-specific code after the operating system.
I am writing a Rcpp code that include two library RcppArmadillo and trng4. However, when I include two header files (RcppArmadillo.h and trng/gamma_dist.hpp) it gives compilation error.
trng/special_functions.hpp:47:39: error: declaration of ‘float lgammaf(float) throw ()’ has a different exception specifier
extern "C" float lgammaf(float) throw();
include-fixed/math.h:476:14: error: from previous declaration ‘float lgammaf(float)’
extern float lgammaf(float);
Full compilation options are
-fopenmp -lgomp -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -DDISABLE_FIO -I/usr/local/include -I"/Users/avi/Library/R/3.0/library/Rcpp/include" -I"/Users/avi/Library/R/3.0/library/RcppArmadillo/include" -fPIC -pipe -std=c++0x -Wall -pedantic -c
Seems like the lgammaf is declared in both header files. I tried using -E with g++ option but that give ld warning " .o, file was built for unsupported file format" and give error function in not available in .Call when I try it to after loading in R. What am I doing wrong?
Perhaps out of context I am using trng4 package to develop a thread gibbs sampler (in openmp) that sample from gamma distribution. I am currently running this MacOS. But eventual it will run in linux server.
It sounds like you do have a problem between Armadillo and trng4. Maybe you should try to, if possible, separate your interface so that you do not need to include from both in the same file.
Someone can correct me if I'm wrong, but I believe you prevent this issue by using #ifndef in each header file so that it's not defined a second time even if it's included a second time. But I guess these aren't your files are they...?
#ifndef __your_unique_header_name__
blah blah
#endif