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

MacOS 11.15: error: invalid argument '-std=c++11' not allowed with 'C' #69

Open
beyarkay opened this issue Aug 7, 2021 · 3 comments
Open

Comments

@beyarkay
Copy link

beyarkay commented Aug 7, 2021

Nice.

After following the instructions on the docs for compiling from source (I'm looking to contribute) on MacOS, everything was good until the compilation step where I was asked to run:

cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" ../src/
make -j3

cmake runs fine, but make -j3 gives the following error:

$ make -j3
Consolidate compiler generated dependencies of target robogen
[  1%] Building CXX object CMakeFiles/robogen.dir/arduino/ArduinoNNCompiler.cpp.o
clang: warning: -O4 is equivalent to -O3 [-Wdeprecated]
[  1%] Building C object CMakeFiles/robogen.dir/brain/NeuralNetwork.c.o
error: invalid argument '-std=c++11' not allowed with 'C'
make[2]: *** [CMakeFiles/robogen.dir/brain/NeuralNetwork.c.o] Error 1
make[1]: *** [CMakeFiles/robogen.dir/all] Error 2
make: *** [all] Error 2

I'm not sure where the argument (-std=c++11) was passed in nor how to solve this issue, although I think it's similar to these:

Thanks for any help you can provide!

@beyarkay
Copy link
Author

beyarkay commented Aug 7, 2021

Slight Update number 2

I reverted the below changes and instead specified that cmake should use gcc and not clang like so:

New command:

cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -DCMAKE_C_COMPILER=/usr/local/bin/gcc-11 -DMAKE_CXX_COMPILER=/usr/local/bin/g++-11 ../src

Old Command:

cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" ../src/

This has removed the old error, although I'm still getting the following (after running make -j3 twice):

Consolidate compiler generated dependencies of target robogen
[ 94%] Built target robogen
Consolidate compiler generated dependencies of target robogen-file-viewer
Consolidate compiler generated dependencies of target robogen-evolver
Consolidate compiler generated dependencies of target robogen-server
make[2]: *** No rule to make target `/usr/local/lib/libode.a', needed by `robogen-server'.  Stop.
make[1]: *** [CMakeFiles/robogen-server.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** No rule to make target `/usr/local/lib/libode.a', needed by `robogen-evolver'.  Stop.
make[1]: *** [CMakeFiles/robogen-evolver.dir/all] Error 2
make[2]: *** No rule to make target `/usr/local/lib/libode.a', needed by `robogen-file-viewer'.  Stop.
make[1]: *** [CMakeFiles/robogen-file-viewer.dir/all] Error 2
make: *** [all] Error 2

Slight update (now out of date)

I changed line 10 in robogen/build/CMakeFiles/robogen.dir/flags.make to remove the bit saying -std=c++11 and it seems to have worked (although I now have a new, different error)

New version (note the lack of -std=c++11 at the end):

C_FLAGS =  -march=core2 -msse2 -msse3 -mssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -mno-avx -mno-xop -mno-fma4 -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk    -pedantic -fPIC

Old version (note the inclusion of -std=c++11 at the end):

C_FLAGS =  -march=core2 -msse2 -msse3 -mssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -    mno-avx -mno-xop -mno-fma4 -O3 -DNDEBUG -isysroot /Library/Developer/                   CommandLineTools/SDKs/MacOSX11.3.sdk   -std=c++11 -pedantic -fPIC

I will close this once I've built successfully.

@beyarkay
Copy link
Author

beyarkay commented Aug 9, 2021

Due to the issues it seemed to be having with ODE, I did:
brew uninstall ode
and then reinstalled it from the source (https://bitbucket.org/odedevs/ode/downloads/) using the following commands:

cd ode-0.16.2
./configure --enable-double-precision --with-cylinder-cylinder=libccd
sudo make install -j

After this, the file /usr/local/lib/libode.a existed which seemed to be what was causing the previous error. Going back to the robogen directory, I built robogen again:

cd ../robogen/build
cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" ../src/
make -j3

And once again I had some issues:

[ 94%] Built target robogen
[ 95%] Linking CXX executable robogen-file-viewer
ld: library not found for -licudata
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [robogen-file-viewer] Error 1
make[1]: *** [CMakeFiles/robogen-file-viewer.dir/all] Error 2
make: *** [all] Error 2

At this point it seems to get past where it was having trouble last time, although still not building properly. I've got no clue what licudata is, although it seems to be causing the issues.

@beyarkay
Copy link
Author

So I had a typo, and the parameter that was being passed to cmake to force it to use gcc instead of clang wasn't working. This is the command I'm currently using to do cmake:

cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -DCMAKE_C_COMPILER=/usr/local/bin/gcc-11 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-11 ../src

Which doesn't work, but at least now I know I'm using gcc and not clang.

With regards to the -licudata flag, I think that it's referring to this Unicode library which I have installed via brew which lists it as icu4c:

$ brew info icu4c
icu4c: stable 69.1 (bottled) [keg-only]
C/C++ and Java libraries for Unicode and globalization
http://site.icu-project.org/home
/usr/local/Cellar/icu4c/69.1 (259 files, 72.8MB)
  Poured from bottle on 2021-08-07 at 13:45:39
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/icu4c.rb
...

This github comment recommends I add some flags to the cxx compiler via this addition to 'the cmake file':

 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/usr/local/opt/icu4c/lib -I/usr/local/opt/icu4c/include")

Which resulted in a load of output that looked like an error relating to the program boost. The output ended with this:

...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [robogen-file-viewer] Error 1
make[1]: *** [CMakeFiles/robogen-file-viewer.dir/all] Error 2
make: *** [all] Error 2

I'm not sure what to do about this error.

The brew info icu4c gave some recommendations for icu4c:

...
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH, run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

which I also tried setting (just the LDFLAGS, CPPFLAGS, and PATH changes) but that resulted in the same massive error message, also ending with complaints about x86_64:

...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [robogen-file-viewer] Error 1
make[1]: *** [CMakeFiles/robogen-file-viewer.dir/all] Error 2
make: *** [all] Error 2

I'm not sure what to do now.

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

1 participant