Compile MaxScale

I'm trying to compile MaxScale on FreeBSD 11 and follow these guidelines: https://mariadb.com/kb/en/mariadb-e...21-building-mariadb-maxscale-from-source-code

Code:
However, I get a libdl error
# cmake ../MaxScale -DBUILD_TESTS=Y
-- CMake version: 3.8.2
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/CC
-- Check for working CXX compiler: /usr/bin/CC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file arpa/inet.h
-- Looking for include file arpa/inet.h - found
-- Looking for include file crypt.h
-- Looking for include file crypt.h - not found
-- Looking for include file ctype.h
-- Looking for include file ctype.h - found
-- Looking for include file dirent.h
-- Looking for include file dirent.h - found
-- Looking for include file dlfcn.h
-- Looking for include file dlfcn.h - found
-- Looking for include file errno.h
-- Looking for include file errno.h - found
-- Looking for include file execinfo.h
-- Looking for include file execinfo.h - found
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Looking for include file ftw.h
-- Looking for include file ftw.h - found
-- Looking for include file getopt.h
-- Looking for include file getopt.h - found
-- Looking for include file ini.h
-- Looking for include file ini.h - not found
-- Looking for include file math.h
-- Looking for include file math.h - found
-- Looking for include file netdb.h
-- Looking for include file netdb.h - found
-- Looking for include file netinet/in.h
-- Looking for include file netinet/in.h - found
-- Looking for include file openssl/aes.h
-- Looking for include file openssl/aes.h - found
-- Looking for include file openssl/sha.h
-- Looking for include file openssl/sha.h - found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for include file pwd.h
-- Looking for include file pwd.h - found
-- Looking for include file regex.h
-- Looking for include file regex.h - found
-- Looking for include file signal.h
-- Looking for include file signal.h - found
-- Looking for include file stdarg.h
-- Looking for include file stdarg.h - found
-- Looking for include file stdbool.h
-- Looking for include file stdbool.h - found
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file stdio.h
-- Looking for include file stdio.h - found
-- Looking for include file stdlib.h
-- Looking for include file stdlib.h - found
-- Looking for include file string.h
-- Looking for include file string.h - found
-- Looking for include file strings.h
-- Looking for include file strings.h - found
-- Looking for include file sys/epoll.h
-- Looking for include file sys/epoll.h - not found
-- Looking for include file sys/ioctl.h
-- Looking for include file sys/ioctl.h - found
-- Looking for include file syslog.h
-- Looking for include file syslog.h - found
-- Looking for include file sys/param.h
-- Looking for include file sys/param.h - found
-- Looking for include file sys/socket.h
-- Looking for include file sys/socket.h - found
-- Looking for include file sys/stat.h
-- Looking for include file sys/stat.h - found
-- Looking for include file sys/time.h
-- Looking for include file sys/time.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for include file sys/un.h
-- Looking for include file sys/un.h - found
-- Looking for include file time.h
-- Looking for include file time.h - found
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
CMake Error at cmake/CheckPlatform.cmake:74 (message):
  Could not find libdl
Call Stack (most recent call first):
  CMakeLists.txt:31 (include)


-- Configuring incomplete, errors occurred!
See also "/maxscale/build/CMakeFiles/CMakeOutput.log".
See also "/maxscale/build/CMakeFiles/CMakeError.log".

I've found a number of reference to similar problems with other applications, but none of the suggestions work for me. How can I remove the "libdl" requirement (which doesn't seem to be needed according to /usr/bin/ld: cannot find -ldl

Thanks.
 

Attachments

  • CMakeError.log.txt
    2.4 KB · Views: 340
  • CMakeOutput.log.txt
    49 KB · Views: 312
A: I have no idea what MariaDB is, nor do I care. But did you look whether it is even supported on FreeBSD? Has anyone ever said that this make file is expected to work on FreeBSD?

B: libdl exists on Linux, where it is used for dynamic loading (so a running program can load new functions). There is no libdl on a default FreeBSD installation. I don't know of any API-compatible replacement. But a good starting point might be: Read the FreeBSD handbook, and search for the "Linux binary compatibility" section. That stuff installs a lot of libraries; if you get lucky, a Linux-compatible dl library is among them.

C: How can you remove the libdl requirement? I hope you know how to edit make files, and the make infrastructure of MariaDB, and I hope you know how to read and modify the source code of MariaDB. Here's what I would do: Edit the complete make file so libdl is not searched for, and the final link command (the "ld" command line) doesn't have -ldl switch. Then try to do a full build. Most likely, the final link stage will fail, because something in MariaDB must be calling some function that resides in libdl. Find that call, get some Linux documentation to understand what it does, then look for equivalent BSD functionality, and change the code to use that.
 
