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

Building with cmake/make on macOS and Linux #66

Closed
jkoutavas opened this issue Feb 21, 2018 · 19 comments
Closed

Building with cmake/make on macOS and Linux #66

jkoutavas opened this issue Feb 21, 2018 · 19 comments
Assignees

Comments

@jkoutavas
Copy link
Contributor

jkoutavas commented Feb 21, 2018

Hi. I'm trying to fire-off a cmake on macOS and run immediately into cmake errors. Same goes when I try to fire-off cmake on Debian 9 or CentOS 7. I fire-off the cmake by issuing "cmake ." at the clone's root.

The problems I am seeing are:

On macOS:

  1. The "clangdefaults.cmake" file is missing (work around: do a 'touch cmake/defaults/clangdefaults.cmake')
  2. Get the error "error: /arch:AVX: No such file or directory" (work around: comment out the 'target_compile_options(${proj} PRIVATE /arch:AVX /Zi )' line from cmake/defaults/CXXhelpers)
  3. With both these work-arounds in place, the makefiles get made and I issue a 'make' at the clone's root. I then get 42% into the build and get this compiler error:
[ 42%] Building C object CMakeFiles/libnyquist.dir/third_party/libnyquist/src/VorbisDependencies.c.o
In file included from /Users/jay/dev/repos/heynow/labsound/third_party/libnyquist/src/VorbisDependencies.c:62:
In file included from /Users/jay/dev/repos/heynow/labsound/third_party/libnyquist/third_party/libvorbis/src/vorbisenc.c:155:
/Users/jay/dev/repos/heynow/labsound/third_party/libnyquist/third_party/libvorbis/src/modes/setup_44.h:18:10: fatal error: 
      'modes/floor_all.h' file not found
#include "modes/floor_all.h"
         ^~~~~~~~~~~~~~~~~~~

Seems to me that the cmake didn't set things up fully for the third_party dependencies. What should I be doing differently here? Invoke cmake with some special arguments?

A similar set of problems when building on Linux occur:

  1. The "gccdefaults" file is missing (work around: do a 'touch cmake/defaults/gccdefaults')
  2. Get the error "error: /arch:AVX: No such file or directory" (work around: comment out the 'target_compile_options(${proj} PRIVATE /arch:AVX /Zi )' line from cmake/defaults/CXXhelpers)
  3. With both of these work-arounds in place, the makefiles get made and I issue a 'make' at the clone's root. I then get 11% into the build and get this compiler error:
[ 12%] Building C object CMakeFiles/libopus.dir/third_party/libnyquist/third_party/opus/opusfile/src/info.c.o
In file included from /home/centos/LabSound/third_party/libnyquist/third_party/libogg/include/ogg/ogg.h:25:0,
                 from /home/centos/LabSound/third_party/libnyquist/third_party/opus/opusfile/include/opusfile.h:109,
                 from /home/centos/LabSound/third_party/libnyquist/third_party/opus/opusfile/src/include/internal.h:32,
                 from /home/centos/LabSound/third_party/libnyquist/third_party/opus/opusfile/src/info.c:16:
/home/centos/LabSound/third_party/libnyquist/third_party/libogg/include/ogg/os_types.h:143:32: fatal error: ogg/config_types.h: No such file or directory
 #  include <ogg/config_types.h>

Again, it seems like I'm missing something here using cmake. Or.. is it possible no one has recently done 'make' builds recently on this repository? Please advise, and, THANK YOU for your help.

/Jay

@meshula meshula self-assigned this Feb 22, 2018
@meshula
Copy link
Member

meshula commented Feb 22, 2018

Thanks for the report. I haven't got a linux machine to test with, but I'll get the Mac target up again. PS, I have tested the make generator on Mac, I've been using the Xcode generator.

You mention you are running cmake at the root, however, I wrote the cmake with an out-of-source build in mind. eg, make a build directory as a sister to the LabSound directory, and cmake ../LabSound from within it. In any case, the clangdefaults file is as you say, missing....

@meshula
Copy link
Member

meshula commented Feb 22, 2018

I pushed cmake fixes that correct the erroneous MSVC flag settings you encountered, as well as the libvorbis issue. I didn't encounter the libogg issue on Mac, however, the CoreAudio framework isn't linked yet, so there's a bit more to do.

The Linux target hasn't been completed, although the RtAudio backend for Windows could be used as a first step in that direction.

@meshula
Copy link
Member

meshula commented Feb 24, 2018

The mac build succeeds now using cmake with the xcode generator.
@jkoutavas, could you try again and report a result?

@meshula
Copy link
Member

meshula commented Feb 24, 2018

