diff --git a/brian2/devices/cpp_standalone/device.py b/brian2/devices/cpp_standalone/device.py index 151384080..a4050a512 100644 --- a/brian2/devices/cpp_standalone/device.py +++ b/brian2/devices/cpp_standalone/device.py @@ -1554,10 +1554,20 @@ def build( libraries = self.libraries + prefs["codegen.cpp.libraries"] + codeobj_libraries compiler_obj = ccompiler.new_compiler(compiler=compiler) + + # Distutils does not use the shell, so it does not need to quote filenames/paths + # Since we include the compiler flags in the makefile, we need to quote them + include_dirs = [f'"{include_dir}"' for include_dir in include_dirs] + library_dirs = [f'"{library_dir}"' for library_dir in library_dirs] + runtime_library_dirs = [ + f'"{runtime_dir}"' for runtime_dir in runtime_library_dirs + ] + compiler_flags = ( ccompiler.gen_preprocess_options(define_macros, include_dirs) + extra_compile_args ) + linker_flags = ( ccompiler.gen_lib_options( compiler_obj,