Reputation: 11
I'm currently attempting to use FFTW as the backend for Eigen's FFT implementation, which is located in the unsupported section of Eigen. However, I've encountered a compilation error due to linker issues.
In a nutshell, my project has the following directory structure:
project_root
│ CMakeLists.txt
└───src
│ └───ccs
│ │ CMakeLists.txt
│ │ LDPCDecoder.h
│ │ LDPCDecoder.cpp
└───thirdparty
└───fftw
└───...
I'm utilizing Eigen's FFT in LDPCDecoder.cpp.
During compilation, I'm encountering numerous "undefined reference" errors like the following:
[build] LDPC_decoder.cpp:(.text+0x8fa0): undefined reference to `fftwf_execute_dft_r2c'
[build] /usr/bin/ld: LDPC_decoder.cpp:(.text+0x93b1): undefined reference to fftwf_execute_dft_c2r'
[build] /usr/bin/ld: LDPC_decoder.cpp:(.text+0x9a28): undefined reference to fftwf_plan_dft_r2c_1d'
[build] /usr/bin/ld: LDPC_decoder.cpp:(.text+0x9d7e): undefined reference to fftwf_plan_dft_c2r_1d'
[build] collect2: error: ld returned 1 exit status`
I've installed the FFTW library in the thirdparty/fftw directory using the following steps:
./configure --prefix <PathTofftwDirectory>
make
make install
As a result, I now have 'libfftw3.a' located in 'thirdparty/fftw/lib/libfftw3.a.'
Here's the content of the CMakeLists.txt file in the ccs directory:
add_library(ccs
tree_decoder.cpp
tree_decoder.h
tree_encoder.cpp
tree_encoder.h
treecode_generation.h
treecode_generation.cpp
ccs_encoder.h
ccs_decoder.h
SPARCS_encoder.h
SPARCS_encoder.cpp
SPARCS_decoder.h
SPARCS_decoder.cpp
tree_encoder_BPSPARCS.h
tree_encoder_BPSPARCS.cpp
BPSPARCS_encoder.h
BPSPARCS_encoder.cpp
BPSPARCS_decoder.h
BPSPARCS_decoder.cpp
LDPC_decoder.h
LDPC_decoder.cpp
tree_decoder_BPSPARCS.h
tree_decoder_BPSPARCS.cpp
tree_decoder_triadicGraph.h
tree_decoder_triadicGraph.cpp
BPSPARCS_codingParameters.h
BPSPARCS_codingParameters.cpp
)
target_include_directories(ccs
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/thirdparty/aff3ct
${CMAKE_SOURCE_DIR}/thirdparty/fftw/include
)
link_directories(ccs ${CMAKE_SOURCE_DIR}/thirdparty/fftw/lib)
target_link_libraries(ccs
${CMAKE_SOURCE_DIR}/thirdparty/fftw/lib/libfftw3.a
aff3ct-static-lib
)
Does anyone have any ideas on how to resolve these linker errors?
I tried to link the library againts the toplevel executable instead ob the static lib ccs, but this did not fix the error. I also did a clean rebuild of the project and a rebuild of the fftw3lib.a
Upvotes: 1
Views: 34