I'm trying to install some software on my Mac (OS X El Capitan 10.11) and when running its configure script, I'm getting a message that it cannot create executables. I'm passing:
../configure \
--disable-diablo \
--download-essential \
CC=/usr/local/bin/mpicc \
CXX=/usr/local/bin/mpicxx \
F77=/usr/local/bin/mpif77 \
FC=/usr/local/bin/mpif90 \
from a build directory. I had to specify where the compilers are located as it would also return an error if I didn't. Also, I am very new to this material so I would like to ask for a bit of patience if I take a while to understand whatever help is sent my way.
Also, I'm having trouble posting my config.log, so help with that would be appreciated as well.
This error usually means that the compiler failes a simple test of compiling a test code and running the resulting binary. You are trying to use mpicc to compile your project (is it necessary?) and it is only a wrapper for regular compiler, You have to have gcc or clang already in the system.
The easiest way to get all "Command line tools" including clang for macOS is to just install XCode and follow with xcode-select --install in terminal.
Related
I'm trying to install fftw-2.1.5 as it is required by the GADGET3 code version I need to use. I had no issues building it on my Linux machine (running Ubuntu 22.04), but on my M1 MacBook Pro (running macOS Monterey 12.4) it crashes at the configure step.
Running:
./configure --prefix=path/to/local/install \
--enable-mpi \
--enable-type-prefix \
--with-gcc
I got the following error message:
checking build system type... configure: error: /bin/sh ./config.sub -apple-darwin21.5.0 failed
It seems that the configure script is not properly parsing the details of the MacBook, hence it crashes before testing the rest of the dependencies...
Disclaimer: I am fairly new to macOS and I have never had to use autotools before.
I found a similar issue here, so credits to the people that documented it there. I am unsure if all the following steps are required but they certainly solved my issue:
I renamed configure.in to configure.ac
I downloaded and applied all the patches from this website. I simply copied the text of each patch into new files patch_filename and ran $ patch < patch_filename in the main fftw-2.1.5 directory. As I renamed configure.in to configure.ac, when applying patch 05_ac_define_syntax.diff it will prompt the user to specify the path to the file to patch, i.e. configure.ac.
(OPTIONAL) I also needed OpenMP support so additionally I needed to modify lines 249, 251, 253, 255 and 257 so that the variables omp_enabler and CFLAGS read as omp_enabler="$CC -fopenmp" and CFLAGS="$save_CFLAGS -fopenmp", where CC=gcc in my case.
I ran $ autoupdate followed by $ autoreconf -vfi in the main fftw-2.1.5 directory.
I ran the configure script with the desired flags, e.g. for double precision + MPI support:
$ ./configure --prefix=path/to/local/install \
--enable-mpi \
--enable-type-prefix \
--with-gcc \
LDFLAGS=-L/opt/homebrew/lib \
CFLAGS=-I/opt/hombrew/include
Finally, the standard make into make check and make install did the trick
I'm trying to set up CMake for a project I'm working on, and I'm first trying to compile a simple Hello World program in C. I'm using Windows 10 with MSYS2. If I invoke the compiler (GCC) directly in Bash, it compiles fine without warnings or errors and gives an executable as output which prints "Hello, world!" exactly as expected. My problem comes in when I try to use CMake to compile my project. When I run cmake -G Ninja .. to compile my project, it throws this error:
CMake Error at C:/msys64/mingw64/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/msys64/mingw64/bin/cc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/dylanweber/Documents/C-Projects/webapp/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/msys64/usr/bin/ninja.exe cmTC_45340 && [1/2] Building C object CMakeFiles/cmTC_45340.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_45340.dir/testCCompiler.c.obj
C:\msys64\mingw64\bin\cc.exe -o CMakeFiles/cmTC_45340.dir/testCCompiler.c.obj -c testCCompiler.c
/bin/sh: C:msys64mingw64bincc.exe: command not found
ninja: build stopped: subcommand failed.
Notice how it mentions C:msys64mingw64bingcc.exe... there must be some kind of path delineation problem but I've tried setting the CC environmental variable to C:\\msys64\\mingw64\\bin\\gcc.exe and C:/msys64/mingw64/bin/gcc.exe. I have been clearing the CMake caches between runs.
Here is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.15)
project(webapp)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
file(GLOB SOURCES "main/*.c")
add_executable(webapp ${SOURCES})
My code is in a "main" folder which is currently just one "main.c" file, in addition to a build directory used to keep all the temporary files in. The most frustrating part is that CMake was just working an hour ago, and I didn't change anything. What can I do to fix this problem?
The solution was not only installing the MinGW64 version of CMake, but also the MinGW64 version of Ninja as well. Since they have different pathing schemes compared to MSYS, they didn't play well together until they were both on the same POSIX-like platform.
I have the MinGW install previously working fine with MSYS. They are installed properly and functioning just well.
I installed the PortAudio library and did the install and got the success message after:
./configure
make
make install
When I try to compile samples:
c:\c>gcc patest_mono.c -o pa.exe
patest_mono.c:50:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
I'm new. I have a feeling I might be doing something fundamentally wrong with the way I'm trying to create the exe from compiling. It's been somewhat of a puzzle quest so far, but I've tried to figure it out and think I am close but completely missing something.
PATH variable ?
In the PortAudio MinGW build instructions I noticed
"The above should create a working version though you might want to
provide '–prefix=<path-to-install-dir>' to configure. "
I've tried adding C:\MingW\PortAudio into the user path. Doesn't work.
I've also tried running the commands in Bash and they come back with an error message "No Rule to make target 'paexpink'" either with the make command, and with gcc .c -o .exe I just get the same error message as compiling straight from the cmd prompt.
I found another source on stack overflow thread with no answers, but the user had commented that http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio provided them a solution but I tried installing the 5 cpython binaries and under the assumption I did it right, it didn't work either.
Thanks for your help,
Julian
To build and install portaudio, you need to add -prefix=/c/<"path to base of the MinGW directory"> to the ./configure line.
For example: ./configure -prefix=/c/MinGW/
then continue the installation by doing
make
After that, do the
make install
and that should install the portaudio files into MinGW.
After it has finished installing, you need to add -lportaudio to the compile command whenever you compile any programs that you want to use PortAudio in.
For example: gcc -o test test.c -lportaudio
I just figured out how to do this today, so I may have accidentally forgotten a few steps.
I am trying to install and run cmocka library for unit testing on Mac OSX Yosemite 10.10.3, but I've got some problems with the RPATH settings.
Update:
Thanks to #baf, I was able to include cmocka.h in my CMakeLists.txt manually like this:
set(CMAKE_C_FLAGS_DEBUG "-I/usr/local/include/cmocka.h")
However, why is it so that I have to do it manually?
I've already tried many different ways of installing it:
What I've done so far:
Download cmocka from here: here. Version 1.0.
tar xvf cmocka-1.0.1.tar.xz
cd cmocka-1.0.1, mkdir build and cd build
sudo cmake ..
I get a message like this here:
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake --help-policy CMP0042" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
cmocka_shared
This warning is for project developers. Use -Wno-dev to suppress it.
Question #1: How can I set the rpath so that there is no warning like the one above?
sudo make
sudo make install
cmocka should be installed now, right?
Running cmake for my program which is using cmocka library.
So now I run cmake for my program and my main CMakeList.txt file has lines like this:
find_library (CMOCKA cmocka)
if (NOT CMOCKA)
message (WARNING "Cmocka library not found.")
endif (NOT CMOCKA)
But the warning doesn't show up during this phase, so I believe that find_libarary(CMOCKA cmocka) has successfully located cmocka on my computer.
Running make for my program.
While running make I get an error like this:
fatal error:<br>
'cmocka.h' file not found<br>
#include <cmocka.h>
^
1 error generated.
So I guess that cmocka cannot be found...
Question #2: Why cmocka library cannot be found?
Additional notes:
I've tried running
$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
but it didn't helped. I guess it is a solution for Linux, not Mac.
I've tried to learn something about RAPTH on Mac in cmake from their official documentation here: http://www.cmake.org/Wiki/CMake_RPATH_handling. However I understood very little and I wasn't able to come up with a solution for my problem.
I've tried installing cmocka using brew but I got the same result.
Moreover, I've read many questions at SO about RPATH, linking and cmocka, but I couldn't find a suitable solution as well. Nevertheless, here is the list of related threads:
How to set the runtime path (-rpath) of an executable with gcc under Mac OSX?
https://stackoverflow.com/questions/29721183/getting-undefined-symbols-for-architecture-x86-64-when-trying-to-build-on-osx
How to configure scons to link using rpath on mac?
mariadb install failure: make (Mac OSX 10.6.8)
I've run otool -L cmocka. Here's what I got:
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: cmocka (No such file or directory)
I was able to successfully compile my program (thanks to baf) when I added the -I/usr/local/include flag to my debug flags:
set(CMAKE_C_FLAGS_DEBUG "-std=gnu99 -Wall -pedantic -g -I/usr/local/include/cmocka.h")
I'm currently building on Windows 7 and am trying to get my debugger to step through my code. The problem is that, while I have my build configuration set to debug, and my CONFIG variable to set to debug in my QMake file, it still doesn't work.
Here is my QMake file:
TEMPLATE = app
CONFIG += console debug
CONFIG -= qt
QMAKE_CXXFLAGS += -g -gdb
SOURCES += main.c \
Triangle.c \
GlutTesting.c
HEADERS += \
Triangle.h \
Includes.h \
GlutTesting.h
LIBS += -lSDL -lopengl32 -lfreeglut
Note that it's actually written in C and compiled as such (all of the files are native C code, compiled with MinGW).
The issue is that everytime I start, even if I set a breakpoint, the code literally just zooms through it to the end of the applications current setting and stops there. It's almost impossible to actually debug my applications now.
What is wrong here? Everytime I Google I just find something about "adding debugging symbols", which is easy to do in Linux, but in Qt Creator it seems quite the PITA to get done properly (unless I'm just missing something totally simple).
Faced the similar problem on Linux (Fedora 16) using Qt Creator 2.5.0
It turned out that gdb started in my home directory and could not (I don't know why) load debugging symbols of a library being debugged. Whenever I force gdb to start from directory where the library binary file is placed (in Qt Creator it is done through additional debugger startup commands in Tools->Options->Debugger->Additional Startup Commands: just make "cd" to the directory with binary file) everything works fine.
One more solution is to set the environment variable LD_LIBRARY_PATH to contain full path to the directory with binary. In Qt Creator it is done in Project->Run Settings->Run Environment.
In order to check that debugging symbols have been loaded properly open gdb log via Window->Views->Debugger Log and type the command "info shared".
This worked for me under Linux, and I'm not sure if it'll work under Windows but here it goes anyway:
in the .pro file, I added the line:
CONFIG += debug
This enabled debugging within the QT system. Then i added the following:
QMAKE_CXXFLAGS += -O0 -g -ggdb
The -ggdb is for the gdb support. And the O (letter O) 0 (number zero) to be no optimisation - to prevent the compiler from optimising out variables. This gives me the backtraces i need with all the symbols when debugging under Linux. This is a fairly standard debugging compiling option across the board with gdb. But it may already be covered by the debug option in CONFIG.
Under Linux i rebuilt the project too:
make clean
make
But for Windows, if you're using Visual Studio, you might need to do a rebuild. I don't know what your compilation toolchain is.
I know you're using Windows, and it might be worth trying these things in case it works under Windows too. However, even if it doesn't work under Windows, it could be useful for someone searching for how to do this under Linux, so I think this is a valid answer, even though it may not specifically answer this particular question.