phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

PhantomJS 2 does not build on OS X 10.0 (Yosemite)

Open sikachu opened this issue 12 years ago • 36 comments

There're several warning along the way, but the error that fails the build was:

/Applications/Xcode-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -pipe -O2 -isysroot /Applications/Xcode-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.6 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_GRAPHICSVIEW -DQT_NO_GRAPHICSEFFECT -DQT_NO_STYLESHEET -DQT_NO_STYLE_CDE -DQT_NO_STYLE_CLEANLOOKS -DQT_NO_STYLE_MOTIF -DQT_NO_STYLE_PLASTIQUE -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_PRINTSUPPORT_LIB -DQT_PLATFORMSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/macx-clang -I. -I../../../../include/QtPrintSupport/5.3.0 -I../../../../include/QtPrintSupport/5.3.0/QtPrintSupport -I../../../../include -I../../../../include/QtPrintSupport -I../../../../include/QtWidgets/5.3.0 -I../../../../include/QtWidgets/5.3.0/QtWidgets -I../../../../include/QtPlatformSupport -I../../../../include/QtPlatformSupport/5.3.0 -I../../../../include/QtPlatformSupport/5.3.0/QtPlatformSupport -I../../../../include/QtWidgets -I../../../../include/QtGui/5.3.0 -I../../../../include/QtGui/5.3.0/QtGui -I../../../../include/QtCore/5.3.0 -I../../../../include/QtCore/5.3.0/QtCore -I../../../../include/QtGui -I../../../../include/QtCore -I.moc qcocoaapplicationdelegate.mm -o .obj/qcocoaapplicationdelegate.o
qcocoaapplicationdelegate.mm:127:28: error: cannot initialize a parameter of type 'id<NSFileManagerDelegate>' with an lvalue of type 'NSObject<NSApplicationDelegate> *'
        [NSApp setDelegate:reflectionDelegate];
                           ^~~~~~~~~~~~~~~~~~
/Applications/Xcode-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSFileManager.h:109:47: note: passing argument to parameter 'delegate' here
@property (assign) id <NSFileManagerDelegate> delegate NS_AVAILABLE(10_5, 2_0);
                                              ^
1 error generated.

Please see the full build log here: https://gist.github.com/sikachu/131b66a23010aad6b785

sikachu avatar Oct 05 '14 11:10 sikachu

Duplicate of #12622.

ariya avatar Oct 08 '14 02:10 ariya

#12622 is about PhantomJS 1 not building ob Yosemite, this one is about PhantomJS 2. Why a duplicate?

mgol avatar Oct 08 '14 07:10 mgol

@ariya I'm installing using --HEAD flag, which I assume is pulling from master. Is master branch PhantomJS 2? If so, this issue would be unrelated to #12622.

sikachu avatar Oct 08 '14 07:10 sikachu

@mzgol @sikachu Good catch! Thanks for the notice. Reopening since this is for PhantomJS 2.

ariya avatar Oct 08 '14 13:10 ariya

I got past the problem by replacing the affected file (src/qt/qtbase/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm) with this one:

https://qt.gitorious.org/qt/qtbase/source/d0a6fcd925dc2a1553e2086e85f59ba76db85bef:src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm

It looks like that's part of Qt 5.3.2.

bprodoehl avatar Oct 15 '14 13:10 bprodoehl

Haven't tried this yet, but might work – http://blog.antas.cz/phantomjs-os-x-yosemite. The idea is to just download & use a pre-compiled phantomjs binary. homebrew recipe, to contrast, is building phantomjs from source.

gmile avatar Oct 17 '14 15:10 gmile

Yeah, if you just want to try a snapshot of PhantomJS 2 on Yosemite, that works. I have binaries here: https://github.com/bprodoehl/phantomjs/releases

That macosx binary was built on Mavericks, but ran for me on Yosemite.

I think moving from Qt 5.3.0 to Qt 5.3.2 will fix the build on Yosemite, though. At least, it did for me.

bprodoehl avatar Oct 17 '14 15:10 bprodoehl

Updating qcocoaapplicationdelegate.mm solved my problem. Thanks @bprodoehl

Audio avatar Nov 03 '14 22:11 Audio

hello, I tried the replacement of that file but didn't work for me, I have more errors now

antonioreyna avatar Nov 23 '14 22:11 antonioreyna

@antonioreyna What errors are you seeing?

bprodoehl avatar Nov 24 '14 01:11 bprodoehl

let me check.

While i show you the osx output i am having also problems with centos, im getting this:

standard input}: Assembler messages:
{standard input}:12160: Warning: end of file not at end of a line; newline inserted
{standard input}:12886: Error: bad register name `%'
{standard input}:12886: Error: open CFI at the end of file; missing .cfi_endproc directive
g++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [.obj/bytecompiler/NodesCodegen.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/www/vhosts/kaandev.com/api.transpais/vendor/danielboendergaard/phantom-pdf/bin/phantomjs/src/qt/qtwebkit/Source/JavaScriptCore'
make[1]: *** [sub-Target-pri-make_first-ordered] Error 2
make[1]: Leaving directory `/var/www/vhosts/kaandev.com/api.transpais/vendor/danielboendergaard/phantom-pdf/bin/phantomjs/src/qt/qtwebkit/Source/JavaScriptCore'
make: *** [sub-Source-JavaScriptCore-JavaScriptCore-pro-make_first-ordered] Error 2

antonioreyna avatar Nov 24 '14 02:11 antonioreyna

