Problems compiliing c++ code using cygwin - c++

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

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.

What's up with those #include statements? It seems like you have a header file in your project called Fcntl.h, is that right? Does it have include guards in it? If it does, maybe you're accidentally using the same guard as the built-in header, and as a result not getting its contents. Cygwin normally runs on a case-insensitive filesystem, so even giving those headers similar names like that is probably dangerous.

Related

"No such file or directory" when including SFML/Graphics.hpp from a header file

Everything compiles fine when I include this particular .hpp in a header in a test project I made with identical (copy-pasted) project settings (include path, linker path etc.). For some reason however, my project won't compile when trying to include it from a file deep in my header hierarchy. Headers have guards.
Here's the log:
C:\WINDOWS\system32\cmd.exe /C ""C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe" -j4 SHELL=cmd.exe -e -f Makefile"
"----------Building project:[ Rogue - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'E:/CPP/Rogue/Rogue'
codelite-cc "C:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe" -g -O0 -std=c++17 -std=c++14 -std=c++11 -Wall Char.cpp -o Char
In file included from Item.h:7:0, //this says ' #include "Entity.h" '
from Char.h:12, //this says ' #include "Item.h" '
from Char.cpp:1:
Entity.h:5:29: fatal error: SFML/Graphics.hpp: No such file or directory
compilation terminated.
mingw32-make.exe[1]: *** [Char] Error 1
<builtin>: recipe for target 'Char' failed
mingw32-make.exe[1]: Leaving directory 'E:/CPP/Rogue/Rogue'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====3 errors, 1 warnings====
And here is my header "hierarchy". (A.h -> B.h means that A #includes B)
defs.h and utils.h are irrelevant class-wise (they contain #defines and utility functions respectively.)
My compiler settings:
Compiler
Linker
SFML is installed in E:/CPP/Libs/SFML
The project is in E:/CPP/Rogue
No enviroment variable as far as I'm aware.

FingerJetFXOSE Cygwin compilation error

Can someone help me, Im having problem in compiling FingerJetFXOSE in Cygwin 32
gcc version 5.4.0 (GCC)
I used the following command:
$ make -f Makefile
make -C src/libFRFXLL
make[1]: Entering directory '/home/src/FingerJetFXOSE-master/src/libFRFXLL'
make -C src/libFRFXLL
make[2]: Entering directory '/home/src/FingerJetFXOSE- master/src/libFRFXLL/src/libFRFXLL'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/src/FingerJetFXOSE-master/src/libFRFXLL/src/libFRFXLL'
make[1]: Leaving directory '/home/src/FingerJetFXOSE-master/src/libFRFXLL'
make -C src/libfjfx
make[1]: Entering directory '/home/src/FingerJetFXOSE-master/src/libfjfx'
g++ -O2 -Wl,--strip-all -I../../include -I../libFRFXLL/include -fno- exceptions-fno-rtti -fno-stack-protector -fPIC -shared -nodefaultlibs -Wl,--version-script
I got this error at the end:
../libFRFXLL/lib/libFRFXLL.a(FRFXLLCreateFeatureSetInPlaceFromRaw.o):FRFXLLCreat
eFeatureSetInPlaceFromRaw.cpp:(.text$_ZN14FingerJetFxOSE15FpRecEngineImpl20Featu
reExtractionObjINS0_8Embedded24FeatureExtractionInPlaceEE16CreateFeatureSetIhEEi
PT_jjjjjPPv[__ZN14FingerJetFxOSE15FpRecEngineImpl20FeatureExtractionObjINS0_8Emb
edded24FeatureExtractionInPlaceEE16CreateFeatureSetIhEEiPT_jjjjjPPv]+0x159c): un
defined reference to `memmove'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:62: ../../lib/libfjfx.so.5.2.0] Error 1
make[1]: Leaving directory '/home/usr/FingerJetFXOSE-master/src/libfjfx'
make: *** [Makefile:50: src/libfjfx] Error 2
Thanks
I looked at the makefiles for the FingerJetFXOSE project here:
https://github.com/FingerJetFXOSE/FingerJetFXOSE
The makefiles do not support Cygwin. The README says that Windows is supported, but I suspect they mean a Visual-Studio-based build after a manual source import.
I think you either have to compile on GNU/Linux, or compile this code without the upstream makefiles.

Error building wxWidgets using -j (jobs) option with MinGW

I'm compiling WxWidgets for Windows using the following command line:
mingw32-make -f makefile.gcc BUILD=release SHARED=1 -j6
The last parameter (-j) is used to speed up the compilation by running multiple jobs in parallel, in my case making full use of my 6-core processor. A single-threaded build normally takes very long.
However, I get the following output when hitting Enter:
if not exist gcc_mswudll mkdir gcc_mswudll
if not exist ..\..\lib\gcc_dll mkdir ..\..\lib\gcc_dll
if not exist ..\..\lib\gcc_dll\mswu\wx\setup.h copy ..\..\include\wx\msw\setup.h ..\..\lib\gcc_dll\mswu\wx\setup.h
gcc -c -o gcc_mswudll\wxregex_regcomp.o -O2 -mthreads -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\msw
u -D__WXMSW__ -D_UNICODE -MTgcc_mswudll\wxregex_regcomp.o -MFgcc_mswudll\wxregex_regcomp.o.d -MD -MP ../../src/regex/
regcomp.c
The system can not find the path specified.
0 file(s) copied.
makefile.gcc:5651: recipe for target '..\..\lib\gcc_dll\mswu\wx\setup.h' failed
mingw32-make: *** [..\..\lib\gcc_dll\mswu\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from ..\..\include/wx/defs.h:27:0,
from ../../src/regex/regcustom.h:39,
from ../../src/regex/regguts.h:38,
from ../../src/regex/regcomp.c:33:
..\..\include/wx/platform.h:183:22: fatal error: wx/setup.h: No such file or directory
#include "wx/setup.h"
^
compilation terminated.
makefile.gcc:5702: recipe for target 'gcc_mswudll\wxregex_regcomp.o' failed
mingw32-make: *** [gcc_mswudll\wxregex_regcomp.o] Error 1
Then, if I just repeat the same command a second time, the following output is shown:
if not exist ..\..\lib\gcc_dll\mswu mkdir ..\..\lib\gcc_dll\mswu
if not exist ..\..\lib\gcc_dll\mswu\wx\setup.h copy ..\..\include\wx\msw\setup.h ..\..\lib\gcc_dll\mswu\wx\setup.h
gcc -c -o gcc_mswudll\wxregex_regcomp.o -O2 -mthreads -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\msw
u -D__WXMSW__ -D_UNICODE -MTgcc_mswudll\wxregex_regcomp.o -MFgcc_mswudll\wxregex_regcomp.o.d -MD -MP ../../src/regex/
regcompThe system can not find the path specified.
.c
0 file(s) copied.
makefile.gcc:5651: recipe for target '..\..\lib\gcc_dll\mswu\wx\setup.h' failed
mingw32-make: *** [..\..\lib\gcc_dll\mswu\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from ..\..\include/wx/defs.h:27:0,
from ../../src/regex/regcustom.h:39,
from ../../src/regex/regguts.h:38,
from ../../src/regex/regcomp.c:33:
..\..\include/wx/platform.h:183:22: fatal error: wx/setup.h: No such file or directory
#include "wx/setup.h"
^
compilation terminated.
makefile.gcc:5702: recipe for target 'gcc_mswudll\wxregex_regcomp.o' failed
mingw32-make: *** [gcc_mswudll\wxregex_regcomp.o] Error 1
Then... If I try a third time, the compilation finishes successfully.
Question: Is it ok to follow this procedure to build WxWidgets in parallel, or is there a possibility that it will lead to problems when using the compiled binaries later on?
Unfortunately there is indeed a bug in MSW makefiles with missing dependencies of the various libraries on setup_h target. It should be safe to do make setup_h first and then make -jN.
Alternatively, you could build using configure as explained in this old but still valid post, then just make -jN works perfectly fine.

Netbeans 8.0 (Windows 8) Not recognizing stoi

I have scoured google for a solution to fix this (including several posts here on c++ 11 features not working) and I can't find a solution. I have grown attached to netbeans in past year, using it for all my computer science courses. But it is slightly bothersome that some features of C++ are limited in my IDE, especially when they are features my professor is using to teach C++. When I use stoi() in any way I get an "Unable to resolve identifier" error. Is there a hot fix of sorts to get netbeans to acquire these features?
I've worked around it for my first programming assignment, but since I'm just now learning C++ I'd like to follow my professor's lead at the moment without doing anything extraneous.
I have tried the accepted solution here: How to use C++11 std::stoi with gcc?, and here: Netbeans C/C++ 7.2 -std=C++11 not recognized by gcc v4.6 or lower and I still get errors. And just as a disclaimer, to my knowledge I am using the listed includes involved here. So if anyone has a solution I'd appreciate it quite much.
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/cs_240_hw01.exe
make[2]: Entering directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f "build/Debug/Cygwin_4.x-Windows/main.o.d"
g++ -std=c++0x -c -g -std=c++11 -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:24:26: error: 'stoi' was not declared in this scope
int myint = stoi(test);
^
nbproject/Makefile-Debug.mk:84: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
nbproject/Makefile-Debug.mk:62: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
EDIT: Added Build output

Can't build test application with WxWIdgets in Netbeans

I'm a total c++ Newbie.
I'm trying to build windows aplications with Wx-Widgets under Net Beans.
So far so good. I have instaled everything, configured, build wx-widgets and attached it to the new project - with help of a good man here: Can't make wx-widget work with net-beans.
Now I try to build my first app:
#include <wx/string.h>
int main(int argc, char **argv)
{
wxPuts(wxT("A wxWidgets console application"));
}
and this is what I get:
I'm not sure if this is readable so I paste the errors:
g++ `C:\WXWIN\wx-config --cxxflags` -c -g -I../../../WXWIN/include `C:\WXWIN\wx-config --cxxflags` -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
/bin/sh.exe: C:WXWINwx-config: command not found
/bin/sh.exe: C:WXWINwx-config: command not found
In file included from ../../../WXWIN/include/wx/defs.h:21:0,
from ../../../WXWIN/include/wx/string.h:25,
from main.cpp:1:
../../../WXWIN/include/wx/platform.h:196:22: fatal error: wx/setup.h: No such file or directory
compilation terminated.
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/c/xampp/htdocs/WxWwigets_tutorial'
make[1]: Leaving directory `/c/xampp/htdocs/WxWwigets_tutorial'
BUILD FAILED (exit value 2, total time: 859ms)
Please notice that I have set everything in linker and compiler like ordered: http://wiki.wxwidgets.org/Compiling_using_Netbeans
The error is right in front of you: "command not found". If you use /bin/sh, you must use Unix style paths, e.g. C:/WXWIN/wx-config instead of DOS paths with the backslashes.
I seriously advise you to get familiar with the environment you're using instead of just following the Wiki instructions without understanding them, otherwise your problems won't be over any time soon.