I am trying to use inotify to detect file system changes on an Ubuntu 12.04 OS with Linux 3.8 kernel in a C++ program.
When I compile the program with gcc, it works as expected.
But when I compile the program with g++, it shows errors like -
inotify_test.cpp:23:21: error: ‘inotify_init’ was not declared in this scope
inotify_test.cpp:31:61: error: ‘inotify_add_watch’ was not declared in this scope
Any ideas on how to resolve this is appreciated.
P.S. Some internet links indicate the use of <sys/inotify.h>, but I do not have that file. I only have <linux/inotify.h>.
Thanks!
Related
I just started using MinGW for Windows. When trying to create executable using
g++ a.cpp -o a.exe -std=c++14
for the code below:
#include <string>
using namespace std;
int main()
{
string x = to_string(123);
return 0;
}
I'm getting following error:
C:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of vsnprintf
C:\Users\..\Local\Temp\cc4sJDvK.o:c:/mingw/include/stdio.h:426: first defined here
collect2.exe: error: ld returned 1 exit status
What is the root cause for this error and how can I make it go away? While I can easily find a replacement for to_string() function I'm not sure what is causing this error to occur in the first place.
Installing MinGW packages mingw32-libmingwex-* will link an appropriate version of vsnprintf and avoid the linker error.
This issue, i.e. multiple definition of vsnprintf, still exists in MinGW as December 2019.
After investigating a lot, I found the solution in the official mailing list.
It's a bug in mingwrt-5.2.2. Downgrading to the mingwrt-5.2.1 version solves that issue.
To do that, just input the following command:
mingw-get upgrade mingwrt=5.2.1
Then restart the MinGW shell.
Read the full story here.
Note: MinGW-w64 and MinGW are separate projects, so the accepted solution is not so helpful to me, as I want to keep MinGW and not to move to MinGW-w64.
I solved this issue using MinGW w64 compiler
download mingw-w64-install.exe
setup to Version: 6.3.0, Architecture: i686, Threads: posix, Exception: dwarf and Build revision: 2.
I hope this will be of some help.
There are multiple definitions of vsnprintf in both stdio.h and libmingwex.a. I am able to work this around by adding #define __USE_MINGW_ANSI_STDIO 0 to the start of the code, before any includes, which disables the definition of vsnprintf in stdio.h.
I'm running a .cpp code where I get some string dependence error
"basic_string.tcc: No such file or directory"
which should come from some compatibility issue. On my MAC machine "clang version 11.0.0" it works but on my linux machine with gcc 6.3.0 its fails. This happens on function
line read_in(std::string filename_begin, std::string fileformat, size_type n_files)
Any idea how to debug this perhaps,
thanks, Damir
Sort briefing what I am trying to do:
I want to use vnode-lp on my windows PC. I’ve installed MinGW. I’ve installed the necessary dependencies like LAPACK & BLAS libraries as well as Profil/BIAS. The installation of all libraries passed the make and make install process without errors. I hope (!) I’ve managed to install it correctly.
Now the Problem:
Now I’ve tried to get a simple program compiled with basically northing in it just an #include “vnode.h”. First I tried it with Microsoft Visual Studio. Since this gave me several errors I tried to compile it with g++ using MinGW. This gives me the same errors. It starts with
./matrix.w:90:17: error: ‘v_bias’ is not a namespace-name
The Question:
How to include vnodelp into an c++ program and compile it without errors under windows, am I missing something?
Off-topic:
I am trying to get this running for over a week now and don’t know what to do anymore.
C++ is most definitely not C, and packages designed for C++ will never compile and run as C code. So, what you're trying to do really can't be done unless you do some fancy stuff by creating a .dll or something like that, and even then I think you wouldn't get the functionality you want. Why not write your code in C++ and compile with g++ or a similar compiler?
I have managed to finally solve this issue. In case someone has the same problem here is the solution.
I have missed something in the call. Here is the full call that has worked for me:
g++ -o2 –Wall –Wno-deprecated –DNDEBUG – DPROFIL_VNODE – DMAXORDER=50 –I(path to profil bias)/include –I(path to profil bias)/include/BIAS –I(path to profil bias)/src/Base –I(path to vnodelp)/FADBAD++ -I../include –DNDEBUG –c –o (filename).o (filename).cc
g++ -L(path to profil bias)/lib –L(path to lapack)/lib –L../lib –o (filename) (filename).o –lvnode –lProfil –lBias –llr (path to lapack)/lib/liblapack.lib (path to lapack)/lib/libblas.lib –lstd++
funfact:
This also complies with gcc instead of g++
I'm installing Gearman 1.1.12 on Windows 8.1 through Cygwin and getting the following error:
CXX libtest/libtest_libtest_la-formatter.lo
In file included from ./libtest/test.hpp:69:0,
from ./libtest/common.h:85,
from libtest/formatter.cc:39:
./libtest/exception.hpp:83:13: error: 'va_list' has not been declared
void init(va_list);
^
I've verified that the source code has the necessary includes and that the GCC/G++ compilers are the latest version, 4.8.2
Any ideas on how to fix this?
I had this problem today and it was "fixed" by including <cstdarg> on libtest/test.hpp.
Did you check that?
(Wanted to reply as a comment, but I don't have enough rep yet)
Related to problem 16611678 I need a new version of gdb in my centos 6.5 64.
I try to compile GDB (7.7, 7.6.2 and 7.5), without success, the error is related to get_tty_state() in ser-unix.c:
ser-unix.c:118:1: error: conflicting types for ‘get_tty_state’
My gcc version is 4.8.2
Before the function declaration there is preprocessor directives for defining hardwire_ttystate if HAVE_TERMIOS is defined and I think the problem come from here (if needed I can post the piece of code), as HAVE_TERMIOS is undefined.
Any help would be appreciated!
Nathanaël