OSX output

icu.cpp:42:10: fatal error: 'unicode/utypes.h' file not found
#include <unicode/utypes.h>
         ^
1 error generated.
make: *** [icu.o] Error 1

another

xlib.cpp:42:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^
1 error generated.
make: *** [xlib.o] Error 1
clock-gettime.cpp:51:4: error: "Feature _POSIX_TIMERS not available"
#  error "Feature _POSIX_TIMERS not available"
   ^
clock-gettime.cpp:53:5: error: use of undeclared identifier 'force_compiler_error'
    force_compiler_error = true;
    ^
2 errors generated.

....

posix_fallocate.cpp:46:14: error: no member named 'posix_fallocate' in the global namespace
    return ::posix_fallocate(0, 0, 0);
           ~~^
1 error generated.
make: *** [posix_fallocate.o] Error 1
posix_fallocate disabled.
mremap auto-detection... ()
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -DQT_NO_GRAPHICSVIEW -DQT_NO_GRAPHICSEFFECT -DQT_NO_STYLESHEET -DQT_NO_STYLE_CDE -DQT_NO_STYLE_CLEANLOOKS -DQT_NO_STYLE_MOTIF -DQT_NO_STYLE_PLASTIQUE -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE  -I../../../mkspecs/macx-clang -I. -I/usr/local/include -o mremap.o mremap.cpp
mremap.cpp:47:14: error: no member named 'mremap' in the global namespace
    (void) ::mremap(static_cast<void *>(0), size_t(0), size_t(42), MREMAP_MAYMOVE);
           ~~^
mremap.cpp:47:68: error: use of undeclared identifier 'MREMAP_MAYMOVE'
    (void) ::mremap(static_cast<void *>(0), size_t(0), size_t(42), MREMAP_MAYMOVE);
                                                                   ^
2 errors generated.
make: *** [mremap.o] Error 1

and more :(

antonioreyna avatar Nov 24 '14 02:11 antonioreyna

Hi all, will be a solution?

rdpanek avatar Nov 27 '14 20:11 rdpanek

Please fix this. We really want to use phantomjs2 on Mac OSX.

Thank you!

tillvollmer avatar Dec 21 '14 09:12 tillvollmer

I'm also having this issue. Unfortunately, replacing (src/qt/qtbase/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm) with: https://qt.gitorious.org/qt/qtbase/source/d0a6fcd925dc2a1553e2086e85f59ba76db85bef:src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm did not work for me.

After switching it out, I'm now seeing these errors:

In file included from Modules/geolocation/Coordinates.cpp:27:
Modules/geolocation/Coordinates.h:36:12: error: unknown type name 'PassRefPtr'
    static PassRefPtr<Coordinates> create(double latitude, double longitude, bool provi...
           ^
Modules/geolocation/Coordinates.h:36:22: error: expected member name or ';' after declaration
      specifiers
    static PassRefPtr<Coordinates> create(double latitude, double longitude, bool provi...
    ~~~~~~~~~~~~~~~~~^
Modules/geolocation/Coordinates.cpp:31:21: error: out-of-line definition of 'altitude' does not
      match any declaration in 'WebCore::Coordinates'
double Coordinates::altitude(bool& isNull) const
                    ^~~~~~~~
3 errors generated.
make[2]: *** [.obj/Modules/geolocation/Coordinates.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [sub-Target-pri-make_first-ordered] Error 2

BananaNeil avatar Dec 25 '14 00:12 BananaNeil

I managed to get phantomjs 2.0.0 to build on Yosemite 10.10.1 by editing src/qt/qtbase/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm

- (void)dealloc
{
    sharedCocoaApplicationDelegate = nil;
    [dockMenu release];
    [qtMenuLoader release];
    if (reflectionDelegate) {
        [NSApp setDelegate:reflectionDelegate]; // replace this line with [[NSApplication sharedApplication] setDelegate:reflectionDelegate];
        [reflectionDelegate release];
    }
    [[NSNotificationCenter defaultCenter] removeObserver:self];

    [super dealloc];
}

taken from https://github.com/Homebrew/homebrew/issues/29837

tetratorus avatar Jan 09 '15 14:01 tetratorus

@lentan1029 Good Job, your solution is functional.

rdpanek avatar Jan 09 '15 14:01 rdpanek

Got the same errors on Yosemite 10.10.1 and worked through the wiki checks and @lentan1029's solution.

What's the final output when building supposed to be? Getting this at the end, and it's still reporting 1.9.8 with phantom.version.


-L/Users/username/Repos/phantomjs/src/qt/qtbase/plugins/bearer -lqcorewlanbearer -framework CoreWLAN -lqgenericbearer -lQt5Network -lssl -lcrypto -L/Users/username/Repos/phantomjs/src/qt/qtbase/plugins/platforms -lqphantom -lQt5PlatformSupport -framework OpenGL -L/Users/username/Repos/phantomjs/src/qt/qtbase/plugins/imageformats -lqico -lQt5Gui -lqtharfbuzzng -lQt5Core -lz -lm

Aetherpoint avatar Jan 10 '15 15:01 Aetherpoint

When will be this fix merged to 2.0 branch? Thanks

rdpanek avatar Jan 27 '15 18:01 rdpanek

Thanks @lentan1029 for the pointer in the right direction. I applied your patch and compiled OSX/ubuntu/centos binaries for myself and others at https://github.com/eugene1g/phantomjs/releases

eugene1g avatar Feb 01 '15 13:02 eugene1g