jeffcrouse/ofxJSON

issues on Linux?

sphaero opened this issue · 11 comments

I don't know if you've tried this addon on linux but I'm having trouble getting it through the precompiler. I've traced it down to the ofxJSON addon and the precompiler but haven't found a cause yet.

I can compile jsoncpp-0.5.0 using scons.

Errors are like:
In file included from /usr/include/c++/4.6/cstdio:44:0,
from /usr/include/c++/4.6/fstream:43,
from ../../z25-lib/unstable/openFrameworks/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.h:14,
from ../../z25-lib/unstable/openFrameworks/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp:10:
/usr/include/stdio.h:940:1: error: expected declaration before ‘}’ token

I'll do some more digging but just to let you know...:

Ubuntu precise: gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

Just tried on Debian Wheezy as well. Same errors. I'm pretty sure it's some precompiler statement gcc is choking on.

gcc version 4.7.2

Just to let you know I traced the problem down to openFrameworks. It's not issue of your addon however your addon does suffer from it. See http://forum.openframeworks.cc/index.php/topic,11495.0.html

i have a similar issue in linux 64 bit, trying to test the @pelayomendez ofTwitter modification of did you solved this @sphaero ? this is the log from the console:

unning command: make -f Makefile Debug
Compiling OF library for Debug
make --no-print-directory -C ../../../libs/openFrameworksCompiled/project/ Debug PLATFORM_OS=Linux ABIS_TO_COMPILE_DEBUG=""
make[2]: "DebugABI" è aggiornato.
Done!
Compiling example_post for Debug
Compiling src/main.cpp
g++ -c -g3 -Wall -march=native -mtune=native -DOF_USING_GTK -DOF_USING_MPG123 -I./src -I../../../addons/ofxXmlSettings/src -I../../../addons/ofxXmlSettings/libs -I../../../addons/ofxJSON/src -I../../../addons/ofxJSON/libs -I../../../addons/ofxJSON/libs/jsoncpp -I../../../addons/ofxJSON/libs/jsoncpp/include -I../../../addons/ofxJSON/libs/jsoncpp/include/json -I../../../addons/ofxJSON/libs/jsoncpp/src -I../../../addons/ofxJSON/libs/jsoncpp/include -I../../../addons/ofxJSON/libs/jsoncpp/include/json -I../../../addons/ofxOAuth/src -I../../../addons/ofxOAuth/libs -I../../../addons/ofxOAuth/libs/liboauth -I../../../addons/ofxOAuth/libs/liboauth/lib -I../../../addons/ofxOAuth/libs/liboauth/lib/linux64 -I../../../addons/ofxOAuth/libs/liboauth/lib/osx -I../../../addons/ofxOAuth/libs/liboauth/include -I../../../addons/ofxOAuth/libs/liboauth/include -I../../../addons/ofxTwitter/src -pthread -D_REENTRANT -I/usr/local/include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2 -I/usr/include/alsa -I/usr/include/libdrm -I/usr/include/GL -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I../../../libs/fmodex/include -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/kiss/include -I../../../libs/openssl/include -I../../../libs/openssl/include/openssl -I../../../libs/poco/include -I../../../libs/portaudio/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/openFrameworks -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/events -MMD -MP -MF obj/linux64/Debug/src/main.d -MT obj/linux64/Debug/src/main.o -o obj/linux64/Debug/src/main.o -c src/main.cpp
In file included from /usr/include/X11/Xlib.h:38:0,
from /usr/include/GL/glx.h:30,
from ../../../libs/openFrameworks/utils/ofConstants.h:174,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/x86_64-linux-gnu/sys/types.h:158:20: error: missing binary operator before token "("
In file included from /usr/include/libio.h:62:0,
from /usr/include/stdio.h:75,
from /usr/include/c++/4.6/cstdio:44,
from ../../../libs/openFrameworks/utils/ofConstants.h:339,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:43:20: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:56:44: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:61:44: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:149:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:162:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:224:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:233:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:240:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:249:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:258:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:270:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:280:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:289:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:297:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:311:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:319:43: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:342:19: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:351:20: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:356:20: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/sys/cdefs.h:363:19: error: missing binary operator before token "("
In file included from /usr/include/math.h:34:0,
from /usr/include/c++/4.6/cmath:46,
from ../../../libs/openFrameworks/utils/ofConstants.h:341,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/huge_val.h:28:18: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/bits/huge_val.h:30:20: error: missing binary operator before token "("
In file included from /usr/include/c++/4.6/cmath:46:0,
from ../../../libs/openFrameworks/utils/ofConstants.h:341,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/math.h:404:42: error: missing binary operator before token "("
In file included from /usr/include/c++/4.6/cwchar:46:0,
from /usr/include/c++/4.6/bits/postypes.h:42,
from /usr/include/c++/4.6/bits/char_traits.h:42,
from /usr/include/c++/4.6/string:42,
from ../../../libs/openFrameworks/utils/ofConstants.h:344,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/wchar.h:75:43: error: missing binary operator before token "("
In file included from /usr/include/sched.h:43:0,
from /usr/include/pthread.h:25,
from /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:41,
from /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr.h:170,
from /usr/include/c++/4.6/ext/atomicity.h:34,
from /usr/include/c++/4.6/bits/basic_string.h:41,
from /usr/include/c++/4.6/string:54,
from ../../../libs/openFrameworks/utils/ofConstants.h:344,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/sched.h:133:20: error: missing binary operator before token "("
/usr/include/x86_64-linux-gnu/bits/sched.h:171:20: error: missing binary operator before token "("
In file included from /usr/include/c++/4.6/cstring:44:0,
from ../../../libs/openFrameworks/utils/ofConstants.h:347,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/string.h:37:42: error: missing binary operator before token "("
In file included from ../../../addons/ofxXmlSettings/libs/tinyxml.h:39:0,
from ../../../addons/ofxXmlSettings/src/ofxXmlSettings.h:8,
from ../../../addons/ofxOAuth/src/ofxOAuth.h:35,
from ../../../addons/ofxTwitter/src/ofxTwitter.h:29,
from src/testApp.h:4,
from src/main.cpp:2:
/usr/include/assert.h:39:42: error: missing binary operator before token "("
/usr/include/assert.h:108:42: error: missing binary operator before token "("
In file included from ../../../libs/poco/include/Poco/Net/SocketDefs.h:150:0,
from ../../../libs/poco/include/Poco/Net/SocketImpl.h:44,
from ../../../libs/poco/include/Poco/Net/Socket.h:44,
from ../../../libs/poco/include/Poco/Net/ServerSocket.h:44,
from ../../../libs/poco/include/Poco/Net/TCPServer.h:44,
from ../../../libs/poco/include/Poco/Net/HTTPServer.h:44,
from ../../../addons/ofxOAuth/src/ofxOAuthVerifierCallbackServer.h:34,
from ../../../addons/ofxOAuth/src/ofxOAuth.h:36,
from ../../../addons/ofxTwitter/src/ofxTwitter.h:29,
from src/testApp.h:4,
from src/main.cpp:2:
/usr/include/x86_64-linux-gnu/sys/socket.h:70:43: error: missing binary operator before token "("
In file included from ../../../libs/openFrameworks/utils/ofConstants.h:156:0,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/unistd.h:28:1: error: ‘__BEGIN_DECLS’ does not name a type
In file included from ../../../libs/openFrameworks/utils/ofConstants.h:156:0,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/unistd.h:288:54: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:335:65: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:361:62: error: expected initializer before ‘__wur’
/usr/include/unistd.h:367:66: error: expected initializer before ‘__wur’
/usr/include/unistd.h:418:36: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:433:52: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:475:6: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:498:41: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:512:50: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:532:27: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:535:39: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:553:30: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:565:6: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:570:6: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:575:6: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:580:6: error: expected initializer before ‘__THROW’
/usr/include/unistd.h:586:6: error: expected initializer before ‘__THROW’
In file included from ../../../libs/openFrameworks/utils/ofConstants.h:156:0,
from ../../../libs/openFrameworks/ofMain.h:5,
from src/main.cpp:1:
/usr/include/unistd.h:614:6: error: expected initializer before ‘__THROW’
Process terminated with status 2 (0 minutes, 3 seconds)
50 errors, 0 warnings