To get past the error you encountered, you'll need to replace the chunk that reads

#include <ogg/config_types.h>

with

#include <inttypes.h>
typedef int16_t ogg_int16_t;
typedef uint16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;
typedef uint32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;

@ddiakopoulos, this issue is at the libnyquist end. Shall we add a UNIX chunk to ogg/os_types.h with the above patch?

@avaer
Copy link

avaer commented Feb 24, 2018

FWIW the way I fixed this error was including libogg source and ran ./configure to generate that ogg/config_types.h.

@jkoutavas
Copy link
Contributor Author

jkoutavas commented Feb 24, 2018

With this morning's pull, I'm able to get 100% through compiling on Darwin using cmake/make, but did hit a linker error.

[100%] Linking CXX executable bin/example
ld: warning: text-based stub file /System/Library/Frameworks//AudioToolbox.framework/AudioToolbox.tbd and library file /System/Library/Frameworks//AudioToolbox.framework/AudioToolbox are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
  "vtable for nqr::ModplugDecoder", referenced from:
      nqr::NyquistIO::BuildDecoderTable() in liblibnyquist.a(AudioDecoder.cpp.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "_mlp_process", referenced from:
      _tonality_analysis in liblibopus.a(analysis.c.o)
  "_net", referenced from:
      _tonality_analysis in liblibopus.a(analysis.c.o)
  "_silk_A2NLSF", referenced from:
      _silk_A2NLSF_FLP in liblibopus.a(wrappers_FLP.c.o)
     (maybe you meant: _silk_A2NLSF_FLP)
  "_silk_NSQ", referenced from:
      _silk_NSQ_wrapper_FLP in liblibopus.a(wrappers_FLP.c.o)
     (maybe you meant: _silk_NSQ_wrapper_FLP)
  "_silk_NSQ_del_dec", referenced from:
      _silk_NSQ_wrapper_FLP in liblibopus.a(wrappers_FLP.c.o)
  "_silk_VAD_GetSA_Q8", referenced from:
      _silk_encode_do_VAD_FLP in liblibopus.a(encode_frame_FLP.c.o)
  "_silk_VAD_Init", referenced from:
      _silk_init_encoder in liblibopus.a(init_encoder.c.o)
  "_silk_biquad_alt", referenced from:
      _silk_LP_variable_cutoff in liblibopus.a(LP_variable_cutoff.c.o)
  "_silk_control_audio_bandwidth", referenced from:
      _silk_control_encoder in liblibopus.a(control_codec.c.o)
  "_silk_encode_pulses", referenced from:
      _silk_Encode in liblibopus.a(enc_API.c.o)
      _silk_encode_frame_FLP in liblibopus.a(encode_frame_FLP.c.o)
  "_silk_interpolate", referenced from:
      _silk_find_LPC_FLP in liblibopus.a(find_LPC_FLP.c.o)
  "_silk_process_NLSFs", referenced from:
      _silk_process_NLSFs_FLP in liblibopus.a(wrappers_FLP.c.o)
     (maybe you meant: _silk_process_NLSFs_FLP)
  "_silk_quant_LTP_gains", referenced from:
      _silk_quant_LTP_gains_FLP in liblibopus.a(wrappers_FLP.c.o)
     (maybe you meant: _silk_quant_LTP_gains_FLP)
  "_silk_resampler_down2", referenced from:
      _silk_pitch_analysis_core_FLP in liblibopus.a(pitch_analysis_core_FLP.c.o)
  "_silk_resampler_down2_3", referenced from:
      _silk_pitch_analysis_core_FLP in liblibopus.a(pitch_analysis_core_FLP.c.o)
  "_silk_stereo_find_predictor", referenced from:
      _silk_stereo_LR_to_MS in liblibopus.a(stereo_LR_to_MS.c.o)
  "_silk_stereo_quant_pred", referenced from:
      _silk_stereo_LR_to_MS in liblibopus.a(stereo_LR_to_MS.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/example] Error 1
make[1]: *** [CMakeFiles/example.dir/all] Error 2
make: *** [all] Error 2

@avaer
Copy link

avaer commented Feb 24, 2018

@meshula
Copy link
Member

meshula commented Feb 24, 2018

@modulesio, I feel the glob, thanks for the suggestion :) I've copied your patch in. 5427ebf

Since your directory structure has changed, I couldn't spot a way to cherrypick the fix without adopting the modified directory structure...

@jkoutavas, I did add those files to the cmake script, perhaps your cmake cache didn't get regenerated?

Perhaps clean out your cmake build directory, and regenerate the cache using the latest patch from modulesio.

