I am trying to use NDK to link a C project to Android Studio. I get the following Cmake error. I get the same error with any project that uses NDK.
Determining if the C compiler works failed with the following output:
Change Dir: C:/Users/Alex/Desktop/android-ndk/audio-echo/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe" "cmTC_52340"
[1/2] Building C object CMakeFiles/cmTC_52340.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_52340
FAILED: cmd.exe /C "cd . && C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi --gcc-toolchain=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot -isystem C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -Wl,--exclude-libs,libgcc.a --sysroot C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/platforms/android-21/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -LC:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc -pie -fPIE CMakeFiles/cmTC_52340.dir/testCCompiler.c.o -o cmTC_52340 -lm && cd ."
The system cannot find the path specified.
ninja: build stopped: subcommand failed.
I am using Windows 10 and Android Studio 2.3.3.
I can successfully run the same program on another Windows 10 machine.
I would love to understand at least what part of this is failing. Any input is appreciated!
The error "The system cannot find the path specified." is issued by cmd.exe (that is, the Windows 10 command interpreter). CMake is invoking cmd.exe and asking it to run C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe, but cmd.exe cannot find it, presumably because it doesn't exist. This suggests that NDK may not be installed properly, or at all. Use Windows Explorer or cmd to look for the existence of this file; if it doesn't exist, your tools aren't installed properly. See where things went awry; for example, if C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin exists and has other files in it, perhaps something got corrupt. If you can't even find ndk-bundle, NDK is probably not installed at all.
If the file exists, try executing it; go into cmd and run C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe directly. If it works, there is something wrong with your CMake environment (not sure what), but I'm guessing it won't work.
Related
I made a fresh project and have been stuck in this specific issue for hours. I am using a shell script (.bat) file to compile and build the project. If I use no libraries, it compiles and runs fine. However, when I try to add SDL2 I get the issues described in the title. I was using Visual Studio Code, set up everything correctly in tasks.json and the issue persisted. I moved to 4code and the issue remains.
This is my build.bat
#echo off
if not exist build mkdir build
pushd build
gcc ..\source\main.c -o main.exe
gcc -L ..\external\SDL2\include
popd
I added the library in the "external" folder. It tells me it can't find the SDL.h file. I am confused because the file is in ..\external\SDL2\include
I never coded in C, so all this compiler business is new to me. I've searched the web for hours and can't find a solution. I'd appreciate any help.
Directory-adding options must be used with compilation command.
gcc ..\source\main.c -o main.exe is a compilation command without directory adding
and gcc -lSDL2 and gcc -L ..\external\SDL2\include are not compilation commands
because they don't include what to compile.
The 3 gcc invokations should be one invokation:
gcc -L ..\external\SDL2\include ..\source\main.c -o main.exe -lSDL2
I'm following the steps of the online book: "Learn C The Hard Way", and since I'm using Windows 7, I've installed Cygwin to use the Linux commands. But I'm facing a problem just on the first exercise of the book. I'm supposed to put the following command on the shell:
$ make ex1
After creating a ex1.c file on the folder. The command should give me:
cc ex1.c -o ex1
But instead, I'm getting the following message:
$ make ex1
cc ex1.c -o ex1
process_begin: CreateProcess(NULL, cc ex1.c -o ex1, ...) failed.
make (e=2): The system cannot find the specified file.
make: *** [ex1] Error 2
What's wrong?
First of all you should know that you should be running the command in the same directory where the file is. In cygwin, first you will have to locate to the folder in which the file is present, then you can run these make commands. Better since you are using Windows. You should better use any other windows based client for C. But if I were at your place. I would have installed a virtual Linux environment on my local windows computer and would have worked on that. You should try that once. Linux Terminal gives a lot of power to the developer. There are a lot of things which you can do on a terminal which is not supported by cygwin. For compiling C programs on Cygwin, I believe you should check if it supports compiler commands or not. :)
Make is reporting that it can not find cc.
cc is a link to gcc, and it belongs to gcc-core.
$ cygcheck -f /usr/bin/cc
gcc-core-5.4.0-1
To verify if the package is correctly installed
$ cygcheck -c gcc-core
Cygwin Package Information
Package Version Status
gcc-core 5.4.0-1 OK
If, as likely, the package is missing, you need to install it with the cygwin setup.
I'm trying to use liboauth with a C program, using gcc as my compiler, and no matter what I've tried I keep getting the error "ld: library not found for -loauth" and "clang: error: linker command failed with exit code 1".
I'm including the header via "#include <oauth.h>", and my most-recent call to gcc looked like this:
gcc -Wall -lcurl -loauth -I /usr/local/include -v -o api api.c
Now, oauth.h does exist in /usr/local/include, and there are a handful of liboauth files (including liboauth.a) located in /usr/local/bin, which I'm assuming were placed there when I ran the install. I will admit that I'm not very familiar with gcc and compiling non-trivial C programs, but I was able to get libcurl working on a fresh download in just a few minutes. I just can't figure out what's going on with liboauth.
Thanks in advance
If you are sure liboauth's located in /usr/local/bin use
gcc -Wall -L/usr/local/bin -I /usr/local/include -v -o api api.c -lcurl -loauth
It'd also be better to place libraries in the end of the command as there is some important stuff with them (they may depend on each other, etc).
By the way, it's pretty strange your libraries are in /usr/local/bin as libraries are almost always stored in some path like /usr/*/lib.
I'm currently trying to install libsndfile on my mac running os x 10.9.1. However, when after running the command 'make' it runs for a while and then displays the following message: sndfile-play.c:61:11: fatal error: 'Carbon.h' file not found. I haven't had much luck finding people with a similar issue. From what I found it looks like it may have to do with newer os versions not being supported. Anyone know how to resolve this issue? Thanks in advance!
The following worked for me (I am running OS X 10.9.1):
Download the source code
Untar the bundle
$ ./configure
$ make
A problem should occur with Carbon.h (sndfile-play.c:61:21:
error: Carbon.h: No such file or directory)
Search Carbon.h in your machine using: $ find /Applications/Xcode.app/Contents/Developer/ | grep Carbon.h
Edit **programs/**Makefile
Look for CFLAGS, ensure CFLAGS is configured:
CFLAGS =
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/ -g -O2 -std=gnu99 -Wall -Wextra -Wdeclaration-after-statement -Wpointer-arith -funsigned-char -Wstrict-prototypes -Wmissing-prototypes -Wcast-align -Wcast-qual -Wnested-externs -Wbad-function-cast -Wwrite-strings -Wundef -pipe -I/Developer/Headers/FlatCarbon
$ make
$ make check (All test should pass), then:
$ sudo make install
Source: http://comunidad.udistrital.edu.co/ocala/2013/06/09/building-libsndfile-on-mac-os-x/
I suggest you use brew to install it : http://brew.sh/
Once installed simply run brew install libsndfile
Also just removing that #include works fine.
To solve in a general way (i.e. without resorting to hacking the Makefile), do an "export CPPFLAGS='-I/" with the path to your Xcode's header directory containing Carbon.h before running ./configure. Here are the steps, all from a Terminal window:
Look for instances of Carbon.h on your system:
find /Applications/Xcode.app/Contents/Developer/ | grep Carbon.h
Output:
/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/Developer/Headers/FlatCarbon/Carbon.h
/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/Carbon.h
/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/Carbon.h
Using the first line (because it appears to be the most generic header directory), copy the path without including Carbon.h at the end:
/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/
Finally, paste that contents within the export line (being sure to include the apostrophes at both ends of the path) like this:
export CPPFLAGS='-I/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/'
Now re-run your ./configure and make lines to compile.
I had success with this method (using Mac OSX 10.9.2):
1) Select the Terminal application.
2) Make sure I'm in the bash shell (method fails in csh or tcsh).
3) In response to bash$ type
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
****** note: this brings brew in from the web. you'll have to give your
sysadmin password*****.
4) In response to bash$ type
"brew install libsndfile"
****** note: this brings sndfile.h and various other libsndfile files in from
the web and installs them in subdirectories of /usr/local . Again, you'll
have to give your sysadmin password*****.
I am trying to install the driver for a serial device, and when I run the installation executable I get this error:
cc -DLINUX -c -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -m64 -mcmodel=kernel -I/usr/src/linux-3.8.0-27-generic/include -I/usr/src/linux-2.4/include -I/usr/src/linux/include -D__SMP__ npreal2.c
npreal2.c:40:31: **fatal error: linux/modversions.h: No such file or directory**
compilation terminated.
I don't find any solutions to this after searching the forums. I noticed that there is a modversions.h in the /usr/src/linux-3.8.0-27-generic/include/config , but not in the linux folder.
Please help!
Try passing -I /usr/src/linux-3.8.0-27-generic/include/config as an argument to make?
or
Check if the header is a part of a certain package and update the package.
You can compile modversions on your system by navigating to the linux directory (usually usr/src/linux). Inside the linux source directory, there should be a file called Rules.make. Inside this make file are build commands for making modversions.h. You can make it by running:
make update-modverfile
Now, while this will make the modversions.h library, if you compile it with a newer compiler than the libraries that this file relies on, many times you will get an error when trying to run a program that uses this header. This then turns into a nightmare.
Another method, I tried it successfully with Xubuntu 13.10:
Open /etc/default/grub
Add this Line and save it.
GRUB_CMDLINE_LINUX="CONFIG_MODVERSIONS=true"
reboot
(no, sudo update-grub,ok)
open a terminal window, enjoy.
locate modversions.h
(Please don't forget modversion'S')