libffi

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

libffi

Curtis Matz
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

> which gcc
/opt/local/bin/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.

Reply | Threaded
Open this post in threaded view
|

Re: libffi

Ken Cunningham

libffi

Curtis Matz [hidden email]
Sun Jun 28 19:37:49 UTC 2020


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



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

=================

DEBUG: Environment: 
CC='/usr/bin/clang'
CC_PRINT_OPTIONS='YES'
CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_wget/wget/work/.CC_PRINT_OPTIONS'
CFLAGS='-pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
CPATH='/opt/local/include'
CPPFLAGS='-I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
CXX='/usr/bin/clang++'
CXXFLAGS='-pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
DEVELOPER_DIR='/Library/Developer/CommandLineTools'
F90FLAGS='-pipe -Os -m64'
FCFLAGS='-pipe -Os -m64'
FFLAGS='-pipe -Os -m64'
INSTALL='/usr/bin/install -c'
LDFLAGS='-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
LIBRARY_PATH='/opt/local/lib'
MACOSX_DEPLOYMENT_TARGET='10.15'
OBJC='/usr/bin/clang'
OBJCFLAGS='-pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
OBJCXX='/usr/bin/clang++'
OBJCXXFLAGS='-pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64'
PERL='/opt/local/bin/perl5.28'
POD2MAN='/opt/local/bin/pod2man-5.28'
SDKROOT='/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'

============

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.

But better!


Ken


Reply | Threaded
Open this post in threaded view
|

Re: libffi

Ken Cunningham


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

but — then it won’t link next.

:>



Reply | Threaded
Open this post in threaded view
|

Re: libffi

Joshua Root-8
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.

- Josh