chrisdew / protobuf

Protocol Buffers for Node.JS
http://code.google.com/p/protobuf-for-node/
Apache License 2.0
234 stars 71 forks source link

Compiling Errors on Mac #17

Closed trevex closed 11 years ago

trevex commented 11 years ago

Unfortunately I tried the new release, seishun's fork and chromium's protobuf gyp. I get compiling errors for all of them, so I assume it is a system specific problem (although compiling chromium works).

Anyway this is the output of npm install protobuf.

Maybe someone can help, I can't figure out what the problem is I am running MacOSX 10.7 or can tell me howto get more verbose output from gyp to atleast know how he configures the build.

Edit: On ubuntu everything works fine. I deinstalled all ports from macports completely just in case, but no change...

chrisdew commented 11 years ago

The first error is in OSX specific code in the protocol buffers library.

../protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h:139: error: invalid conversion from ‘google::protobuf::internal::Atomic64*’ to ‘volatile int64_t*’

Can you compile the protocol buffers library on your machine? http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz

trevex commented 11 years ago

Yes without any problems by just running ./configure && make

chrisdew commented 11 years ago

Unfortunately I don't have an OSX machine to debug this on.

If anyone else reading this has a Mac, could you tell me if you also see this issue (or not)? (We need to determine whether this affects all OSX machines, or just trevex's.)

trevex commented 11 years ago

I was testing it previously on my 10.7 mac but on a fresh 10.8 (mountain lion) installation it is the same, same error... If someone could tell me how to get more verbose informations out of gyp, I could compare these to the protobuf makefile configuration and adapt the gyp file.

Also I am not really experienced using gyp, but my work around is currently having compiling the 2.4.1 src of protobuf the usual way globally with make install and then using this binding.gyp:

{
    "targets": [
        {
            "target_name": "protobuf_for_node",
            "include_dirs": ["protobuf/src"],
            "sources": [
                "protobuf_for_node.cc", "addon.cc"
            ],
            'libraries': [
              '-lprotobuf'
            ],
        }
    ]
}

After hours of comparing the settings generated by configure and gyp I was not able to find the problem...

yyfrankyy commented 11 years ago

Same here.

The protobuf directory inside this repo is not the same as protobuf-2.4.1, and the trunk branch of official protobuf repo still failed to compile on my mac (10.7.5).

I recommend @chrisdew to use the stable version of protobuf-2.4.1 instead of the newest version at the trunk of protobuf.

chrisdew commented 11 years ago

Thanks for the updates, I will integrate the 2.4.1 release code in a week or two.

If anyone wants to do this sooner, test on a Mac and send me a pull request, that would be much appreciated.

yyfrankyy commented 11 years ago

There is a temporary solution from here: https://code.google.com/p/protobuf/issues/detail?id=407

diff --git a/protobuf/src/google/protobuf/stubs/atomicops.h b/protobuf/src/google/protobuf/stubs/atomicops.h
index 1315682..8eb0d85 100644
--- a/protobuf/src/google/protobuf/stubs/atomicops.h
+++ b/protobuf/src/google/protobuf/stubs/atomicops.h
@@ -71,7 +71,7 @@ typedef int32 Atomic32;
 // http://code.google.com/p/nativeclient/issues/detail?id=1162
 typedef int64 Atomic64;
 #else
-typedef intptr_t Atomic64;
+typedef int64 Atomic64;
 #endif
 #endif

With this patch, I'm be able to build and require protobuf with node-gyp successfully.

$ node -e 'console.log(require("protobuf"))'
{ Schema: [Function: Schema] }