LibreCAD port

Notes for LibreCAD build:

Download sources and extract zip:

Make build folder and cd to it:

cd “/MyStuff/compiled_apps/LibreCAD-2.2.1.5”
mkdir build
cd build

Install Boost:

pkgman install boost1.91_devel

Find following:

#ifdef Q_OS_WIN
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>
#  include <dbghelp.h>
#  include <fcntl.h>
#  include <io.h>
#  include <process.h>
#  include <sys/stat.h>
#else
#  include <csignal>
#  include <execinfo.h>
#  include <fcntl.h>
#  include <sys/types.h>
#  include <unistd.h>
#endif

Change it to:

#ifdef Q_OS_WIN
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>
#  include <dbghelp.h>
#  include <fcntl.h>
#  include <io.h>
#  include <process.h>
#  include <sys/stat.h>
#else
#  include <csignal>
#  ifndef Q_OS_HAIKU
#    include <execinfo.h>
# endif
#  include <fcntl.h>
#  include <sys/types.h>
#  include <unistd.h>
#endif

Find:

#if !defined(Q_OS_WIN)
char g_altStack[kAltStackSize];
#endif

Change it to:

#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
char g_altStack[kAltStackSize];
#endif

Find POSIX signal handler section and change:

#if !defined(Q_OS_WIN)

To:

#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)

Close to end of the file find:

void LC_CrashHandler::install()
{
    static std::once_flag once;
    std::call_once(once, []() {
        preparePath();
        buildHeader();
        std::set_terminate(&terminateHandler);
        g_prevQtHandler = qInstallMessageHandler(&qtMessageHandler);
#ifdef Q_OS_WIN
        installWindows();
void    installPosix();
#endif
    });
}

Change it to:

void LC_CrashHandler::install()
{
    static std::once_flag once;
    std::call_once(once, []() {
        preparePath();
        buildHeader();
        std::set_terminate(&terminateHandler);
        g_prevQtHandler = qInstallMessageHandler(&qtMessageHandler);
#ifdef Q_OS_WIN
        installWindows();
#elif defined(Q_OS_HAIKU)
    // Haiku: crash handler not implemented yet.
#else
void    installPosix();
#endif
    });
}

Run:

cmake ..

If okay, run:

make -j2

Test build:

./build/librecad -style Fusion

Why -style Fusion? Because of window scaling, without it bottom of window is outside screen..

3 Likes

If you’re allowed to redistribute the copy why not build a haiku package recipe while you’re at it unless the licensing doesn’t allow you to do that

I put these notes here, because i didn’t want to mess any other thread.

About Haiku recipes and packaging, i did try but no luck. Luckily these works good straight from build dirs, so its enough for me now. Made little scripts for both and got those attached to menu for quick start..

I have to confess that i got these builds working with a little LLM help.

Had to get same CAD versions working with Haiku than my Linux and Mac has.. so that’s why these experiments.

pkgman install devel:libexecinfo should work.

2 Likes

I love this!
Was a beast to build!
I had to do

pkgman install qt5_devel qt5_tools boost1.91_devel
mkdir build && cd build
cmake ..
make -j15

As there is already a HaikuPorts recipe for LibreCAD, I guess it means that it can be update easily for latest version of it.

2 Likes

There was a problem with filebrowse dialogs when selecting paths in app preferences. Filebrowser windows opened behind preferences window.

So, here is the fix:

Open file:

nano librecad/src/ui/qg_filedialog.cpp

Find following:

QSettings settings;
if( 0 == settings.value("Defaults/UseQtFileOpenDialog", 0).toInt()) {
    setOption( QFileDialog::DontUseNativeDialog, false );
}
else {
    setOption( QFileDialog::DontUseNativeDialog, true );
}

Change it to this:

#ifdef Q_OS_HAIKU
    setOption(QFileDialog::DontUseNativeDialog, true);
#else
    QSettings settings;
    if( 0 == settings.value("Defaults/UseQtFileOpenDialog", 0).toInt()) {
        setOption( QFileDialog::DontUseNativeDialog, false );
    }
    else {
        setOption( QFileDialog::DontUseNativeDialog, true );
    }
#endif

But this doesnt change everything, so you have to change other file too:

Open file:

nano librecad/src/ui/forms/qg_dlgoptionsgeneral.cpp

Find following:

void QG_DlgOptionsGeneral::setFontsFolder()
{
    QFileDialog dlg(this);
    dlg.setFileMode(QFileDialog::Directory);
    dlg.setOption(QFileDialog::ShowDirsOnly);

    if (dlg.exec())
    {
        auto dir = dlg.selectedFiles()[0];
        lePathFonts->setText(QDir::toNativeSeparators(dir));
    }
}

Change it to this:

void QG_DlgOptionsGeneral::setFontsFolder()
{
    QFileDialog dlg(this);
#ifdef Q_OS_HAIKU
    dlg.setOption(QFileDialog::DontUseNativeDialog, true);
#endif
    dlg.setFileMode(QFileDialog::Directory);
    dlg.setOption(QFileDialog::ShowDirsOnly);

    if (dlg.exec())
    {
        auto dir = dlg.selectedFiles()[0];
        lePathFonts->setText(QDir::toNativeSeparators(dir));
    }
}

Then build it again:

cd build
make -j2

Now it should work.. :smiling_face_with_sunglasses:

1 Like