Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on MacOS #237

Open
geoffw64 opened this issue Nov 12, 2024 · 3 comments
Open

Compiling on MacOS #237

geoffw64 opened this issue Nov 12, 2024 · 3 comments

Comments

@geoffw64
Copy link

Hi all,
I'm developing on MacOS 14.4 and Xcode 15. Target is MacOS 14.

I installed the latest stable version of kfr 6 using these commands (I previously installed current versions of cmake and ninja):

cmake -B build-release -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/Users/geoffw/Documents/kfr-main -DCMAKE_CXX_COMPILER=/usr/bin/clang
ninja -C build-release install
cmake -B build-debug -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/Users/geoffw/Documents/kfr-main -DCMAKE_CXX_COMPILER=/usr/bin/clang
ninja -C build-debug install

This appeared to be successful and no errors were produced.
When I try to compile a C++ program, the linker produces this error where I call a filter constructor:
Undefined symbol: kfr::iir_filter::iir_filter(kfr::iir_params<double, 18446744073709551615ul> const&)

Here is the pertinent source code:
#include "kfr/base.hpp"
#include "kfr/dsp/biquad.hpp"
#include "kfr/dsp/biquad_design.hpp"
#include "kfr/dsp/special.hpp"
#include "kfr/io.hpp"
using namespace kfr;
int main() {
std::cout << "Hello world KFR" << std::endl;
univector<fbase, 128> output;
biquad_section bq[] = {
biquad_notch(0.1, 0.5),
biquad_notch(0.2, 0.5),
biquad_notch(0.3, 0.5),
biquad_notch(0.4, 0.5),
};
output = iir(unitimpulse(), iir_params{ bq });
iir_filter EQ_R(bq);
return EXIT_SUCCESS;
}

The code compiles cleanly and runs if I remove the function call.

Is the problem that Xcode doesn't know where kfr was built to? If so, how do I configure that?
Any help would be greatly appreciated.
Best,
Geoff.

@geoffw64
Copy link
Author

Also, my Mac is Intel Core i5.

@dancazarin
Copy link
Member

Hi,
Have you added the kfr_dsp static library to the linker input in Xcode? Xcode (like any other compiler) requires explicit linking to the libraries you use.

@geoffw64
Copy link
Author

I hadn't Dan, thanks.
I'm new to Xcode and overlooked setting up for the linker.
Kudos for the great work you're doing.

In the hope that someone may benefit, here is how I have configured Xcode.
NB: Directory names are my own.

Click on Project Navigator pane and click on project.
Click “Build Settings” button on the ribbon along the top of the screen.
Scroll down to “Search Paths” and open it.
Open the “Library Search Paths:” item.
Add /Users/geoff/Documents/kfr-main/lib/debug to the Debug item.
Add /Users/geoff/Documents/kfr-main/lib to the Release item.
Click "Build Phases" button on the ribbon.
Click on “Link Binary with Libraries”.
Click the “+” symbol.
Click “Add Other” then “Add Files”.
Navigate to “kfr-main” folder and select it.
Select the “lib” folder to reveal the kfr .a library files .
Choose the library files needed for the project. I needed:
libkfr_dsp_sse41.a
libkfr_dsp_avx512.a
libkfr_dsp_avx2.a
libkfr_dsp_avx.a
libkfr_io.a
Click Open.
The dialog will close and the libraries will have been added to the list.
The compiler will now be able to find the libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants