mbrucher / AudioTK

An audio digital processing toolbox based on a workflow/pipeline principle
https://github.com/AudioTK/AudioTK
BSD 3-Clause "New" or "Revised" License
251 stars 37 forks source link

Linux compilation issues #4

Closed SpotlightKid closed 8 years ago

SpotlightKid commented 8 years ago

I had to jump through a few hoops to manage to get AudioTK compiled on Arch Linux with GCC 5.3.0. Here's what I did to successfully compile:

patch -p1 -N -r - -i exp-cstddef.patch

rm -rf build
mkdir build
cd build
cmake -DCMAKE_CXX_FLAGS="-std=c++11" \
      -DENABLE_PYTHON=1 \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DENABLE_TESTS=0 \
      ..
make

The exp-cstdef.patch:

diff --git a/ATK/Utility/exp.cpp b/ATK/Utility/exp.cpp
index 5447602..9af5802 100644
--- a/ATK/Utility/exp.cpp
+++ b/ATK/Utility/exp.cpp
@@ -4,6 +4,7 @@

 #include <ATK/Utility/exp.h>

+#include <cstddef>
 #include <cmath>

 namespace ATK

Without this patch I get this error:

<...>/AudioTK/ATK/Utility/exp.cpp:29:5: error: 'size_t' was not declared in this scope

When enabling tests I get the following error:

<...>/AudioTK/tests/IO/libsndfile/InSndFileFilter.cpp:9:21: fatal error: ATK/git.h: No such file or directory
mbrucher commented 8 years ago

Interesting for the first one... It should now be fixed. The second failure is due to the fact that I don't test libsndfile, as I don't use it that often. The tests for libsndfile will fail because it won't find the files at the location (ATK_SOURCE_TREE won't be defined). At least the compilation is now OK.

SpotlightKid commented 8 years ago

Here's the rationale for the patch:

https://gcc.gnu.org/gcc-4.6/porting_to.html

You should also probably add something like this to CMakeLists.txt

if(UNIX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c+11")
endif()
mbrucher commented 8 years ago

Indeed, thanks for the link. I'm still thinking about what to do with the C++11 stuff. By default, GCC know targets C++14, so I should be covered, ans I may use some features there (when GCC, VS and XCode support them). Thanks for the feedback!

SpotlightKid commented 8 years ago

I still get the following error when I enable tests (latest develop branch version):

<...>/audiotk-git/src/audiotk/tests/Distortion/SimpleOverdriveFilter.cpp:6:21: fatal error: ATK/git.h: No such file or directory

When I remove #include <ATK/git.h> from tests/Distortion/SimpleOverdriveFilter.cpp and pass -DCMAKE_BUILD_TYPE=Release to cmake, compilation finishes without error.

diff --git a/tests/Distortion/SimpleOverdriveFilter.cpp b/tests/Distortion/SimpleOverdriveFilter.cpp
index 61f16cd..24f1397 100644
--- a/tests/Distortion/SimpleOverdriveFilter.cpp
+++ b/tests/Distortion/SimpleOverdriveFilter.cpp
@@ -3,7 +3,6 @@
  */

 #include <ATK/config.h>
-#include <ATK/git.h>

 #include <ATK/Distortion/SimpleOverdriveFilter.h>

If I do not set the build type to "Release", compilation fails with:

<...>/audiotk-git/src/audiotk/ATK/Distortion/DiodeClipperFilter.cpp: In member function 'void ATK::DiodeClipperFilter<DataType_>::process_impl(int64_t) const':
<...>/audiotk-git/src/audiotk/ATK/Distortion/DiodeClipperFilter.cpp:125:4: error: 'nb_input_ports' was not declared in this scope
     assert(nb_input_ports == nb_output_ports);

and a couple more errors about asserts with undefined variables at other place in this file.

mbrucher commented 8 years ago

Yeah, there must be some remaining git.h include commands, and as the file still exists in my configurations, the issue doesn't show up for me. I'll try to start from scratch on Tuesday.

mbrucher commented 8 years ago

I've removed all the asserts (that are actually useless), and removed the git.h include. The issue there is that the test is only compiled with libsndfile, which I don't usually do :/

SpotlightKid commented 8 years ago

Except for still needing to add -std=c++1 to the CXXFLAGS, all compilation issues seem to be fixed now.

For reference, here's the build procedure I currently use on Linux:

BUILD_TYPE="Release"
PY_VER=$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])')

rm -rf build
mkdir build
cd build
cmake .. \
  -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
  -DCMAKE_CXX_FLAGS="-std=c++11" \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DENABLE_PYTHON=1 \
  -DPYTHON_INSTALL_FOLDER=/usr/lib/python${PY_VER} \
  -DENABLE_TESTS=1
LC_ALL=C make
SpotlightKid commented 8 years ago

Here's a link to my Arch Linux AUR package:

https://aur.archlinux.org/packages/audiotk-git/

mbrucher commented 8 years ago

Thanks a lot! I'll fix the other issues today. I won't add the C++11 flag, as all the main compilers compile at least in C++11 mode.

SpotlightKid commented 8 years ago

Well, GCC from version 5 onward always needs this option to support C++11 features.

See https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Standards.html#Standards. Section 2.2 "C++ Language" states:

The default, if no C++ language dialect options are given, is -std=gnu++98.

mbrucher commented 8 years ago

Indeed... I would need to add some checks on the gcc version,a s GCC will be C++14 by default. I guess I must have ended up of GCC 6 page, and not GCC 5 when I looked for the default value. Makes no sense that GCC 5 isn't using C++11 though. But that's another topic ;)

SpotlightKid commented 8 years ago

CMake >= 2.8.8 has a CMAKE_CXX_COMPILER_VERSION variable:

https://cmake.org/cmake/help/v3.5/manual/cmake-generator-expressions.7.html?highlight=cmake_cxx_compiler_version

https://cmake.org/pipermail/cmake/2012-January/048596.html