I am writing a test for a Biquad Filter class I have written in C++, and I am attempting to use to FFTWPP header to simplify the use of the FFTW library. I have successfully built and run the FFTWPP examples, so I can be sure that the FFTW3 library is successfully built and installed on my Mac (running OS Catalina 10.15.5 (19F101)).
I have managed to include the FFTW lib directory into the cmake project definitions, and I have added the appropriate include paths into the CMAKE file:
cmake_minimum_required(VERSION 3.16)
project(IIR)
set(CMAKE_CXX_STANDARD 14)
find_package(Python 3.7 COMPONENTS Development) # Used for MatplotlibPP
include_directories(.)
include_directories(./../../../fftwpp/)
include_directories(./../../../fftw-3.3.8/api/)
include_directories(./../../../matplotlib-cpp/) #Plotting
include_directories(./../../../AudioFile/) #AudiofileIO
include_directories(/usr/local/include) # contains includes for FFTW3
link_directories(.)
link_directories(/usr/local/lib)# contains binary for FFTW3
find_library(
fftw3
NAMES fftw lfftw3 libfftw3
HINTS /usr/local/lib
)
add_executable(IIR
Test_BiquadFilter.cpp)
target_link_libraries(IIR PUBLIC Python fftw3)
However, it appears the linker is failing to link the symbols through the FFTWPP header:
[100%] Linking CXX executable IIR
Undefined symbols for architecture x86_64:
"fftwpp::ThreadBase::ThreadBase()", referenced from:
fftwpp::fftw::fftw(unsigned int, int, unsigned int, unsigned int) in Test_BiquadFilter.cpp.o
"fftwpp::fftw::maxthreads", referenced from:
_main in Test_BiquadFilter.cpp.o
fftwpp::fftw::Setup(std::__1::complex<double>*, std::__1::complex<double>*) in Test_BiquadFilter.cpp.o
"fftwpp::fftw::testseconds", referenced from:
fftwpp::fftw::time(fftw_plan_s*, fftw_plan_s*, std::__1::complex<double>*, std::__1::complex<double>*, unsigned int) in Test_BiquadFilter.cpp.o
"fftwpp::fftw::effort", referenced from:
fftwpp::rcfft1d::Plan(std::__1::complex<double>*, std::__1::complex<double>*) in Test_BiquadFilter.cpp.o
fftwpp::crfft1d::Plan(std::__1::complex<double>*, std::__1::complex<double>*) in Test_BiquadFilter.cpp.o
"fftwpp::fftw::planner", referenced from:
fftwpp::fftw::Setup(std::__1::complex<double>*, std::__1::complex<double>*) in Test_BiquadFilter.cpp.o
"fftwpp::inout", referenced from:
fftwpp::fftw::Setout(std::__1::complex<double>*, std::__1::complex<double>*) in Test_BiquadFilter.cpp.o
"fftwpp::crfft1d::threadtable", referenced from:
fftwpp::crfft1d::lookup(bool, unsigned int) in Test_BiquadFilter.cpp.o
fftwpp::crfft1d::store(bool, fftwpp::threaddata const&) in Test_BiquadFilter.cpp.o
"fftwpp::rcfft1d::threadtable", referenced from:
fftwpp::rcfft1d::lookup(bool, unsigned int) in Test_BiquadFilter.cpp.o
fftwpp::rcfft1d::store(bool, fftwpp::threaddata const&) in Test_BiquadFilter.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Should I be linking the FFTW library against FFTWPP and be building that as its own library, and then link that library against my project?
I know I have probably added some extra parts to the Cmake project unnecessarily, but is my CMake configuration otherwise incorrect for another reason, when linking a library this way?
Many thanks,
The answer to my issues as kindly pointed out by a commenter to the original post, was that I was not linking against FFTWPP.
The solution in this was to add FFTWPP as a library to the project, and add that library to the list of target linked libraries.
link_directories(./../../../fftwpp/)
find_library(
fftw3
NAMES fftw lfftw3 libfftw3
HINTS /usr/local/lib
)
add_library(fftwpp STATIC ./../../../fftwpp/fftw++.cc)
add_executable(IIR
Test_BiquadFilter.cpp)
target_link_libraries(IIR PUBLIC Python fftw3 fftwpp)
Related
I'm trying to compile https://github.com/dmikushin/binance-cxx-api on osx 10.13.6
(since code is written for linux i had to adjust things a little)
I get following errors (which are openssl related as far as i see):
Undefined symbols for architecture x86_64:
"_EVP_sha256", referenced from:
binance::hmac_sha256(char const*, char const*) in binance_utils.cpp.o
"_HMAC", referenced from:
binance::hmac_sha256(char const*, char const*) in binance_utils.cpp.o
"_SHA256_Final", referenced from:
binance::sha256(char const*) in binance_utils.cpp.o
"_SHA256_Init", referenced from:
binance::sha256(char const*) in binance_utils.cpp.o
"_SHA256_Update", referenced from:
binance::sha256(char const*) in binance_utils.cpp.o
ld: symbol(s) not found for architecture x86_64
The project is cmake based and does not find or link against openssl (installed with homebrew)
I added include and lib dirs directly in the cmake GUI -> compiler, linker flag
(took the include dir, still gave me the errors)
Also applied several combinations of below and alike => didn't make the error go away
cmake -DOPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl/1.0.2d_1/include -DOPENSSL_CRYPTO_LIBRARY=/usr/local/Cellar/openssl/1.0.2d_1/lib/libcrypto.dylib -DOPENSSL_SSL_LIBRARY=/usr/local/Cellar/openssl/1.0.2d_1/lib/libssl.dylib
googling did not bring up new ideas (most of these errors seem to be fixed by the cmake -DOPENSSL.. option)
Does anyone have an idea?
Did you consider editing the cmake project ?
Adding the following lines in the CMakeLists.txt:
FIND_PACKAGE(OpenSSL)
if(${OpenSSL_FOUND})
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
endif()
And editing the following line to link to OpenSSL
target_link_libraries(${PROJECT_NAME} jsoncpp curl websockets ssl crypto)
I'm trying to create a project that uses the Boost library. I'm on OS X 10.9.5 (I should update that) and using Xcode 6.2. I installed boost with homebrew brew install boost and it's located in /usr/local/Cellar/boost/1.59.0. I added the path the the /usr/local/Cellar/boost/1.59.0/include to the header search path in Xcode and it seems to recognize it because the autocomplete hinting works.
In the boost documentation it mentions that some of the Boost libraries must be built before they can be used. I assume homebrew took care of that because I have a bunch of .a and .dylib files in /usr/local/Cellar/boost/1.59.0/lib
I'm still new to C++ and the Xcode build process but it seems I still need to link the compiled libraries to my project. I tried adding the path /usr/local/Cellar/boost/1.59.0/lib to my project's library search paths but I'm not sure if that is correct.
Here is the error I get when I try to build my project.
Undefined symbols for architecture x86_64:
"boost::filesystem::detail::create_directory(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
boost::filesystem::create_directory(boost::filesystem::path const&) in main.o
"boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
boost::filesystem::exists(boost::filesystem::path const&) in main.o
"boost::system::system_category()", referenced from:
___cxx_global_var_init2 in main.o
"boost::system::generic_category()", referenced from:
___cxx_global_var_init in main.o
___cxx_global_var_init1 in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there something else I need to configure to get this to work?
Adding the path is correct but you also need to specify the libraries you need. On the commandline you would use -l for that in Xcode you can add them to Other Linker Flags.
The libraries you need are boost_filesystem and boost_system.
So I'm trying to build a program using OpenGL and GLFW. The only errors I'm getting are:
Undefined symbols for architecture x86_64:
"_glewInit", referenced from:
_main in main.o
"_glfwCreateWindow", referenced from:
_main in main.o
"_glfwGetKey", referenced from:
_main in main.o
"_glfwInit", referenced from:
_main in main.o
"_glfwMakeContextCurrent", referenced from:
_main in main.o
"_glfwPollEvents", referenced from:
_main in main.o
"_glfwSetInputMode", referenced from:
_main in main.o
"_glfwSwapBuffers", referenced from:
_main in main.o
"_glfwTerminate", referenced from:
_main in main.o
"_glfwWindowHint", referenced from:
_main in main.o
"_glfwWindowShouldClose", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So obviously this is a linking error. After doing some research, I think I found my error. It seems like I need to add the GLFW library (libglfw.dylib) and the Cocoa and OpenGL libraries. My problem is that I can't find libglfw.dylib - or anything glfw for that matter - under the "Link Binary With Libraries" section. I found OpenGL.framework and Cocoa.framework, but I can't find the glfw one. I tried going through the whole cmake process (cmake > make > sudo make install) for glfw but it didn't show up. I then tried installing using brew and that didn't work either. I can't figure out why I can't find this file. Any ideas? This is my first time doing anything with GLFW and one of my first projects doing any coding on OSX. If I'm forgetting any information you need to help let me know and I'll get it to you all as fast as I can.
First of all, using GLEW on OS X is 100% pointless (OpenGL extensions are all handled statically at link-time on this platform). You should add some code to your project that does something along the lines of:
#ifndef __APPLE__
// GLEW-specific code here
#endif
Also, .dylib is for dynamically linking - there's not much point in doing that on OS X. GLFW is not distributed in the form of a Framework, you'll have to compile it yourself. You can still use a dynamic linking version of GLFW if you wish, but you'd wind up having to package the library in your .app bundle. I would advise you just use the static version and avoid all of that.
Have you reviewed the OS X section of the GLFW compilation instructions?
I've been trying to run make on the recent release of openCV (2.4.3) but I've been having problems. I've created a build folder in the openCV directory and ran the following commands:
cmake -G "Unix Makefiles" ..
make -js
I get the following error:
Linking CXX shared library ../../lib/libopencv_highgui.dylib
[ 35%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gaussmix.cpp.o
Undefined symbols for architecture x86_64:
"_ModPlug_GetCurrentOrder", referenced from:
_modplug_read_packet in libavformat.a(libmodplug.o)
"_ModPlug_GetCurrentPattern", referenced from:
_modplug_read_packet in libavformat.a(libmodplug.o)
"_ModPlug_GetCurrentRow", referenced from:
_modplug_read_packet in libavformat.a(libmodplug.o)
"_ModPlug_GetCurrentSpeed", referenced from:
_modplug_read_packet in libavformat.a(libmodplug.o)
"_ModPlug_GetCurrentTempo", referenced from:
_modplug_read_packet in libavformat.a(libmodplug.o)
"_ModPlug_GetLength", referenced from:
_modplug_read_header in libavformat.a(libmodplug.o)
"_ModPlug_GetMessage", referenced from:
_modplug_read_header in libavformat.a(libmodplug.o)
"_ModPlug_GetName", referenced from:
_modplug_read_header in libavformat.a(libmodplug.o)
There's more but the rest of the message is the similar to that.
It looks like the linker is having a hard time with highgui.
I've received a similar error when I (somehow miraculously) had openCV installed previously (I deleted the former installation) when trying to run code using XCode
Any thoughts?
I don't know the cause of this particular problem. However, I found a workaround that works for my situation. I disabled ffmpeg and it seems to compile ok. I cleaned out my build directory and ran cmake with the option -DWITH_FFMPEG=OFF
I am trying to compile some stuff under mac os 10.7 in eclipse and the build dies on:
Undefined symbols for architecture x86_64:
"_kCFAllocatorDefault", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFURLCreateWithFileSystemPath", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFStringCreateWithCString", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFBundleCreate", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFBundleGetFunctionPointerForName", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFRelease", referenced from:
___GLeeGetProcAddress in GLee.o
"_glGetString", referenced from:
___GLeeGetExtensions in GLee.o
_GLeeGetExtStrGL in GLee.o
_GLeeInit in GLee.o
(maybe you meant: _GLee_Lazy_glGetStringi, _GLeeFuncPtr_glGetStringi )
"___CFConstantStringClassReference", referenced from:
CFString in GLee.o
So I know the problem is with ld symbols. Now I tried going to project proprieties and adding -framework CoreFramework to parameters of g++ and gcc in eclipse but that didnt fix it.
Where are these symbols located and more importantly - how do I add them to my project?
I fixed this by adding a .dylib to linker. How to set it up?
Go to project proprieties
Go to C/C++ build --> settings
Choose Mac OS X C++ Linker --> Libraries
Here is where the tricky part is... I found out by "try-error" method, how this works:
Lets say you have a dylib file you want to add called "libMyLib.dylib" located in /opt/local/lib/MyLibrary
To part of the window where it says libraries add line
"MyLib"
To part of the window where it says Library search path add line
"/opt/local/lib/MyLibrary/"
=> eclipse will automatically do this:
1. add "lib" in front of the string
2. add ".dylib" after your string
There comes another problem with Mac... Lets say you use symbols from CoreFoundation framework. Mac OS frameworks are essentialy dylibs with header files ... If you are not sure you can always check by "file myFile"
The problem is that eclipse will never correctly pick up on those dylibs from MAC OS SDK and /System/Library/Frameworks/ cause they dont have the .dylib added to them. The trick is to simply go to where the dylib is located (eventhough it doesnt have a .dylib in its name) e.g.
cd /System/Library/Frameworks/CoreFoundation.framework
and then copy the file and add dylib (do NOT RENAME IT!!!)
file CoreFoundation
CoreFoundation (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
CoreFoundation (for architecture i386): Mach-O dynamically linked shared library i386
#copy the lib and name it to "eclipse friendly format"
cp CoreFoundation libCoreFoundation.dylib
You can use the -framework option
e.g. g++ -framework CoreFoundation ..........