On linux I think it was fixed by installing the libjson library
and changing in config,make:
USER_CFLAGS = $(shell pkg-config jsoncpp --cflags)
USER_LDFLAGS = $(shell pkg-config jsoncpp --libs)

Ow and removing the source for jsoncpp from the addon or making sure it's not included during compile

This solve the issue! installing

libjsoncpp0 and libjsoncpp0-dev

and adding

PROJECT_CFLAGS = $(shell pkg-config jsoncpp --cflags)
PROJECT_LDFLAGS=-Wl,-rpath=./libs $(shell pkg-config jsoncpp --libs)

and removing isoncpp headers and source from the addon did the magic thing!

Many thanks @sphaero !
May we close this issue?

I don't know. I still don't know what's causing it. I'm now getting:

openFrameworks/addons/ofxJSON/libs/jsoncpp/src/jsoncpp.cpp:191:29: fatal error: json/assertions.h: No such file or directory
 #include <json/assertions.h>
                             ^
compilation terminated.

It seems this is because of these 'amalgated' sources??? Committed Aug 5.

Again removing the libs dir resolves it.

Hi @sphaero have you updated to the latest version of ofxJSON? We don't use the installed system version of jsoncpp but compile from source.

Here it references a file which is not in the repo:
https://github.com/jefftimesten/ofxJSON/blob/master/libs/jsoncpp/src/jsoncpp.cpp#L191

or the define is missing

Strange -- it should be defined here:

https://github.com/jefftimesten/ofxJSON/blob/master/libs/jsoncpp/include/json/json.h#L79

I just recently updated ofxJSON to use the amalgamated headers and tested it on several flavors of ubuntu and raspberry pi, udoo, and it seemed to work -- what version / distro of linux are you running?

Ah yes then I understand what is going on. It's caused by double inclusion of the workaround. The amalgamated headers are the solution to what caused this issue in the first place. We should quickly close this issue and forget it ever existed.

So to anybody out there, don't use the workaround anymore mentioned in this thread. It should work out of the box now.