Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fail on windows #6341

Closed
circleous opened this issue Dec 18, 2016 · 20 comments
Closed

Build fail on windows #6341

circleous opened this issue Dec 18, 2016 · 20 comments
Labels
Windows Microsoft Windows platform support issues
Milestone

Comments

@circleous
Copy link

circleous commented Dec 18, 2016

I'm trying to build radare2 on windows using mingw-w64 (MSYS2).
Following radare gitbooks windows compilation instruction.

zip_close.c:645:28: error: ‘_O_BINARY’ undeclared (first use in this function)
     _setmode(_fileno(tfp), _O_BINARY );

Fails when trying to run make

@circleous
Copy link
Author

HPCE/hpce-2015-cw2#3
Seems like this has same issue. After comment out the line, build is fine.

diff --git a/shlr/zip/zip/zip_close.c b/shlr/zip/zip/zip_close.c
index 42fa58c..d32f84a 100644
--- a/shlr/zip/zip/zip_close.c
+++ b/shlr/zip/zip/zip_close.c
@@ -642,7 +642,7 @@ _zip_create_temp_output(struct zip *za, FILE **outp)
       According to Pierre Joye, Windows in some environments per
       default creates text files, so force binary mode.
     */
-    _setmode(_fileno(tfp), _O_BINARY );
+    //_setmode(_fileno(tfp), _O_BINARY );
 #endif
 
     *outp = tfp;

@XVilka
Copy link
Contributor

XVilka commented Dec 19, 2016

@circleous Why are you closed it?

@circleous circleous reopened this Dec 19, 2016
@circleous
Copy link
Author

The program runs fine so far. So, i thought for closing this.

@XVilka
Copy link
Contributor

XVilka commented Dec 19, 2016

No, but the bug itself remains.

@XVilka XVilka added bug Windows Microsoft Windows platform support issues labels Dec 19, 2016
@radare radare added this to the 1.1.0 milestone Dec 19, 2016
@radare
Copy link
Collaborator

radare commented Dec 19, 2016

commenting this fixes the build but breaks the usage. O_BINARY should be available on windows. mainly because its windows-only flag

@radare
Copy link
Collaborator

radare commented Dec 19, 2016

pushed a fix. pls confirm i dont have such env to test

@radare
Copy link
Collaborator

radare commented Dec 19, 2016 via email

@circleous
Copy link
Author

circleous commented Dec 19, 2016

warning: implicit declaration of function ‘_fileno’ This isnt only happen on _fileno but _snprintf, _read, ... winapi related. After digging out a bit, it needs -D_POSIX_SOURCE. After that, it triggers another error meanwhile the first problem is solved. Until now, i havent found any other solution for this.
sys.c:419:4: error: unknown type name ‘fd_set’
ref: http://stackoverflow.com/questions/15749184/fileno-not-available https://cygwin.com/ml/cygwin-apps/2013-04/msg00413.html

-fPIC is ignored in windows. This will trigger warning: -fPIC ignored for target (all code is position independent). Weird thing is that mk/platform.mk isnt filtering msys. Somewhat related #40 Since its intended so i leave it as is.

@radare
Copy link
Collaborator

radare commented Dec 20, 2016

Maybe the instructions are wrong? i just do sys/mingw32.sh and it builds fine on osx and linux

@radare radare modified the milestones: 1.2.0, 1.1.0 Dec 20, 2016
@circleous
Copy link
Author

circleous commented Dec 20, 2016

Oddly enough, build runs fine on cygwin x86 windows. So, i'm guessing warning: implicit declaration of function ‘_fileno and error on _read, _snprintf, etc.. somewhat related to my hacky current build system, not to mention some cflags added along the way. I'll try doing it from vanilla.

@XVilka
Copy link
Contributor

XVilka commented Dec 20, 2016

Well, Cygwin 32/64, Mingw32 on Windows and Mingw32 on *nix, Mingw-w64, MSYS2, etc - everything is different and use different architectures. @circleous Can you please provide a full build log?

@radare
Copy link
Collaborator

radare commented Dec 20, 2016 via email

@XVilka
Copy link
Contributor

XVilka commented Dec 20, 2016

well, Mingw32 is not very 'native' one, unlike Mingw-w64. Cygwin provides unix-like experience of radare2 on windows - true colors, piping with unix utils, etc. Mingw32 can be easily integrated with Visual Studio and so on. It's different target auditory.

@XVilka
Copy link
Contributor

XVilka commented Dec 22, 2016

I can't reproduce it on my environment. @circleous are you?

@circleous
Copy link
Author

circleous commented Dec 23, 2016

Sorry for the wait. http://sprunge.us/ihHC
EDIT: This is tested on Windows 10 64 bit with Mingw-w64.

@radare
Copy link
Collaborator

radare commented Dec 23, 2016 via email

@radare
Copy link
Collaborator

radare commented Jan 2, 2017

_fileno should be defined in stdio.h . see https://msdn.microsoft.com/en-us/library/zs6wbdhx.aspx

@radare
Copy link
Collaborator

radare commented Jan 2, 2017

So, as long as the fopen is done with the 'b' bit. this thing is totally unnecessary, i have just commented out. pls confirm its fixed

@radare radare added the release label Jan 2, 2017
@circleous
Copy link
Author

Yep, build is fine now.

@Maijin Maijin closed this as completed Jan 4, 2017
@Maijin
Copy link
Contributor

Maijin commented Jan 4, 2017

Then close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Microsoft Windows platform support issues
Projects
None yet
Development

No branches or pull requests

4 participants