Fatal Error Installing libsndfile on OS X Mavericks - c

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*****.

Related

Compile an SDL project using gcc?

How can I compile a sdl project using gcc in the linux command line without using Cmake?
EDIT;
gcc SDLGAME.c pkg-config --cflags --libs sdl2
but i get error.
gcc: error: Pkg-config: No such file or directory
gcc: error: sdl2: No such file or directory
gcc: error: unrecognized command line option ‘--cflags’
gcc: error: unrecognized command line option ‘--libs’; did you mean ‘--libs=’?
#HolyBlackCat
source code --->>
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc,char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) !=0)
{
printf("error SDL");
return 0;
}
SDL_Window* win=SDL_CreateWindow("Game",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
500,500,0);
return 0;
}
I get this error--->>
error: XDG_RUNTIME_DIR not set in the environment.
error SDL
Caveat: This isn't a total solution but some suggestions and is prefaced by top comment's and comments under OP's [now deleted] answer.
To review ...
After fixing the original issue by use of:
gcc -o SDLGAME SDLGAME.c `pkg-config --cflags --libs sdl2`
OP running the program produces:
error: XDG_RUNTIME_DIR not set in the environment.
This may be a general issue about the ubuntu install itself. Some resources for that: https://askubuntu.com/questions/872792/what-is-xdg-runtime-dir and
https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut
A workaround may be:
export XDG_RUNTIME_DIR=/tmp/dir
mkdir -p /tmp/dir
But, I ran the program successfully on my home system, running fedora 29 and my ubuntu system running 18.04.5
On my systems, XDG_RUNTIME_DIR was set to /run/user/1000. However, with/without the workaround and even doing unset XDG_RUNTIME_DIR worked on my systems.
However: On my ubuntu system, I had removed the standard libsdl2 package and rebuilt and installed it from the source package a year ago due to some issues I had.
So, if the workaround doesn't work, I recommend libsdl2 rebuild/reinstall from source.
Even if the standard package is working, when debugging your app, it can be helpful to be able to consult the libsdl2 source.
Note that one change I made to your app was to add a sleep(3) at the bottom so you can see the window come up.
Here is the method I used to build/install from source:
It's probably necessary to uninstall/remove the binary libsdl2 package. So, you'll have to do (e.g.)
sudo apt-get remove libsdl2 libsdl2-dev
Or, whatever the binary package is called [I forget]. But, those also came from: apt-cache search libsdl2
So, once that's cleaned out, what I did was:
Create a directory (e.g.): $HOME/aptsrc
cd $HOME/aptsrc
Download the source package [without sudo]: apt-get source libsdl2
This extracts several files (e.g. *.tar.gz, *.tar.xz, *.dsc and a directory. On my system, it was: libsdl2-2.0.8+dfsg1, but for you it may be different. Do (e.g.): DIR=$HOME/aptsrc/libsdl2-2.0.8+dfsg1
cd $DIR
Configure with: $DIR/configure
Run cmake: cmake $DIR
Run make with: make
Install with: sudo make install
Note that this comes from an internal script I created. Even after the cd $DIR, I think it's necessary to use full path on the commands [where indicated].
Now, the library should be installed under /usr/local. The output of pkg-config --cflags --libs sdl2 should reflect this:
-D_REENTRANT -I/usr/local/include/SDL2 -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL2
The original output of this command would have looked like:
-I/usr/include/SDL2 -D_REENTRANT -lSDL2
This is for the standard install from the binary package, so if you still have that, the binary package may still be installed.
Otherwise, you should now be able to rebuild your app using the original gcc command. Now, it should be attached to the source built version of the library. You can confirm this with: ldd ./SDLGAME but just running it might be easier.

Fatal error when building sqlcipher3 from macOS ('sqlcipher/sqlite3.h' file not found)

I have been trying to build sqlcipher3 on MacOS with the following command:
git clone https://github.com/coleifer/sqlcipher3 && cd sqlcipher3
python3 setup.py build
I am getting the following error:
$ python3 setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
creating build/lib.macosx-10.14-x86_64-3.7/sqlcipher3
copying sqlcipher3/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/sqlcipher3
copying sqlcipher3/dbapi2.py -> build/lib.macosx-10.14-x86_64-3.7/sqlcipher3
running build_ext
Builds a C extension linking against libsqlcipher library
building 'sqlcipher3._sqlite3' extension
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/src
xcrun -sdk macosx clang -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Qunused-arguments -DMODULE_NAME="sqlcipher3.dbapi2" -I/usr/include -I/Users/gab/Downloads/testbuild/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/include/python3.7m -c src/module.c -o build/temp.macosx-10.14-x86_64-3.7/src/module.o
In file included from src/module.c:24:
src/connection.h:34:10: fatal error: 'sqlcipher/sqlite3.h' file not found
#include "sqlcipher/sqlite3.h"
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'xcrun' failed with exit status 1
But sqlcypher is correctly installed with brew:
$ brew install sqlcipher
Warning: sqlcipher 4.4.2 is already installed and up-to-date
To reinstall 4.4.2, run `brew reinstall sqlcipher`
And sqlite3.h was added in the process:
$ find /usr/local/Cellar -name sqlite3.h
/usr/local/Cellar/sqlite/3.33.0/include/sqlite3.h
/usr/local/Cellar/sqlite/3.34.0/include/sqlite3.h
/usr/local/Cellar/sqlcipher/4.4.2/include/sqlcipher/sqlite3.h
Is there something I am missing? Should I be adding a path flag when running python3 setup.py build?
I would
C_INCLUDE_PATH=/usr/local/Cellar/sqlcipher/4.4.2/include LIBRARY_PATH=/usr/local/Cellar/sqlcipher/4.4.2/lib python3 setup.py build
give a try.
I'm not too sure about the cause of the problem,
but have you considered manualy downloading it from github and setting it near the code that uses that?
I know it's probably not the solution you were searching for but it might be all it takes...
I think you’re more likely to find an answer to this on the SQLCipher discussion board.

Determining if the C compiler works failed with the following output

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\toolchain‌​s\llvm\prebuilt\wind‌​ows-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\toolchain‌​s\llvm\prebuilt\wind‌​ows-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\toolchain‌​s\llvm\prebuilt\wind‌​ows-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.

Compiling Apache Lucy

I am trying to compile Apache Lucy. Here are the steps I followed:
Downloaded Lucy and Clownfish
Compiled Clownfish runtime and compiler
Configured Lucy
Started Lucy Make
The compilation of the files in the core directory works fine but when it gets to the modules it throws an error:
$ make
gcc -pedantic -Wall -Wextra -Wno-variadic-macros -std=gnu99 -D_GNU_SOURCE -D CFP_LUCY -D CFP_TESTLUCY -fvisibility=hidden -O2 -g -fno-strict-aliasing -fPIC -I . -I ../core -I autogen/include -I ../modules/analysis/snowstem/source/include -I ../modules/unicode/ucd -I ../modules/unicode/utf8proc -c ../modules/analysis/snowstem/source/libstemmer/libstemmer_utf8.c -o ../modules/analysis/snowstem/source/libstemmer/libstemmer_utf8.o
../modules/analysis/snowstem/source/libstemmer/libstemmer_utf8.c:4:35: fatal error: ../include/libstemmer.h: No such file or directory
#include "../include/libstemmer.h"
^
compilation terminated.
make: *** [../modules/analysis/snowstem/source/libstemmer/libstemmer_utf8.o] Error 1
The problem seems to be that the code files in the modules include the include files with a relative path like #include "../include/libstemmer.h". Even though the resulting directory is included in the include files directory i.e. -I ../modules/analysis/snowstem/source/include but it does not work
I started modifying the source files to remove the relative path but more started cropping up. I think there must be a better way. Any help on how I can fix this would be really helpful.
If you do only cpan Lucy::Simple it should be enough
It seems to me there is not a C library available yet.
Above link is old (2012) but explains why it is not obvious.
http://grokbase.com/t/lucy/user/12bp9rw0g7/lucy-user-using-lucy-directly-from-c
https://github.com/cancerberoSgx/lucy.js/blob/master/scripts/build-lucy-c.sh
that's a shell script that will clone lucy .git and dependencies, compile lucy c and clownfish C them and then compile and run one of the lucy/samples/c
It does it all locally in a folder, so you don't have to install anything globally as root. you need linux buildtools like gcc, make, configure, etc. Good luck

Can not find linux/modversions.h

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')

Resources