Welcome to the Builder Academy

Question configure script uses implicit int for test app

More
23 Feb 2025 18:28 #10547 by Banlock
I'm trying to build tbaMUD on a Apple Silicon Mac running Sequoia with compiling tools as installed by Xcode (so clang version 16.0.0).

I got a message from configure:
Code:
checking whether the C compiler (gcc  ) works... no [color=#000000][size=1][font=Monaco]configure: error: installation or configuration problem: C compiler cannot create executables.[/font][/size][/color]

I created a simple test.c to make sure the complier works, and it did. So I looked to see what the compiler script was doing and at line 694 saw this:
Code:
cat > conftest.$ac_ext << EOF #line 697 "configure" #include "confdefs.h" main(){return(0);} EOF

I tried that as a separate .c file and got this:
Code:
[color=#000000][size=1][font=Monaco]configure:699:1: [color=#ad1f16]error: [/color]type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int][/font][/size][/color]

So I changed the test code in configuration to have "int main()" and it worked.

I guess this isn't really your problem as configure is part of aututools and isn't something that you guys control - but aside from editing the script, is there a better way to handle this? Thanks for any suggestions!

Please Log in or Create an account to join the conversation.

More
23 Feb 2025 20:49 - 23 Feb 2025 21:04 #10548 by ironfist
I'm not super familiar with autotools, but I think you are technically supposed to edit the configure.in (which should be configure.am?) to generate the configure script and also edit the Makefile.am... I ran autoreconf -fi on configure.in and got a lot of deprecation/obsolete warnings.

Also, circlemud was made before c99, some of the stuff might need some more work to get to that level

Edit: When I did run the autoreconf -fi on the configure in the cnf dir, I do see int main( on all the functions inside of that configure script it puts in the cnf directory

Another Edit:  autoupdate seems to update the configure.in
Last edit: 23 Feb 2025 21:04 by ironfist.

Please Log in or Create an account to join the conversation.

More
23 Feb 2025 22:33 #10549 by thomas
Yeah, I think a reasonable step upwards would be to work toward cmake and more modern build systems, so modern IDEs can be used for the development more easily than it can today.
I'm not currently fluent in C build tools, so this is something I would like help with. If not, I'll involve an AI for teaching me :)

Please Log in or Create an account to join the conversation.

More
23 Feb 2025 23:28 #10550 by ironfist
I had been messing around with ninja/meson since that is what gnome/gtk uses and ended up with something below.  It seems to work with the tbamud code I'm working on currently but has mysql that is not on stock.  I haven't tested all the steps from scratch to make sure they were copied right though.  I've only used it on ubuntu.  It is very basic and probably needs a lot of work but here is what it looks like:

meson.build
Code:
# Project definition project('tbaMUD', 'c', version: '1.0') # Option to enable profiling profile = get_option('profile') ? ['-pg'] : [] # Compiler flags and options cflags = ['-Wall', '-Wno-char-subscripts', '-Wno-unused-but-set-variable', '-I/usr/include/mysql'] # MySQL dependency mysql_dep = dependency('mysqlclient', required: true) # Get the C compiler cc = meson.get_compiler('c') # Add the crypt library crypt_dep = cc.find_library('crypt', required: true) # Declare a custom dependency that includes compiler flags and the MySQL and Crypt dependencies global_deps = declare_dependency(   compile_args: cflags + profile,   dependencies: [mysql_dep, crypt_dep] ) # Add the subdirectory where the source files are subdir('src') # Utilities # subdir('util') # Create the executable (no path specified here) (if you want /usr/local/bin) # executable('circle', src_files, dependencies: global_deps, install: true, install_dir: join_paths(get_option('prefix'), 'bin')) # Create the executable in the root directory and install it into the 'bin' directory executable('circle', src_files, dependencies: global_deps, install: true, install_dir: 'bin')

cat meson_options.txt
Code:
option('profile', type : 'boolean', value : false, description : 'Enable profiling')

cat src/meson.build
Code:
# Source files in the src directory src_files = files(   'act.comm.c', 'act.informative.c', 'act.item.c', 'act.movement.c', 'act.offensive.c',   'act.other.c', 'act.social.c', 'act.wizard.c', 'aedit.c', 'arena.c', 'asciimap.c',   'ban.c', 'boards.c', 'bsd-snprintf.c', 'castle.c', 'cedit.c', 'clan.c', 'clanedit.c',   'class.c', 'comm.c', 'config.c', 'constants.c', 'db.c', 'dg_comm.c', 'dg_db_scripts.c',   'dg_event.c', 'dg_handler.c', 'dg_misc.c', 'dg_mobcmd.c', 'dg_objcmd.c', 'dg_olc.c',   'dg_scripts.c', 'dg_triggers.c', 'dg_variables.c', 'dg_wldcmd.c', 'feats.c', 'fight.c',   'genmob.c', 'genobj.c', 'genolc.c', 'genqst.c', 'genshp.c', 'genwld.c', 'genzon.c',   'graph.c', 'handler.c', 'hedit.c', 'house.c', 'ibt.c', 'improved-edit.c', 'interpreter.c',   'limits.c', 'lists.c', 'magic.c', 'mail.c', 'medit.c', 'memorization.c', 'mobact.c',   'modify.c', 'msgedit.c', 'mud_event.c', 'mysql_db.c', 'mysql_players.c', 'oasis.c',   'oasis_copy.c', 'oasis_delete.c', 'oasis_list.c', 'objsave.c', 'oedit.c', 'players.c',   'prefedit.c', 'protocol.c', 'qedit.c', 'quest.c', 'random.c', 'redit.c', 'sedit.c',   'shop.c', 'spec_assign.c', 'spec_procs.c', 'spell_parser.c', 'spells.c', 'statedit.c',   'strife_quest.c', 'tedit.c', 'utils.c', 'weather.c', 'zedit.c', 'zmalloc.c' )

- **Meson** (build system)
- **Ninja** (build backend)
- **GCC** (C compiler)
- **MySQL Client Libraries**
- **Crypt Library** (for password encryption)

You can install the required packages on a Debian-based system (e.g., Ubuntu) using:

sudo apt update
sudo apt install meson ninja-build gcc libmysqlclient-dev libcrypt-dev

## Compilation and Installation Steps

Follow the steps below to compile and install the project locally.

### Step 1: Configure the Build Directory

First, configure Meson to use the root of the project as the installation prefix:

meson setup builddir --prefix=$PWD

This command sets up the build directory and ensures that the compiled binary will be installed in the local `bin/` directory inside the project.

### Step 2: Compile the Project

To compile the project, run the following command:

meson compile -C builddir

This will compile the source files and generate the necessary binaries.

### Step 3: Install the Executables

After the project is compiled, install the `circle` executable (and any other required binaries) to the `bin/` directory in the project:

meson install -C builddir

The `circle` executable and other utility programs will be installed into `bin/`.

### Step 4: Run the Project

To run the `circle` executable, use the following command:

./bin/circle

This will launch the tbaMUD server.

## Cleaning the Build

If you want to clean the build directory, you can remove the `builddir` directory:

rm -rf builddir

Then, you can reconfigure and rebuild by repeating the steps above.

Please Log in or Create an account to join the conversation.

More
24 Feb 2025 15:40 - 24 Feb 2025 15:42 #10551 by Banlock
For clarification, I was using command line only - so not Xcode itself, and I don't have the autotools installed so I haven't experimented with that. I'm wondering if configure just missed that I was on a Mac OS system instead of a generic unix-like? It also put -lcrypt in the makefile - which causes an error and isn't needed on the Mac.

Has anyone done a completely clean configure; make on a modern Mac recently? My code had lived on an Intel Mac before and I had recently updated the code from tbaMUD 2018 to 2025 (using git), so maybe there was some cruft from the older code or environment left behind.

But, I'm not sure this is super relevant as I'm sure most people building tbaMUD will be on Linux.

In any event, I hope my experience will be helpful to anyone in a similar situation. Thanks everyone for the comments.

(By the way, with changes made it built and ran successfully, as far as I can tell)
Last edit: 24 Feb 2025 15:42 by Banlock. Reason: More clarification

Please Log in or Create an account to join the conversation.

More
24 Feb 2025 17:39 - 24 Feb 2025 18:03 #10552 by ironfist
Autotools is what generates the configure file in the root directory though.  (I don't think the one in the repository has been regenerated in a while)  If you don't use autotools, then you don't need the configure script.  For example, meson doesn't use a Makefile (which configure generates from Makefile.in).  I believe CMAKE uses its own tools, though I'm not real familiar with any of these build systems so someone can step in and counter any of this ;).

I don't necessarily trust google AI totally, but it claims:

To use autotools on a Mac, the most common approach is to install the necessary tools (autoconf, automake, and libtool) using a package manager like Homebrew and then run the standard autotools commands within your project directory to generate a configure script and build your application for your Mac system; essentially following the same process as on Linux

However, the parts of the code that say CIRCLE_MAC... I believe that is for pre-bsd-unix-mac, so you may have issues there - not sure what has happened with that over the years or if any of that has been addressed.

Edit: you could still edit the Makefile manually and remove the lcrypt if that works also, but I think you would lose the changes if you regenerate the Makefile with a configure later on, but whatever works for your workflows :).
Last edit: 24 Feb 2025 18:03 by ironfist.
The following user(s) said Thank You: Banlock

Please Log in or Create an account to join the conversation.

Time to create page: 0.219 seconds