-1

I have problems building an executable file for a simple disease-transmission model implemented in C++, using cmake under macOS Monterey (v12.6.1). When I build the executable file, I obtain the following error when I try running it:

dyld[5281]: symbol not found in flat namespace (_cblas_caxpy) Abort trap: 6

The problem persists when I try to use XCode (v14.0.1) instead, resulting in the same error message.

Interestingly, my friend is able to build (& run) the executable file under macOS v10.15.7 without any problems.

Does anybody know what is going on here and how this issue can be resolved? The C++ project is publicly available on GitHub: https://github.com/AnnaMariaL/DengueSim

Any help would be very much appreciated.

Thanks!

Anna

  • tried: build an executable file with cmake, and Xcode under MacOS v12.16.1
  • expected: executable file
  • the program runs fine when launched under Xcode itself, but if I try to run the built executable from Xcode on the command line, that fails with the same error as for the CMake executable. So Xcode itself is, somehow, magically able to get this linker issue to resolve.
  • **First thing first:** In the title you mention "cmake fails to generate executable file" **CMake isn't suppose to generate anything, cmake is a build tool that helps you generate configuration for your compiler and linker**. In the post you then mention that you have built your executable. So you actually have an executable and the problem is elsewhere. I'm writing this to you not to belittle you. But to point out why you might not get an actual answer on your post. I will however write what is the most probable issue. – Milan Š. Jan 20 '23 at 14:51
  • 1
    And as a side note: Most of your issues would be more apparent if the `CMakeLists.txt` would be written properly. – Milan Š. Jan 20 '23 at 14:55
  • “When I build”. This is not a story, you are looking for precise answers but not providing any details regarding the precise commands you are supposedly issuing. – Richard Barber Jan 21 '23 at 17:50

1 Answers1

0

Your title/post is very confusing, however the issue isn't with cmake. It's with your cblas library and/or your linker. Look at the bug closely:

dyld[5281]: symbol not found in flat namespace (_cblas_caxpy) Abort trap: 6

Your linker is telling you that it can't find a function (symbol) in the given namespace. This is either due to the fact that your linker doesn't know where to find the correct library or you are linking against a wrong version of the library that doesn't have the symbols. The other issues might be related to how the library was built and with what it was built (architecture, compiler, etc...). This we can't answer because we don't have enough information to know for sure.

Milan Š.
  • 1,353
  • 1
  • 2
  • 11
  • Hi Milan - thanks for your answer. What puzzles us is the involvement of flat namespace at all. The project was created as a new project on macOS12 - and the GSL dylib does not use the flat namespace either (was checked with otool). The gsl library (v 2.71.) was installed with homebrew (v.3.6.18). – AnnaMariaL Jan 20 '23 at 17:10
  • Well your linker disagrees with your statement... [Maybe this will guide you further?](https://stackoverflow.com/questions/32277351/what-does-expected-in-flat-namespace-mean) – Milan Š. Jan 20 '23 at 17:27
  • @AnnaMariaL Also if I were you, I would start with fixing your CMake... What you're doing there with the `file(GLOB_RECURSE...` is a sure-fire way on how to get issues like you describe. Take a look [at findGSL](https://cmake.org/cmake/help/latest/module/FindGSL.html) and `find_package()` in general. – Milan Š. Jan 20 '23 at 17:29