A: I have no idea what MariaDB is, nor do I care. But did you look whether it is even supported on FreeBSD? Has anyone ever said that this make file is expected to work on FreeBSD?

You've probably not been aware of much of the world outside FreeBSD :) MariaDB is the fork of MySQL that is being used by many these days. (But I'm pretty sure you know and are just being mean). It runs in FreeBSD and can be install from the ports. The MariaDB devs have offered to assist, but of course it's good to get input from both the OS and the app dev camps. No need to get hostile :-o

B: libdl exists on Linux, where it is used for dynamic loading (so a running program can load new functions). There is no libdl on a default FreeBSD installation. I don't know of any API-compatible replacement. But a good starting point might be: Read the FreeBSD handbook, and search for the "Linux binary compatibility" section. That stuff installs a lot of libraries; if you get lucky, a Linux-compatible dl library is among them.

Did you even bother with the source I quoted above? In it someone said: "The same functionality that is in linux's libdl is provided in FreeBSD's libc", so I should be able to remove the requirement for it in building MaxScale, which btw is a MariaDB product, but not MariaDB itself.

C: How can you remove the libdl requirement? I hope you know how to edit make files, and the make infrastructure of MariaDB,

I know reasonably well, but I'm learning as I go along. That's why I'm here.

and I hope you know how to read and modify the source code of MariaDB.

I can read source code also reasonably well, but I have no interest in editing MariaDB's source, since it's not what I'm trying to get to build in FreeBSD, it's there already.

Here's what I would do: Edit the complete make file so libdl is not searched for, and the final link command (the "ld" command line) doesn't have -ldl switch. Then try to do a full build. Most likely, the final link stage will fail, because something in MariaDB must be calling some function that resides in libdl. Find that call, get some Linux documentation to understand what it does, then look for equivalent BSD functionality, and change the code to use that.

Now this part of your response is at least useful and thank you for it. I have been asked to file a bug report on MaxScale as I find problems, so I trust the MaxScale devs will patch the code, since they build the database product for FreeBSD already.
 
You've probably not been aware of much of the world outside FreeBSD :) MariaDB is the fork of MySQL that is being used by many these days. (But I'm pretty sure you know and are just being mean). ...
Honestly, until you pointed it out, I had no idea what MariaDB is. Which is sort of funny: Given that I worked for 16 years with the people who invented relational databases, one would think that I'm an expert in that field ... but I barely know how to write the simplest SQL, don't understand DB internals, and don't use them much. (And I use other OSes much more than FreeBSD, but happen to like FreeBSD much better.)

But in the end, it doesn't matter exactly what MariaDB and its outgrowth MaxScale are. It is a piece of software, for which ports to FreeBSD exist, but the port is "broken", in the sense that it doesn't compile because porting the dynamic library functionality has some problem. At that point, there really are two approaches to take: One is to ask the people who have performed the ports to help; the other is to look at the source code and fix it yourself. You are pursuing both, which is good. My advice was only meant for the second path, which is fixing it yourself.

Did you even bother with the source I quoted above? In it someone said: "The same functionality that is in linux's libdl is provided in FreeBSD's libc", so I should be able to remove the requirement for it in building MaxScale, which btw is a MariaDB product, but not MariaDB itself.
The problems with dynamic library handling between operating systems are well known: the family of "dl..." functions is not completely standardized between operating systems. The basic dlopen(), dlsym(), dlerror(), dlclose() sequence seems to be compatible between most *nix OSes, and that makes sense since they are now Posix. but Linux has a few extra calls in the libdl library that other OSes don't. And it has the (perhaps obsolescent) habit of storing the "dl..." functions in libdl rather than in libc. Perhaps, if you can modify the make scripts of MaxScale to not use libdl at all, it might just work completely. If not, the compiler/linker error messages will help you debug it, if you choose to debug it yourself.

(By the way, in many software projects the make scripts are the second-worst part of the package, they don't receive enough loving care and attention to detail, which is why they typically cause problems when moving to other environments. The only thing that is usually done even sloppier are automated test scripts. But that's just a sigh of frustration of having worked in software for several decades. And the software I write is part of the problem, not part of the solution.)
 
I found if you remove the the dl requirement from the cmake file, the list of dependencies goes on for a bit. MaxScale also requires e2fsprogs-libuuid and bison to be installed. After that cmake bombs out, reporting it cannot find certain init functions in /lib/lsb, which I assume is looking for Linux-related functions.

I stopped here, but it looks like the rabbit hole keeps going for a while and it looks like MaxScale assumes building on a Linux environment.
 
Unfortunately time doesn't allow me to learn how to proceed beyond this point at this stage, so I will just have run MaxScale on Linux for the time being. Hopefully the people that support MariaDB on FreeBSD will in time also dot the same for MaxScale.

Thanks for all comments and effort.
 
Back
Top