SmallBASIC icon indicating copy to clipboard operation
SmallBASIC copied to clipboard

Compile failed on FreeBSD

Open Curculigo opened this issue 1 year ago • 8 comments

fs_serial.c:57:12: error: use of undeclared identifier 'B576000'
   57 |     return B576000; 
      |            ^
fs_serial.c:63:12: error: use of undeclared identifier 'B1152000'
   63 |     return B1152000;
      |            ^
2 errors generated.

Curculigo avatar Aug 04 '24 02:08 Curculigo

Only baud rates from B300 to B38400 are defined by POSIX. In Linux additional baud rates are defined, which I included in SmallBASIC, because 38400 bauds is too slow. Every Arduino can communicate much faster using serial connection. In OpenBSD and FreeBSD B300 to B38440 are defined, too, and additional some faster modes. But it seems not the same as in Linux. @chrisws : Do you think it is a good idea to uses #ifdef to check, whether a baud rate is defined? Would maybe look a little bit ugly.

Joe7M avatar Aug 04 '24 20:08 Joe7M

@Curculigo : If you want to have a quick fix, so that you can build SmallBASIC, then edit the file SmallBASIC/src/common/fs_serial.c and remove everything (including) line 45 to 75. This will remove all non-POSIX baud rates.

Joe7M avatar Aug 04 '24 20:08 Joe7M

adding an #ifdef for one of the baud rate codes (to assume all or nothing) seems the simplest fix. it doesn't seem to be worth adding some handling in the configure script for this issue.

chrisws avatar Aug 05 '24 02:08 chrisws

Now it's unable to find pcre.h. pcre.h is in /usr/local/include. I passed CXXFLAGS="-I/usr/local/include" before running the configure script and the configure script has picked it:

Before:

Building Unix console version.
CFLAGS=-g -O2 -std=gnu11
CXXFLAGS=-g -O2
PACKAGE_LIBS= -lm -ldl -lpthread -L/usr/local/lib -Wl,-R/usr/local/lib -lpcre

After:

Building Unix console version.
CFLAGS=-g -O2 -std=gnu11
CXXFLAGS=-I/usr/local/include
PACKAGE_LIBS= -lm -ldl -lpthread -L/usr/local/lib -Wl,-R/usr/local/lib -lpcre

But it still fails to find pcre.h. Btw, I noticed that -g -O2 is removed after I passed my own CXXFLAGS. I want to append CXXFLAGS, not replace it. How can I do that?

Curculigo avatar Aug 05 '24 04:08 Curculigo

What output did you get when running configure ?

You should see something like

checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for pcre-config... yes

This uses pcre-config --libs to setup the include path accordingly.

chrisws avatar Aug 05 '24 04:08 chrisws

checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether byte ordering is bigendian... no
./configure: line 7046: g++: command not found
checking for pcre-config... yes

Curculigo avatar Aug 05 '24 07:08 Curculigo

ah - i see it's setting the lib path but not the include path. also the g++ error is from building keywords. looks like you still need to install the gnu c++ compiler - or maybe you have something else?

chrisws avatar Aug 05 '24 07:08 chrisws

The default compiler on FreeBSD is LLVM Clang.

Curculigo avatar Aug 05 '24 08:08 Curculigo