bloomberg / blazingmq

A modern high-performance open source message queuing system
https://bloomberg.github.io/blazingmq/
Apache License 2.0
2.53k stars 130 forks source link

Compilation failed on Fedora 39. #201

Closed faizol closed 6 months ago

faizol commented 6 months ago

Is there an existing issue for this?

Current Behavior

Compiling on Fedora 39 failed because of linking issue;

[100%] Linking CXX executable bmqtool.tsk
/usr/bin/ld: /usr/lib64/libfl.so: undefined reference to `yylex'

which could be traced to how flex 2.6.x changed the way yylex behaves.

Expected Behavior

No response

Steps To Reproduce

Env - OS: Fedora 39

Step - run bin/build-ubuntu.sh (commenting out the apt update and installations)

Expected - to compile/link without errors

Errors -

[100%] Linking CXX executable bmqtool.tsk
/usr/bin/ld: /usr/lib64/libfl.so: undefined reference to `yylex'

BlazingMQ Version

0.90.21

Anything else?

I solved the compilation issue by adding target_link_options(bmq PUBLIC "LINKER:-as-needed") to the CMakeLists.txt in the src/groups/bmq/ folder,

if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
  target_link_libraries(bmq PUBLIC "${FLEX_LIBRARIES}")
  target_link_options(bmq PUBLIC "LINKER:-as-needed")
endif()

However I am not sure if that's the right solution without affecting how BlazingMQ would behave.

pniedzielski commented 6 months ago

Hi @faizol, thanks for this report. I'll try reproducing this on in a Fedora 39 environment.

We use flex to parse and evaluate subscriptions in the bmqeval package. As I understand, libfl provides default implementations of two functions, main and yywrap, neither of which we use in BlazingMQ. So we probably shouldn't be linking against this at all, which is why the -as-needed flag works for you.

If you're interested, I notice there's a libfl-static library in Fedora, which seems to provide .a files instead of the .so files libfl2 provides. This is the same as the libfl-dev package that Debian provides, and that we list as a requirement. I wonder if not using --as-needed and instead linking against libfl-static would also work?

faizol commented 6 months ago

Linking it against static library (libfl.a) does solve the problem on Fedora 39 platform. Thank you.