matthiassars / vanTies

a plugin for VCV Rack
GNU General Public License v3.0
3 stars 1 forks source link

Build failure on macOS platform #6

Closed cschol closed 2 months ago

cschol commented 2 months ago

Multiple compile errors on macOS platform:

x86_64-apple-darwin20.2-clang++-libc++ -std=c++11 -stdlib=libc++  -fPIC -I/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64/include -I/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64/dep/include -MMD -MP -g -O3 -funsafe-math-optimizations -fno-omit-frame-pointer -Wall -We
xtra -Wno-unused-parameter -march=nehalem -mmacosx-version-min=10.9  -c -o build/src/FunsWidget.cpp.o src/FunsWidget.cpp                                                                                                                                                           
In file included from In file included from src/AdjeWidget.cppsrc/Adje.cpp::11:                                                                                                                                                                                                    
:
In file included from In file included from src/Adje.hsrc/Adje.h::55:
:
src/Spectrum.hsrc/Spectrum.h::3131::55::  error: error: implicit instantiation of undefined template 'std::array<int, 32>'implicit instantiation of undefined template 'std::array<int, 32>'

In file included from src/BufkeWidget.cppIn file included from :src/Bufke.cpp1:3:
    prime = {    prime = {

    ^    ^

:
In file included from src/Bufke.hIn file included from :6src/Bufke.h:
:In file included from 6src/Adje.h:
:In file included from 5src/Adje.h:
:5:
src/Spectrum.h:src/Spectrum.h31::315::5 : error: error: implicit instantiation of undefined template 'std::array<int, 32>'implicit instantiation of undefined template 'std::array<int, 32>'

    prime = {
    prime = {    ^

    ^
/home/build/rack-plugin-toolchain/local/osxcross/bin/../SDK/MacOSX11.1.sdk/usr/include/c++/v1/__tuple:219:64: note: template is declared here
/home/build/rack-plugin-toolchain/local/osxcross/bin/../SDK/MacOSX11.1.sdk/usr/include/c++/v1/__tuple:219:64: template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;note: 
template is declared here                                                               ^

template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
/home/build/rack-plugin-toolchain/local/osxcross/bin/../SDK/MacOSX11.1.sdk/usr/include/c++/v1/__tuple:219:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
In file included from In file included from src/Ad.cppsrc/AdWidget.cpp::11:
:
In file included from In file included from src/Ad.hsrc/Ad.h::1212:
:
In file included from In file included from src/AdditiveOscillator.hsrc/AdditiveOscillator.h::33:
In file included from :
src/SpectrumStereo.hIn file included from :src/SpectrumStereo.h2::
2:
cschol commented 2 months ago

Still failing:

In file included from src/AdWidget.cpp:1:                                                                                                                                                                                                                                          
In file included from src/Ad.h:12:                                                                                                                                                                                                                                                 
In file included from src/AdditiveOscillator.h:3:                                                                                                                                                                                                                                  
In file included from src/SpectrumStereo.h:2:                                                                                                                                                                                                                                      
src/Spectrum.h:31:5: error: implicit instantiation of undefined template 'std::array<int, 32>'                                                                                                                                                                                     
    prime = {                                                                                                                                                                                                                                                                      
    ^                                                                                                                                                                                                                                                                              
/home/build/rack-plugin-toolchain/local/osxcross/bin/../SDK/MacOSX11.1.sdk/usr/include/c++/v1/__tuple:219:64: note: template is declared here                                                                                                                                      
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;                                                                                                                                                                                                              
                                                               ^                                                                                                                                                                                                                   
In file included from src/AdWidget.cpp:1:                                                                                                                                                                                                                                          
In file included from src/Ad.h:12:                                                                                                                                                                                                                                                 
In file included from src/AdditiveOscillator.h:3:                                                                                                                                                                                                                                  
src/SpectrumStereo.h:73:5: error: cannot initialize object parameter of type 'Spectrum' with an expression of type 'SpectrumStereo'                                                                                                                                                
    process_tmp();                                                                                                                                                                                                                                                                 
    ^~~~~~~~~~~                                                                                                                                                                                                                                                                    
In file included from src/AdWidget.cpp:1:                                                                                                                                                                                                                                          
In file included from src/Ad.h:12:                                                                                                                                                                                                                                                 
src/AdditiveOscillator.h:76:23: error: cannot initialize object parameter of type 'Spectrum' with an expression of type 'SpectrumStereo'                                                                                                                                           
    int highest = min(spec->getHighest(),                                                                                                                                                                                                                                          
                      ^~~~                                                                                                                                                                                                                                                         
src/AdditiveOscillator.h:104:12: error: cannot initialize object parameter of type 'Spectrum' with an expression of type 'SpectrumStereo'                                                                                                                                          
    wave = spec->getAmp(0) * sine_iMin2 + spec->getAmp(1) * sine_iMin1;                                                                                                                                                                                                            
           ^~~~                                                                                                                                                                                                                                                                    
src/AdditiveOscillator.h:104:43: error: cannot initialize object parameter of type 'Spectrum' with an expression of type 'SpectrumStereo'                                                                                                                                          
    wave = spec->getAmp(0) * sine_iMin2 + spec->getAmp(1) * sine_iMin1;                                                                                                                                                                                                            
                                          ^~~~                                                                                                                                                                                                                                     
src/AdditiveOscillator.h:110:15: error: cannot initialize object parameter of type 'Spectrum' with an expression of type 'SpectrumStereo'                                                                                                                                          
      wave += spec->getAmp(i) * sine_i;                                                                                                                                                                                                                                            
              ^~~~                                                                                                                                                                                                                                                                 
src/AdWidget.cpp:72:12: error: cannot initialize a parameter of type 'engine::Module *' with an lvalue of type 'Ad *'                                                                                                                                                              
        setModule(module);                                                                                                                                                                                                                                                         
                  ^~~~~~                                                                                                                                                                                                                                                           
/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64/include/app/ModuleWidget.hpp:46:33: note: passing argument to parameter 'module' here                                                                                                                                           
        void setModule(engine::Module* module);                                                                                                                                                                                                                                    
                                       ^                                                                                                                                                                                                                                           
src/AdWidget.cpp:84:11: error: no matching function for call to 'createParamCentered'                                                                                                                                                                                              
        addParam(createParamCentered<RoundLargeBlackKnob>(                                                                                                                                                                                                                         
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                          
/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64/include/helpers.hpp:98:15: note: candidate function template not viable: no known conversion from 'Ad *' to 'engine::Module *' for 2nd argument                                                                                 
TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) {                                                                                                                                                                                            
              ^                                                                                                                                                                                                                                                                    
src/AdWidget.cpp:86:11: error: no matching function for call to 'createParamCentered'                                                                                                                                                                                              
        addParam(createParamCentered<RoundLargeBlackKnob>(                                                                                                                                                                                                                         
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                          
/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64/include/helpers.hpp:98:15: note: candidate function template not viable: no known conversion from 'Ad *' to 'engine::Module *' for 2nd argument                                                                                 
TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) {                                                                                                                                                                                            
              ^                                                                                                                                                                                                                                                                    
src/AdWidget.cpp:88:11: error: no matching function for call to 'createParamCentered'                                                                                                                                                                                              
        addParam(createParamCentered<RoundLargeBlackKnob>(                                                                                                                                                                                                                         
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                          
/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64/include/helpers.hpp:98:15: note: candidate function template not viable: no known conversion from 'Ad *' to 'engine::Module *' for 2nd argument                                                                                 
TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) {                                                                                                                                                                                            
              ^                                                                         
matthiassars commented 2 months ago

Hm. 🤔 I made a post in the forum.

baconpaul commented 2 months ago

so on a raw mac it builds fine, which means something in your code is screwing up header interpretation in the toolchain. I have a 242 not a 251 based docker on my mac so can't build it there because of DarkPJ301MPort

I took a quick look at your code and some thoughs

  1. If I had to be I would say it is because you are using namespace std in header files. This is a bad practice for a variety o reasons and makes your code fragile under changing include orders, which is what I think is happening here. Just for general C++ goodness, I'd strongly recommend fixing that.

  2. A good rule of thumb in rack if you do want to do things like that is always make sure you include "rack.hpp" very first. It looks like you might be doing that through your included headers but I'm not 100% sure.

  3. You have a header called "plugin.hpp" which shadows a header in the SDK. I wonder if the wrong one is getting included in mac toolchain builds somehow? That could also be a problem. I think most of us call our slug header Slug.h so in your case vanTies.hpp

Again just some thoughts. Wasn't able to repro the blowout here because i haven't updated my toolchain in a bit.

matthiassars commented 2 months ago

Thanks, @baconpaul !

The new version is in the library. Apparently it works.

Regarding your remarks:

  1. I was told that you can do that when you define your methods inline. But I can move the definition to a .cpp file.
  2. Will check that.
  3. Thanks!

I tried to install the toolkit, but I got stuck there.

baconpaul commented 2 months ago

ha yeah my first guess when reading was "include array but that's already there so it must be something else"

It wasn't something else. Just the problem was fixed and you hadn't updated either community or this issue!

Anyway, using namespace std in headers is a really bad idea. It will seem annoying typing "std::" and "rack::" all the time but you will appreciate it if and as your project scales.

matthiassars commented 2 months ago

Will do that. Thanks for the feedback, @baconpaul ! 🙂

cschol commented 2 months ago

I think this was solved with the latest commit and the additional build failure was an old one.

baconpaul commented 2 months ago

Yeah that’s what happened indeed!