I converted some Audio C++ libraries into Arduino Libraries and used symlinks which point to the original file locations to make sure that Arduino can find all relevant files. This approach was working fine in OSX and Linux. Unfortunately this seems to create problems in Windows, so I decided to change the approach a little bit and replace the symlinks just with regular files that contain a regular #include.

To convert all files manually would have been too tedious, so I used the following simple Python program.

import os
from pathlib import Path

def prefix(path):
    n = path.count("/")
    if n==1:
        return "../"
    if n==2:
        return "../../"
    if n==3:
        return "../../../"
    if n==4:
        return "../../../../"

def replace(path, newPath):
    # delete file
    # create new file
    content = "#pragma once\n// link to original location\n#include \""+prefix(path)+newPath+"\"\n\n"
    with open(path, "w") as text_file:

working_dir = os.getcwd()+"/"
for path, currentDirectory, files in os.walk("src"):
    for file in files:
        p = os.path.join(path, file);
        if (Path(p).is_symlink()):
            linkedPath = str(os.path.realpath(p)).replace(working_dir,"")
            print(p + " ->" + linkedPath);
            replace(p, linkedPath)
Categories: Arduino


Leave a Reply

Avatar placeholder

Your email address will not be published.