tracktion_engine icon indicating copy to clipboard operation
tracktion_engine copied to clipboard

[Bug]: Tracktion Engine Won't Compile With Projucer in XCode

Open dmann200 opened this issue 11 months ago • 16 comments

Detailed steps on how to reproduce the bug

I've been trying for several days to get tracktion_engine to compile using Projucer. I'm on Max OS X 15.3. I'm trying to build an Xcode project which is a static framework. I mainly need the functionality of the tracktion_engine class. C++17 version.

I wish I could say that there was one error but there are many. Firstly, it did not include tracktion_core by default which I had to add manually. It complains about many missing files, but as soon as I supply one, it complains about another.

Tracktion2025-3 - App /Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_NodePlayer.h /Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_NodePlayer.h:80:62 No viable conversion from 'juce::Range<int64_t>' (aka 'Range') to 'int64_t' (aka 'long long')

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.h /Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.h:26:38 No type named 'floating_point' in namespace 'std'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.h:42:12 No matching constructor for initialization of 'juce::Range<int64_t>' (aka 'Range')

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.h:42:14 No matching function for call to 'timeToSample'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.h:43:14 No matching function for call to 'timeToSample'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.h:50:41 Member reference base type 'double' is not a structure or union

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.cpp /Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.cpp:34:31 No matching function for call to 'timeToSample'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/tracktion_graph/tracktion_Utility.cpp:51:31 No matching function for call to 'timeToSample'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/utilities/tracktion_GlueCode.h /Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/utilities/tracktion_GlueCode.h:35:56 No type named 'integral' in namespace 'std'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_graph/utilities/tracktion_GlueCode.h:35:82 No type named 'integral' in namespace 'std'

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_core/utilities/tracktion_Maths.h /Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_core/utilities/tracktion_Maths.h:13:22 Inline nested namespace definition is a C++20 extension

I've also tried building with CMake and this was unsuccessful. These are the errors I got: running cmake on modules/cmakelists.txt failed with error: CMake Error at CMakeLists.txt:24 (juce_add_modules): Unknown CMake command "juce_add_modules".

