I’ve installed libffi but I’m trying to compile and it says it can’t find ffi.h. How do I tell my compiler which happens to be gcc9 to look in /opt/local for the header file?
> port installed | grep libffi
libffi @3.2.1_0 (active)
src/rtlib/thread_call.c:33:10: fatal error: ffi.h: No such file or directory
33 | #include <ffi.h>
make: *** [src/rtlib/obj/darwin-x86_64/thread_call.o] Error 1
> which gcc
> gcc --version
gcc (MacPorts gcc9 9.3.0_1) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I take it you are trying to build your own software using stuff from MacPorts and it doesn’t work.
Homebrew always “just worked” but MacPorts does not. Sadly, you are the second person so far in as many weeks to ask how the heck to actually use macports :>
For better or worse, richer or poorer, MacPorts has tucked all it’s software away in a hidden directly that no software ever looks in without being told to. That is __better__. That is __harder__. Sometimes __much_harder__. That’s because MacPorts was designed 20 years ago by software engineers who knew what they were doing, and knew how to do it right. It is safer/more secure/just better to do it this way.
It’s also 1000x harder for users, which is why the competition has done so frighteningly well with an mostly vastly inferior product (that everyone can use).
You need to set up your bulld to use MacPorts. The easiest way to see how is to try to configure any good port using “sudo port -d configure XYZ”, and see what MacPorts does for you behind the scenes
CFLAGS='-pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
CXXFLAGS='-pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
F90FLAGS='-pipe -Os -m64'
FCFLAGS='-pipe -Os -m64'
FFLAGS='-pipe -Os -m64'
LDFLAGS='-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
OBJCFLAGS='-pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
OBJCXXFLAGS='-pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
Most of that, except the PERL and POD2MAN probably, is what you need to put into your environment with individual commands, a shell script, etc.
And if you’re trying to do that with Xcode — well please tell us all how. That’s really hard.
> On Jun 28, 2020, at 9:47 PM, David Strubbe <[hidden email]> wrote:
> Probably you want to set CFLAGS=-I/opt/local/include. This is the standard way to tell a C compiler where to find .h files.
but — then it won’t link next.
In reply to this post by Curtis Matz
Curtis Matz wrote:
> I’ve installed libffi but I’m trying to compile and it says it can’t find ffi.h. How do I tell my compiler which happens to be gcc9 to look in /opt/local for the header file?
>> port installed | grep libffi
> libffi @3.2.1_0 (active)
> src/rtlib/thread_call.c:33:10: fatal error: ffi.h: No such file or directory
> 33 | #include <ffi.h>
> | ^~~~~~~
> compilation terminated.
> make: *** [src/rtlib/obj/darwin-x86_64/thread_call.o] Error 1
This is the problem pkg-config was designed to solve. Compile with
`pkg-config --cflags libffi` and link with `pkg-config --libs libffi`.
It happens that libffi doesn't put its header directly in
/opt/local/include, but pkg-config knows that so you don't have to.
|Free forum by Nabble||Edit this page|