Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems compiliing c++ code using cygwin

I am trying to compile some source code in cygwin (in windows 7) and get the following error when I run the make file

g++ -DHAVE_CONFIG_H -I. -I..  -I..  -Wall -Wextra -Werror -g -O2 -MT libcommon_a  Fcntl.o -MD -MP -MF .deps/libcommon_a-Fcntl.Tpo -c -o libcommon_a-Fcntl.o `test -f 'Fcntl.cpp' || echo './'`Fcntl.cpp
Fcntl.cpp: In function int setCloexec(int):
Fcntl.cpp:8: error: 'F_GETFD' was not declared in this scope
Fcntl.cpp:8: error: 'fcntl' was not declared in this scope
Fcntl.cpp:11: error: 'FD_CLOEXEC' was not declared in this scope
Fcntl.cpp:12: error: 'F_SETFD' was not declared in this scope
make[4]: *** [libcommon_a-Fcntl.o] Error 1
make[4]: Leaving directory `/abyss-1.1.2/Common'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/abyss-1.1.2'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/abyss-1.1.2'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/c/Users/Martin/Documents/NetBeansProjects/abyss-1.1.2_1'
make: *** [.build-impl] Error 2

The problem file is:-

#include "Fcntl.h"
#include <fcntl.h>


/* Set the FD_CLOEXEC flag of the specified file descriptor. */
int setCloexec(int fd)
{
 int flags = fcntl(fd, F_GETFD, 0);
 if (flags == -1)
  return -1;
 flags |= FD_CLOEXEC;
 return fcntl(fd, F_SETFD, flags);
}

I don't understand what is going on, the file fcntl.h is available and the varaiables that it says were not declared in this scope do not give an error when I compile the file on its own

Any help would be much appreciated

Many Thanks

like image 714
user343403 Avatar asked May 23 '26 17:05

user343403


1 Answers

I've not built things with Cygwin, so this might be off-base, but considering that you're building on Windows, which has a case-insensitive filesystem, are you sure that the compiler can tell the difference between your header Fcntl.h and the system header fcntl.h? It might just be including your header twice and never getting the system header.

like image 196
Tyler McHenry Avatar answered May 25 '26 06:05

Tyler McHenry