tried cmake on modules/juce and got many errors mainly: CMake Error at extras/Build/juceaide/CMakeLists.txt:157 (message): Failed to build juceaide [ 9%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/Main.cpp.o In file included from /Users/admin/tracktion_engine/modules/juce/extras/Build/juceaide/Main.cpp:35:

It is my understanding that Projucer should automatically supply the files that are needed and create the proper configuration. What am I doing wrong here?

By the way I'm happy to compensate any developer a healthy rate who wants to jump onboard and help get this thing compiled.

What is the expected behaviour?

I expect that when I build the project after generating it with Projucer there will be no errors.

Unit test to reproduce the error?

Sorry I don't have a unit test.

Operating systems

macOS

What versions of the operating systems?

10.15

Architectures

ARM

Stacktrace


Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

None

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • [x] I agree to follow the Code of Conduct

dmann200 avatar Mar 04 '25 18:03 dmann200

I replied to this on the juce forum but as I mentioned there, the first thing to try is to use C++20 as that's the minimum version supported by the engine.

drowaudio avatar Mar 05 '25 10:03 drowaudio

Thanks. I already did that but still having many issues.

dmann200 avatar Mar 05 '25 15:03 dmann200

Also it seems that it is not exporting the choc library.

/Users/admin/Documents/Programming/Xcode/Prototype/Tracktion2025-2/JuceLibraryCode/modules/tracktion_core/audio/tracktion_AudioReader.h:16:11 '../../3rd_party/choc/audio/choc_SampleBuffers.h' file not found

dmann200 avatar Mar 05 '25 15:03 dmann200

Have you checked the file is there in that relative path?

Are you using cmake now?

It sounds like you haven't added the module correctly? juce_add_module

Have you tried building and running the demo runner example in tracktion_engine first?

drowaudio avatar Mar 05 '25 18:03 drowaudio

I'm primarily using Projucer->XCode. When I add the module using Projucer, I have three modules available tracktion_core, tracktion_graph, and tracktion_engine all of which are added in Projucer.

Regarding whether the files are in the path I am not clear what the absolute path is for this "../../3rd_party/choc/audio/choc_SampleBuffers.h' file not found" The two instances of ".." indicate we move up two subdirectories but from what starting path? Is that the root of the xcode project? Is it the location of the .h file which has the include statement? This "3rd_party" folder exists in many locations throughout tracktion so it is unclear which 3rd_party folder they are referring to.

Regarding the demo runner, it currently does not compile if I run "cmake cmakelists.txt" from "tracktion_engine/examples". Even if I force cmake to use c++20 I get this build error:

Adding Benchmarks to the Project project -- Not building with VST2 CMake Error at Benchmarks/CMakeLists.txt:35 (juce_add_console_app): Unknown CMake command "juce_add_console_app".

When I attempt to build with cmake, "tracktion_engine/cmakelists.txt" I also get numerous errors but different ones relating to "juceaid": CMake Error at modules/juce/extras/Build/juceaide/CMakeLists.txt:157 (message): Failed to build juceaide

[ 9%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/Main.cpp.o

In file included from /Users/admin/tracktion_engine/modules/juce/extras/Build/juceaide/Main.cpp:35:

dmann200 avatar Mar 05 '25 20:03 dmann200

For C/C++ includes, they are relative to the current file. That’s standard.

For running the examples, it sounds like you might not have done a recursive git clone so juce isn’t found in tracktion_engine/modules/juce?

Finally, you usually run cmake from the root of the project and it creates all the targets in the project for you. For example, running it in the root of this repo will create an IDE project with the DemoRunner, TestRunner, Benchmarks and EngineInPluginDemo (various plugin format) targets. You’d then build and run the DemoRunner target.

drowaudio avatar Mar 05 '25 21:03 drowaudio

I believe I did do a recursive clone. As you can see the specific Main.cpp file exists here: Image

dmann200 avatar Mar 05 '25 21:03 dmann200

How are the choc files and other 3rd party files supposed to get copied into the xcode project folder from Projucer? This is what my projucer project looks like: Image

dmann200 avatar Mar 05 '25 21:03 dmann200

They’re just header files so are just included. There are ifdefs to use the locally provided or system provided files to avoid conflicts if you’re using choc in your own project.

Maybe try doing a fresh clone and cmake build of the examples? This is run constantly on CI so should work.

git clone --recurse-submodules [email protected]:Tracktion/tracktion_engine.git
cd tracktion_engine
cmake -G Xcode -B build

drowaudio avatar Mar 05 '25 22:03 drowaudio

I'll reiterate that you should use cmake but in your above Projucer report, you're not using the "copy source files" option are you? I've no idea how that is supposed to work. It's a very atypical behaviour.

Cmake is a much better build system.

drowaudio avatar Mar 05 '25 22:03 drowaudio

I've tried it with "copy source files" on and with "copy source files" off. Fails in both cases, just with slightly different error messages. As you seem to know this framework pretty well would you like a paid gig helping me get this to compile?

dmann200 avatar Mar 06 '25 03:03 dmann200

I'm on of the authors of the framework so yes, know it very well. But unfortunately I don't any free time right now to aid setup.


Did you try running the above commands? I'll re-iterate them here (with some minor modifications for speed). Can you open a Terminal, make a tmp dir and cd in to it then just copy/paste the following:

git clone --branch develop --depth 1 --recurse-submodules [email protected]:Tracktion/tracktion_engine.git
cd tracktion_engine
cmake -G Xcode -B build

That should give you a build/tracktion.xcode project you can open, choose a target (e.g. DemoRunner), build and run it.

Does that work? I need to know if you can get that far to determine if the problem is with your dev environment, cloning of tracktion_engine or integrating in to your own project. This is the first step.

drowaudio avatar Mar 06 '25 10:03 drowaudio

OK now I'm not sure if I'm foolish or not. When I followed your steps verbatim it said no C/C++ compiler could be found. However when I have run it on other occasions, it seemed that it did find the compiler. I treat this error as correct (even though it goes against my intuition) and explore this solution.

admin@Davids-MacBook-Pro tracktion_engine % cmake -G Xcode -B build -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:6 (project): No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:6 (project): No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred! admin@Davids-MacBook-Pro tracktion_engine % cmake Usage

cmake [options] cmake [options] cmake [options] -S -B

Specify a source directory to (re-)generate a build system for it in the current working directory. Specify an existing build directory to re-generate its build system.

dmann200 avatar Mar 07 '25 00:03 dmann200

Do you perhaps not have the Xcode command line tools installed? Try running this from the Terminal xcode-select --install. Then try again and let me know how that goes.

drowaudio avatar Mar 07 '25 10:03 drowaudio

Finally got it to build. Very difficult. My command line tools were installed but required update. But there were many other steps required after that.

Not quite sure what the secret sauce was but here is my command line history (minus useless stuff)

rm -rf build CMakeCache.txt brew reinstall cmake sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer cmake -G Xcode -B build

BEFORE getting command line to work you need to modify CMakeLists.txt to force c++20:

set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)

Run software update on mac to update command line tools then REBOOT because these were reinstalling over and over.

dmann200 avatar Mar 07 '25 20:03 dmann200

I'm glad you got it working. I'm not sure what was going on with your Xcode install but seems like you've managed to cmake to find the compiler now.

I can probably add the CMAKE_CXX_STANDARD properties. I'm not sure why they're not needed in the build tests, it might be that 20 is the default in the compiler versions we're using.

drowaudio avatar Mar 10 '25 12:03 drowaudio