@jkoutavas
Copy link
Contributor Author

@meshula, I see you merged-in @modulesio's latest changes. This morning, I updated to that, wiped-out my build directory and ran cmake ../labsound; make on my macOS 10.12.16 system. Build got to 49% before failing:

[ 49%] Building CXX object CMakeFiles/libnyquist.dir/third_party/libnyquist/src/ModplugDependencies.cpp.o
In file included from /Users/jay/dev/repos/oppop/labsound/third_party/libnyquist/src/ModplugDependencies.cpp:91:
/Users/jay/dev/repos/oppop/labsound/third_party/libnyquist/third_party/libmodplug/src/fastmix.cpp:678:2: error: 
      ISO C++1z does not allow 'register' storage class specifier [-Wregister]
        SNDMIX_BEGINSAMPLELOOP8

@jkoutavas jkoutavas changed the title Building with CMake on macOS or Linux Building with cmake/make on macOS or Linux Feb 25, 2018
@jkoutavas jkoutavas changed the title Building with cmake/make on macOS or Linux Building with cmake/make on macOS and Linux Feb 25, 2018
@jkoutavas
Copy link
Contributor Author

jkoutavas commented Feb 25, 2018

I'd like to humbly suggest that the CI test for passing a Mac build should include a cmake/make build too (not just a cmake/xcodebuild)

And of course, when things are working, add a linux cmake/make build to the CI too.

@meshula
Copy link
Member

meshula commented Feb 25, 2018

@jkoutavas Good suggestion on testing with cmake/make. the 'register' issue you're running into tells me that you are running an up to date tool chain on mac, which I don't have here, and can't upgrade quickly.

Would you mind attempting a fix? I believe that if you add the following


#ifdef __clang__
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif

to

libniyquist/third_party/libmodplug/src/stdafx.h

you'll get past the issue you have reported. If this works, we can patch it in.

@jkoutavas
Copy link
Contributor Author

you'll get past the issue you have reported. If this works, we can patch it in.

Alas, it did not make a difference.

I wonder if the solution is to have it build specifically for C++11?

@meshula
Copy link
Member

meshula commented Feb 25, 2018

That would be fine, I think, if it works.

@jkoutavas
Copy link
Contributor Author

That would be fine, I think, if it works.

I'll take a stab at that, and hopefully open a PR for it.

@jkoutavas
Copy link
Contributor Author

jkoutavas commented Feb 26, 2018

Okay, I lowered the bar to C++11, see 26144eb that helped. It's a commit on my open PR #71. The

#ifdef __clang__
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif

is not needed now.

Now we're at 61%...:

[ 61%] Building CXX object CMakeFiles/libnyquist.dir/third_party/libnyquist/third_party/libmodplug/src/load_abc.cpp.o
/Users/jay/dev/repos/oppop/LabSound/third_party/libnyquist/third_party/libmodplug/src/load_abc.cpp:260:13: error: static declaration of 'setenv' follows
      non-static declaration
static void setenv(const char *name, const char *value, int overwrite)

@jkoutavas
Copy link
Contributor Author

Yay! With the latest commit, 49e0d79, macOS cmake/make builds to 100%. Nice work!

@jkoutavas
Copy link
Contributor Author

Linux build, with latest commit is at 13%:

[ 13%] Building C object CMakeFiles/libopus.dir/third_party/libnyquist/third_party/opus/opusfile/src/http.c.o
In file included from /home/centos/LabSound/third_party/libnyquist/third_party/libogg/include/ogg/ogg.h:25:0,
                 from /home/centos/LabSound/third_party/libnyquist/third_party/opus/opusfile/include/opusfile.h:109,
                 from /home/centos/LabSound/third_party/libnyquist/third_party/opus/opusfile/src/include/internal.h:32,
                 from /home/centos/LabSound/third_party/libnyquist/third_party/opus/opusfile/src/http.c:16:
/home/centos/LabSound/third_party/libnyquist/third_party/libogg/include/ogg/os_types.h:143:32: fatal error: ogg/config_types.h: No such file or directory
 #  include <ogg/config_types.h>

@meshula
Copy link
Member

meshula commented Feb 26, 2018

Earlier, @modulesio reported this fix, but I haven't had time to look into it further:

FWIW the way I fixed this error was including libogg source and ran ./configure to generate that ogg/config_types.h.

Maybe this needs to be an additional step in the cmake script.

@meshula
Copy link
Member

meshula commented Sep 10, 2018

Closing this, as cmake works now for macos reliably via xcode or make, CI is showing green. Feel free to open a new issue to add a cmake/make build for CI.

@meshula meshula closed this as completed Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants