uniconproject / unicon

http://www.unicon.org
Other
54 stars 27 forks source link

unicon/iconc can't find ft2build.h when compiling #347

Open DestyNova opened 8 months ago

DestyNova commented 8 months ago

With the following program hello.icn:

procedure main()
  write("Hello, amigo!")
end

Trying to compile with unicon/iconc produces the following error:

❯ unicon -C hello.icn 
Parsing hello.icn: .
Parsing /home/omf/code/icon/unicon/ipl/procs/posix.icn: .........
iconc  -U1  -fs -o hello  -A /tmp/uni79385330 /tmp/uni86049813-iconc /tmp/uni20299443-iconc 
Translating to C:
No errors; no warnings
Compiling and linking C code:
In file included from hello.h:8,
                 from hello.c:13:
/home/omf/code/icon/unicon/rt/include/rt.h:3091:13: fatal error: ft2build.h: No such file or directory
 3091 |    #include <ft2build.h>
      |             ^~~~~~~~~~~~
compilation terminated.
*** C compile and link failed ***

The issue appears to be that ft2build.h is installed in /usr/include/freetype2 but gcc needs to be explicitly told about it. If I explicitly pass the include path it works:

❯ iconc -p '-I/usr/include/freetype2' hello.icn
Translating to C:
hello.icn:
No errors; no warnings
Compiling and linking C code:
Succeeded

I did a quick search and didn't see any other issues mentioning this, so perhaps it's a misconfiguration on my Pop!_OS (Ubuntu-based) system. Any advice would be appreciated.

Jafaral commented 8 months ago

Unless you intentionally want -C, you can just drop that and it should work.

I.e, just do unicon hello.icn

DestyNova commented 8 months ago

Unless you intentionally want -C, you can just drop that and it should work.

I.e, just do unicon hello.icn

Yes that works and is fine for local development, but if I wanted to build a binary that doesn't depend on iconx -- e.g. for distribution to people who don't have Unicon installed -- then -C is needed (although ldd tells me that those binaries have a lot of dynamic library dependencies).

Jafaral commented 8 months ago

Unicon is an interpreted language, the compiler is still in alpha state. So iconx is expect to be on the target platform typically. You can bundle iconx with an executable by passing -B:

unicon -B hello.icn

Give that a try. OF course that also assumes the the libraries you built iconx against should be available on the target platform. In all cases, portability of binaries is limited for various architectural reasons.