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 error: 'for' loop initial declarations are only allowed in C99 or C11 mode #588

Closed
1 task done
ghost opened this issue Jul 5, 2017 · 4 comments
Closed
1 task done

Comments

@ghost
Copy link

ghost commented Jul 5, 2017

Report

Issues and Steps to Reproduce

Building yoga-layout fails when using a Node Docker container, with an error message use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code from error: 'for' loop initial declarations are only allowed in C99 or C11 mode.

Steps to Reproduce:

  1. Install Docker
  2. Download node image: docker pull node
  3. Run interactive container: docker run -it node sh
  4. Try installing yoga-layout in an interactive session: yarn add yoga-layout

This issue should also be present with a standard Debian install, as this is what the Node Docker container is using.

Environment details:

# uname -a
Linux 7726868914e5 4.9.31-moby #1  x86_64 GNU/Linux

# yarn -v
yarn install v0.24.6

# node -v
v8.1.2

Expected Behavior

Describe what you expected would happen.
Should install yoga-layout without errors.

Actual Behavior

Describe what actually happened.

Fails to install.

Full error log is here:

# yarn add yoga-layout
yarn add v0.24.6
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/1] ⠈ yoga-layout: /root/.npm/_logs/2017-07-05T05_25_45_061Z-debug.log
[-/1] ⠈ waiting...
[-/1] ⠈ waiting...
[-/1] ⠈ waiting...
error /node_modules/yoga-layout: Command failed.
Exit code: 1
Command: sh
Arguments: -c npm -- run autogypi && npm -- run build:node
Directory: /node_modules/yoga-layout
Output:
npm info it worked if it ends with ok
npm info using npm@5.0.3
npm info using node@v8.1.2
npm info lifecycle yoga-layout@1.5.0~preautogypi: yoga-layout@1.5.0
npm info lifecycle yoga-layout@1.5.0~autogypi: yoga-layout@1.5.0

> yoga-layout@1.5.0 autogypi /node_modules/yoga-layout
> autogypi

npm info lifecycle yoga-layout@1.5.0~postautogypi: yoga-layout@1.5.0
npm info ok 
npm info it worked if it ends with ok
npm info using npm@5.0.3
npm info using node@v8.1.2
npm info lifecycle yoga-layout@1.5.0~prebuild:node: yoga-layout@1.5.0
npm info lifecycle yoga-layout@1.5.0~build:node: yoga-layout@1.5.0

> yoga-layout@1.5.0 build:node /node_modules/yoga-layout
> npm -- run copy-sources && npm -- run node-gyp configure build

npm info it worked if it ends with ok
npm info using npm@5.0.3
npm info using node@v8.1.2
npm info lifecycle yoga-layout@1.5.0~precopy-sources: yoga-layout@1.5.0
npm info lifecycle yoga-layout@1.5.0~copy-sources: yoga-layout@1.5.0

> yoga-layout@1.5.0 copy-sources /node_modules/yoga-layout
> ! npm -s -- run is-monolithic || (rsync -r --checksum --delete ../yoga/ sources/yoga/)

npm info lifecycle yoga-layout@1.5.0~postcopy-sources: yoga-layout@1.5.0
npm info ok 
npm info it worked if it ends with ok
npm info using npm@5.0.3
npm info using node@v8.1.2
npm info lifecycle yoga-layout@1.5.0~prenode-gyp: yoga-layout@1.5.0
npm info lifecycle yoga-layout@1.5.0~node-gyp: yoga-layout@1.5.0

> yoga-layout@1.5.0 node-gyp /node_modules/yoga-layout
> node-gyp "configure" "build"

gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.1.2 | linux | x64
gyp http GET https://nodejs.org/download/release/v8.1.2/node-v8.1.2-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v8.1.2/node-v8.1.2-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v8.1.2/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v8.1.2/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/node_modules/yoga-layout/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/8.1.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/8.1.2',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.node-gyp/8.1.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/node_modules/yoga-layout',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/node_modules/yoga-layout/build'
  COPY Release/obj.target/nbind/geni/symbols.txt
  CC(target) Release/obj.target/nbind/sources/yoga/YGNodeList.o
../sources/yoga/YGNodeList.c: In function 'YGNodeListInsert':
../sources/yoga/YGNodeList.c:67:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (uint32_t i = list->count; i > index; i--) {
   ^
../sources/yoga/YGNodeList.c:67:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
../sources/yoga/YGNodeList.c: In function 'YGNodeListRemove':
../sources/yoga/YGNodeList.c:79:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (uint32_t i = index; i < list->count - 1; i++) {
   ^
../sources/yoga/YGNodeList.c: In function 'YGNodeListDelete':
../sources/yoga/YGNodeList.c:89:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (uint32_t i = 0; i < list->count; i++) {
   ^
nbind.target.mk:134: recipe for target 'Release/obj.target/nbind/sources/yoga/YGNodeList.o' failed
make: Leaving directory '/node_modules/yoga-layout/build'
make: *** [Release/obj.target/nbind/sources/yoga/YGNodeList.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 4.9.31-moby
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /node_modules/yoga-layout
gyp ERR! node -v v8.1.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm info lifecycle yoga-layout@1.5.0~node-gyp: Failed to exec node-gyp script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yoga-layout@1.5.0 node-gyp: `node-gyp "configure" "build"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the yoga-layout@1.5.0 node-gyp script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-07-05T05_25_45_061Z-debug.log
npm info lifecycle yoga-layout@1.5.0~build:node: Failed to exec build:node script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yoga-layout@1.5.0 build:node: `npm -- run copy-sources && npm -- run node-gyp configure build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the yoga-layout@1.5.0 build:node script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-07-05T05_25_45_100Z-debug.log
@theobat
Copy link

theobat commented Jul 6, 2017

I had the same problem, you can either:

  • upgrade g++ version (greater >4.8)
  • modify this repo: here adding a line '-std=c99' and here switch to c++1y

Tthe first solution is what I used (I was on heroku cedar14).

@weaintplastic
Copy link

@theobat thanks so much for the hint.

I was running into the same issues with the docker node:8 container which already provides g++ version 4.9. So instead I've updated g++ and gcc to version 5 using a custom docker container. Here's the content of my Dockerfile which made installing yoga-layout smooth as butter.

# Use official node runtime as parent image
FROM node:8

# Install gcc-5 in order to support yoga-layout
RUN echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/unstable.list &&\
    apt-get update &&\
    apt-get install --assume-yes -t unstable gcc-5 g++-5 &&\
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 &&\
    cc --version

@audiolion
Copy link

tried @weaintplastic 's suggestion on Ubuntu 16.04 but no dice

@NickGerleman
Copy link
Contributor

It looks like this issue is stale. Please reopen if you see the same behavior on the latest version of Yoga.

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

No branches or pull requests

4 participants