Building on OpenBSD

Hello,

I tried to build the software on OpenBSD, I ran:

git clone --recursive https://github.com/LibrePCB/LibrePCB.git && cd LibrePCB
mkdir build && cd build
qmake-qt5 -r …/librepcb.pro CONFIG+=debug
gmake CC=clang CXX=clang++

The compilation ran for some time, but errored in systeminfo.cpp:299:2:

clang++ -c -pipe -Wextra -g -Wextra -fPIC -std=gnu++11 -Wall -W -pthread -DQUAZIP_STATIC -DBUILD_OUTPUT_DIRECTORY="/home/ruda/soft/LibrePCB/build/output" -DSHARE_DIRECTORY_SOURCE="/home/ruda/soft/LibrePCB/share" -DGIT_COMMIT_SHA=“893da5f2bd0f0e2ee3610dba8b642ffa1d396d3b” -DLINKING_TYPE="“static”" -DUNBUNDLE=""-"" -DQT_OPENGL_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_SQL_LIB -DQT_CORE_LIB -isystem /usr/include/c++/v1 -I…/…/…/…/libs/librepcb/common -I/home/ruda/soft/LibrePCB/build/libs/librepcb/common -I…/…/…/…/libs -I…/…/…/…/libs/sexpresso -I…/…/…/…/libs/type_safe/include -I…/…/…/…/libs/type_safe/external/debug_assert -I…/…/…/…/libs/muparser/include -I…/…/…/…/libs/quazip -I…/…/…/…/libs/polyclipping -I…/…/…/…/libs/fontobene-qt5 -I/usr/local/include/X11/qt5 -I/usr/local/include/X11/qt5/QtOpenGL -I/usr/local/include/X11/qt5/QtPrintSupport -I/usr/local/include/X11/qt5/QtWidgets -I/usr/local/include/X11/qt5/QtGui -I/usr/local/include/X11/qt5/QtXml -I/usr/local/include/X11/qt5/QtNetwork -I/usr/local/include/X11/qt5/QtSql -I/usr/local/include/X11/qt5/QtCore -I/home/ruda/soft/LibrePCB/build/libs/librepcb/common -I/usr/X11R6/include -I/usr/X11R6/include/libdrm -I/home/ruda/soft/LibrePCB/build/libs/librepcb/common -I/usr/local/include -I/usr/local/lib/qt5/mkspecs/openbsd-clang -o systeminfo.o …/…/…/…/libs/librepcb/common/systeminfo.cpp
…/…/…/…/libs/librepcb/common/systeminfo.cpp:299:2: error: “Unknown operating system!”
#error “Unknown operating system!”

I wonder what can be done. Is it really necessary to have explicit checks for any conceivable operating system and fail when one does not find one known?

Thanks
Ruda

Hi,

In this case, yes I’d say it is necessary because it is needed to make file locks working properly, and there is no portable way to implement it so we have to do it for each OS separately. But if I remember correctly, this is the only file where we need to do this.

Can you try to replace this line:

#elif defined(Q_OS_FREEBSD)

by

#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)

within the file libs/librepcb/common/systeminfo.cpp? And if it compiles without errors, could you run the unit tests?

I tried the proposed change in libs/librepcb/common/systeminfo.cpp and it compiled without errors. How am I supposed to run the unit tests? I ran gmake in the unittests directory:

odin$ gmake
cd unittests/ && ( test -e Makefile || /usr/local/bin/qmake-qt5 -o Makefile /home/ruda/soft/LibrePCB/tests/unittests/unittests.pro CONFIG+=debug ) && gmake -f Makefile
/home/ruda/soft/LibrePCB/build/tests/unittests
gmake[1]: Entering directory ‘/home/ruda/soft/LibrePCB/build/tests/unittests’
gmake[1]: Nothing to be done for ‘first’.
gmake[1]: Leaving directory ‘/home/ruda/soft/LibrePCB/build/tests/unittests’
odin$ ls
Makefile unittests
odin$ cd unittests/
/home/ruda/soft/LibrePCB/build/tests/unittests
odin$ ls
Makefile
airwiresbuildertest.o
alignmenttest.o
angletest.o
applicationtest.o
attributekeytest.o
attributesubstitutortest.o
boardgerberexporttest.o
boardpickplacegeneratortest.o
boardplanefragmentsbuildertest.o
circuitidentifiertest.o
componentprefixtest.o
componentsymbolvariantitemsuffixtest.o
componentsymbolvariantitemtest.o
csvfiletest.o
deviceconvertertest.o
devicesetconvertertest.o
directorylocktest.o
editabletablewidgettest.o
filedownloadtest.o
filepathtest.o
graphicslayernametest.o
lengthedittest.o
lengthsnaptest.o
lengthtest.o
librarybaseelementtest.o
librarydownloadtest.o
main.o
mathparsertest.o
moc_editabletablewidgetreceiver.cpp
moc_editabletablewidgetreceiver.o
moc_networkrequestbasesignalreceiver.cpp
moc_networkrequestbasesignalreceiver.o
moc_predefs.h
networkrequesttest.o
packageconvertertest.o
pathmodeltest.o
pathtest.o
pickplacecsvwritertest.o
pointtest.o
positivelengthedittest.o
projectlibrarytest.o
projecttest.o
ratiotest.o
scopeguardtest.o
serializableobjectlisttest.o
signalslottest.o
sqlitedatabasetest.o
symbolconvertertest.o
systeminfotest.o
toolboxtest.o
transactionaldirectorytest.o
transactionalfilesystemtest.o
unsignedlengthedittest.o
uuidtest.o
versiontest.o
workspacetest.o

So it seems to me there are quite a few object files. What should I do?

Thanks
Ruda

Oops, sorry for not mentioning the instructions how to run the tests! Actually it’s quite simple, the unittests are automatically built when building librepcb, now you just need to run the executable build/output/librepcb-unittests.

@rudolfII did running the unit tests work? If yes, we could add this fix to LibrePCB itself, so that it supports OpenBSD out of the box.

@dbrgn

I only now noticed that you answered how to run the tests.
One test failed:

[----------] Global test environment tear-down
[==========] 1362 tests from 63 test suites ran. (36092 ms total)
[ PASSED ] 1361 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] SystemInfoTest.testGetProcessNameByPid

Ruda

I was able to get it running on OpenBSD, the patch will be included in the next LibrePCB release: