How to Install PostgreSQL on Manjaro

How to install PostgreSQL on Manjaro (really any Arch distro) is not straight forward. Worse yet, most of the information you find online about how to do it is outdated fifteen minutes after it is published. You have to be sure the versions match before following the instructions.

My version

You really need to do this one from the terminal.

sudo pacman -Ss postgres

That will show you lots of stuff. If you just want to jump, run these two commands.

sudo pacman -Sy postgresql
sudo pacman -Sy libpqxx

The second one many will argue is not needed. Just install it. Technically it is for C/C++ users doing server development, but quite a few programs using PostgreSQL as their back end need it. Don’t rely on packagers being smart enough to include it as a dependency.

Oh, don’t get all happy and giddy. This is an Arch based distro, nothing is easy despite the “simplicity” motto.

It’s still not going to work

Most other distros would be really nice and simple. After you installed the server, they would enable and start it for you. Not Arch based distros. Being kind to the user isn’t in the development mantra.

Part of the reason is you cannot have “One package to rule them all!” This desktop thing is kind of an afterthought in the Arch world. A cute little thing to be passed along as a promotional item like a pen with a company name on it. The bulk of Arch based packaging and development appears to be focused on server markets. Here’s a good example.

sudo -u postgres -i
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/'

You should see something like this:

Initializing PostgreSQL

Most desktop distros just do that (or something like it) for you as part of the POSTINST step. While some super desktop users will have multiple disk drives in their system and now how to automount NAS at boot, John and Jane Q. Public don’t.

Those of you who happen to have a spare 6TB Western Digital Black internal disk drive in your machine will want to change the directory path because you probably installed that drive just for database use . . . unless you really like funny cat videos.

A Debian Detour

On Debian and most other desktop friendly distros, they choose to make the expert users suffer.

sudo mkdir /media/db_data/postgres_data
sudo chown postgres:postgres /media/db_data/postgres_data
psql -d postgres -c " create tablespace bigspace location '/media/db_data/postgres_data' "

Then you have to explicitly create your tables in that tablespace.

createdb --tablespace bigspace tax_$tax_year 'Tax information for $tax_year'

Yes, parking my PostgreSQL data out on a second disk was painful. Most ordinary users only have one disk. Adding insult to injury, if I had to re-install my OS due to drive failure and no current backup, there was actually no way to recover the data in the tablespace. At least there wasn’t back then. I’m very religious about backing up, but that failure caught me at the right time.

OS/2 Still Lives

There is a method to the madness with the way Manjaro/Arch distros choose to do this. It just doesn’t work well for the average user. Server focused distros are pushing LVM.

I’m not really trusting this particular history of OS/2 and its statements about LVM. The reason for my distrust is I ran OS/2 as my primary desktop for years. The reason is that I never ran a server edition of OS/2, but I ran LVM for years.

Logical Volume management was way more important in the OS/2 days. You have to remember that an 80MEG hard drive was huge then. Depending on what flavor of DOS you were running, you couldn’t even partition that entire drive as a single partition. According to this post my memory is wrong, but I physically remember running into the partition size limit issue more than once. First time was with my first 40MEG drive and he second time was with my first 80MEG drive.

With LVM and a SCSI controller allowing for up to six drives you didn’t have these issues. OS/2 had a drive preparation that would let you dynamically add another drive to the LVM. Is that 80MEG drive getting full? Just add another. Once IBM ripped out most of the really bad Microsoft code, OS/2Warp 4.5 was a really stable and capable OS. So naturally they abandoned it.

Pieces of OS/2 keep showing up because it was ahead of its time. It had better memory management and networking than any Microsoft product of the day or many years to follow. In particular, LVM was something of a crown jewel. As a parting thumb in the eye of Microsoft, IBM OpenSourced LVM and it found its way into Linux.

The Method to the Madness

Some Linux distros are defaulting to LVM for the primary installation target, others are not. I will leave it up to the reader to click the links and do the research.

This long winded tale is explaining why opted to not be nice to the user. A sysadmin is going to want to point PostgreSQL to an LVM or network storage appliance providing hundreds, perhaps thousands of Terabytes of storage. An ordinary desktop user has one disks.

Your Final Step

sudo systemctl enable --now postgresql.service

You should be good to go!

Add yourself as a super user

There are those who offer up the argument for adding yourself to the postgres group. I’ve never done it. If you are really bothered by the createuser command not being able to change directory to your home then I guess you can. Just don’t forget to also change the group on your directory.

groups and permissions

If you want to understand more about Linux groups and file permissions, start here.

The Arch Bug

When you install PostgreSQL on Manjaro you run into the Arch bug. Manjaro is Arch Linux based. When you hear about Linux being an “expert friendly” operating system with an uninviting community, you are most likely hearing a story about someone’s adventure into Arch. Just signing up for the user forum should tell you what you are in for.

Arch forum registration greeting

Basically, the bug is Arch deciding to change a default from false to true. So, if you’ve been using my xpnsqt application to keep track of your expenses for filing taxes; (Tax season is just around the corner people!) you will see something like this when you try to load your CSV backup files.

'/home/roland/postgres_tax_backups/tax_2019_payees.csv' -> '/tmp/tax_2019_payees.csv'
 '/home/roland/postgres_tax_backups/tax_2020_categories.csv' -> '/tmp/tax_2020_categories.csv'
 '/home/roland/postgres_tax_backups/tax_2020_expenses.csv' -> '/tmp/tax_2020_expenses.csv'
 '/home/roland/postgres_tax_backups/tax_2020_payees.csv' -> '/tmp/tax_2020_payees.csv'
 ;;;;;   Loading 1992
 creating tax tables
    Importing …  1992
 psql:import_it.sql:1: ERROR:  could not open file "/tmp/tax_1992_payees.csv" for reading: No such file or directory
 HINT:  COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
 psql:import_it.sql:2: ERROR:  could not open file "/tmp/tax_1992_categories.csv" for reading: No such file or directory
 HINT:  COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
 psql:import_it.sql:3: ERROR:  could not open file "/tmp/tax_1992_expenses.csv" for reading: No such file or directory
 HINT:  COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.

Since roughly the 1970s /tmp has been that unprotected no-mans land where you didn’t leave stuff sit for long. Most distros point temp environment variables for each user to /tmp/user-name and make that a directory owned by the user. This gives you some protection.

You know, the average schmoe using Linux at home or work doesn’t know much about Linux really. They’ve always used a desktop and only open a terminal when it is absolutely necessary.

Sysadmins on the other hand, should know all about systemctl overrides. They also would have been the only one who wanted this turned on. Seriously, there is no account information with my xpnsqt thing. I suspect there is no account information in your recipe database. How about the database you created to keep track of your music collection? DVDs?

When you install PostgreSQL on Manjaro – The Schmoe Tactic

At some point everyone is a schmoe because he universe likes to laugh at people. The schmoe approach will do just enough research to find out what value they need to change.

cd /usr/lib/systemd/system
sudo cp postgresql.service postgresql.service_original
sudo jed postgresql.service

You may not have jed installed. You should, but you probably didn’t install it. Use nano or whatever terminal emulator you have installed.

PrivateTmp needs to be false

Save an exit. The dutiful schmoe will then do the following:

sudo cp postgresql.service postgresql.service_fixed

Why? Because every update will probably walk on this file. The dutiful schmoe can use a diff utility like Meld to compare the before and after so they can remember what needed to be fixed.

When you install PostgreSQL on Manjaro – Shoulda Done

sudo systemctl edit postgresql.service
Override file

The dark lore of the override file won’t be immediately obvious. You cannot just override the value. You have to override the value under a tag/section whatever the name is this week.

Yeah, Arch did this to you. Every other distro I’ve used realizes your typical desktop user won’t know how to fix this. Far too many will be a schmoe, constantly fixing that file.

No Matter Which Approach

No matter which approach you take, your changes will not take effect until you either reboot or restart PostgreSQL.

sudo systemctl restart postgresql

Related posts:

How to install JED from AUR on Manjaro

How to make Manjaro KDE work with NAS

Interesting PostgreSQL Oddity

I was working on a tiny database to send out some emails with varying subjects. Decided to use PostgreSQL so I could have a real database as the back end. SQLite doesn’t share (on most platforms) so I couldn’t add data while the program was running. Being able to add stuff and check on progress while running is one of those design things you can’t kick when you’ve been in IT as long as me.

Nothing odd about the definition of the table. It only has two columns.

CREATE TABLE agile_book_subjects (
	subject VARCHAR(80),
	last_used VARCHAR(60)

Opted to be a bit lazy when I created the test data. I created a text file with the following:

Subject Line 1,
Subject Line 2,
Subject Line 3,
Subject Line 4,
Subject Line 5,
Subject Line 6,
Subject Line 7,
Subject Line 8,
Subject Line 9,
Subject Line 10,
Subject Line 11,

Next I created a simple import script.

if [ -z "$1" ]; then
    echo "must pass csv file name to import"
    echo "first line must have column names"

export PGUSER=roland
export PGPASSWORD=spooge_1

psql -q -d email_marketing -c "copy agile_book_subjects from '$1' csv header;"

psql -q -d email_marketing -c "select count('*') from agile_book_subjects;"

Here is what happened

When I run it all looks well. I ass-u-me it would have gagged if it didn’t like the missing value.

11 records as expected

While the application is running I see only one subject being used. This is odd. I perform a few queries in another terminal.

Ascending sort seems borked

Well, if that doesn’t look like a Microsoft product! My ascending sort puts the only record with a value in the sort column on top. The select statement in the Java program is as follows:

SELECT subject FROM agile_book_subjects ORDER BY last_used ASC LIMIT 1;
Result of actual select used

If it is unable to sort on a null value, how did it get the first row? Better yet, explain this:

Nulls have a higher value than text?

How is it the nulls sort above the record with actual text? I’m on Ubuntu 20.04 LTS using stuff out of the repos if anyone is interested in the platform.

Of course the fix was to stick a 0 in for last_used then recreate the database and repopulate the table. Still, if it can’t handle nulls in a column as one would expect nulls, it shouldn’t have given me the first row. Is it really putting something like COBOL HIGH-VALUES in the column?

A value should always sort higher than a null value.

Kind of reminds me of this song

CopperSpice Experiments – Pt. 4

Keep in mind I have a minimal Ubuntu 20.04 LTS on this system and will be building PostgreSQL support into CopperSpice. The Building for Unix instructions assume a full installation and even then aren’t complete. By using a minimal install I can help even non-Ubuntu users because I will find everything that got missed.

sudo apt-get install libfreetype6-dev libfontconfig1-dev libglib2.0-dev libgstreamer1.0-dev \
                libgstreamer-plugins-base1.0-dev libice-dev libaudio-dev libgl1-mesa-dev libc6-dev \
                libsm-dev libxcursor-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev \
                libxrandr-dev libxrender-dev libxkbcommon-dev libxkbcommon-x11-dev libx11-dev

sudo apt-get install libxcb1-dev libx11-xcb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev \
                libxcb-render0-dev libxcb-render-util0-dev libxcb-randr0-dev libxcb-shape0-dev \
                libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-dev cmake ninja-build libxcb-glx0-dev

One of the first things I want to do is try converting my XpnsQt project from Qt to CopperSpice. This and my lottery tracking application are my goto tire kicking applications. XpnsQt needs PostgreSQL.

I rebooted at this point so all would be good with PostgreSQL.

Yeah, the import works from the oldest year it finds a data file for to the current year. I just don’t have files for this year on this machine. Data from 1996 or so through 2019 should be more than enough to kick the tires.

My first attempt at configuring CopperSpice failed rather spectacularly.

Configuring CMake for CopperSpice

Search for required Packages

-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) (Required is at least version "1.0")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/ (found version "1.2.11") 
-- Could NOT find Cups (missing: CUPS_LIBRARIES CUPS_INCLUDE_DIR) 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Could NOT find PulseAudio (missing: PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR) (Required is at least version "0.9.9")
-- Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found version "12.2")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found GLib2: /usr/include/glib-2.0;/usr/lib/x86_64-linux-gnu/glib-2.0/include 
-- Found GOBJECT2: /usr/lib/x86_64-linux-gnu/ 
-- Found Iconv: /usr/include 
-- Found X11: /usr/include found components: ICE SM Xcursor Xext Xfixes Xi Xinerama Xrandr Xrender 
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/ - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found xcb: /usr/include 
-- Found xcb-image: /usr/include 
-- Found xcb-icccm: /usr/include 
-- Found xcb-sync: /usr/include 
-- Found xcb-xfixes: /usr/include 
-- Found xcb-shm: /usr/include 
-- Found xcb-randr: /usr/include 
-- Found xcb-shape: /usr/include 
-- Found xcb-keysyms: /usr/include 
-- Found xcb-xinerama: /usr/include 
-- Found xcb-xkb: /usr/include 
-- Found xcb-render: /usr/include 
-- Found xcb-render-util: /usr/include 
-- Found X11_XCB: /usr/lib/x86_64-linux-gnu/ 
-- Found XKBCommon: /usr/lib/x86_64-linux-gnu/ 
-- Found XKBCommon_X11: /usr/lib/x86_64-linux-gnu/ 
-- Found Fontconfig: /usr/include 
-- Checking for module 'gstreamer-1.0'
-- Found gstreamer-1.0, version 1.16.2
-- Checking for module 'gstreamer-base-1.0'
-- Found gstreamer-base-1.0, version 1.16.2
-- Checking for module 'gstreamer-app-1.0'
-- Found gstreamer-app-1.0, version 1.16.2
-- Checking for module 'gstreamer-audio-1.0'
-- Found gstreamer-audio-1.0, version 1.16.2
-- Checking for module 'gstreamer-video-1.0'
-- Found gstreamer-video-1.0, version 1.16.2
-- Found GStreamer: /usr/lib/x86_64-linux-gnu/ 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/ 
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)

Enabled CopperSpice libraries

* Core Gui Multimedia Network OpenGL Script Sql Svg WebKit Xml XmlPatterns

-- The following packages have been found:

* ZLIB, Compression Library, <>
Required for compression support
* Threads, Platform dependant threading library
Required for threading support
* GLib2, GNOME core library, <>
Required for glib mainloop support
* GObject2, The object system used for Pango and GTK+, <>
Required for glib mainloop support
* Iconv, For use on systems which do not have Iconv or lack Unicode support, <>
Iconv support
* X11, Open source implementation of the X Window System, <>
Required for X11/X.Org integration support
* XCB, Open source implementation of the XCB Interface for the X11 Window System, <>
Required for XCB/X.Org integration support
* X11_XCB, Integration between X11 and XCB, <>
Required for X11 XCB support
* XKBCommon, Keyboard library, <>
Required for XKB integration support
* XKBCommon_X11, Keyboard library, <>
Required for XKB X11 integration support
* Fontconfig, Library for configuring and customizing font access, <>
Required for fonts configuration support
* GStreamer, Open source media playback library, <>
Required for multimedia audio and video support
* OpenGL, The Mesa 3D Graphics Library, <>
Required for OpenGL support

-- The following packages have not been found:

* OpenSSL (required version >= 1.0), Support for SSL and TLS, <>
Required for HTTPS support
* Cups, CUPS is the standards-based open source printing system, <>
Required for printing support
* ALSA, Advanced Linux Sound Architecture, <>
Required for ALSA audio support
* PulseAudio, Sound processing daemon for Unix, <>
Required for pulseaudio support
* PostgreSQL, Popular open source database, <>
Required for PostgreSQL database support
* MySQL, Popular open source database, <>
Required for MySQL database support
* LibXml2, XML C parser and toolkit developed for the Gnome project, <>
Required for XML support in WebKit

CopperSpice configured to run on: Linux 64 bit, Release Mode
CopperSpice will be built in: /home/roland/Projects/cs_build
CopperSpice will be installed in: /usr/lib/cs_lib

-- Configuring done
-- Generating done
-- Build files have been written to: /home/roland/Projects/cs_build

I was rather shocked to see Cups, Alsa, SSL, and PulseAudio in the list of things that weren’t there. The Alsa and PulseAudio were listed in the table on the documentation link, just not in the commands.

This time should work, right?

Since I know I installed the official libraries, this is a bit of a head scratcher. Scrolling back in the output I see the following:

I won’t bore you with how many times I edited my .profile assigning different values to PostgreSQL_ROOT and PostgreSQL_TYPE_INCLUDE_DIR. I even started rebooting instead of just logging out and back in. I will share an image of one of the stupid things a person tries when the doc leads them off a cliff.

Ah! /usr/include/pqxx/types Now there is excitement! Nah. False high.

That’s the package you need. The number will change with PostgreSQL version, but you need postgresql-server-dev-nnnn. It installs a standard U.S. buttload of dependencies when you select it.

Yes, I rebooted after this to see if things would work. This time when I entered the command:

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/lib/cs_lib ~/Projects/copperspice

I had much greater success.

Like most of the known universe, I quit caring about MySQL when Oracle bought InnoDB. Someday Oracle will squeeze that orange for every drop of juice and I don’t want to be relying on it.

Now we can build CopperSpice.

I believe I also had to manually install CMake.

The screenshot utility that comes installed with Ubuntu 20.04 LTS blows

On KDE Neon they have a great one. You can tell it to delay when you are going to scrape a screen section so you can navigate to the proper place in a menu system. Not on this one. They have a delay, but it is only for entire windows or screens.

Adding insult to injury it will randomly show you a screen shot an then save a garbage file after you give it a name. I can’t find a pattern, it just does it. There are half a dozen screen scrapes that didn’t get into this post series already because it “said it saved them” but the file was trash.

The other insulting feature is that it autosnaps as soon as you get done dragging the mouse. The default one on KDE Neon leaves the box around what you selected and allows you to adjust things before hitting return to select your scrape. When the left margins are hosed in this post series, that is why.

<Previous-part Next-part>

How Far We’ve Come – Pt. 18

The Internet has no shortage of “how to cross compile Qt for Pi Web pages.” Most of them kind of were “right enough” at one point in time for a subset of people. Most of them don’t bother to tell you what the host system is. I suspect many of them used a 32-bit host system which masked most of the problems with their instructions. The instructions found here definitely fall into this category. How do I know that? I followed them for a bit because I liked not having to loop mount an image. Really weird things can happen when images for a different CPU are loop mounted and something goes wrong. Another reason I followed them is that they appeared to be an update for the official Qt Wiki article using the same method.

Yes, everyone wants to believe the instructions they found are a fine Cuban cigar. On the Internet, even when they are “just posted today” they tend to be closer to a Lucky Strike someone ripped the filter off of then left lay on a shelf for 7+ years.

When I got to the configure step I tried to use this:


./configure -release -opengl es2 \
-opensource -confirm-license -plugin-sql-psql -qt-sql-sqlite \
-device linux-rasp-pi2-g++ \
-device-option CROSS_COMPILE=~/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- \
-sysroot ~/piBuild/sysroot -prefix /usr/local/qt5pi \
-extprefix ~/piBuild/qt5pi \
-hostprefix ~/piBuild/qt5 -v

I wanted to be sure we compiled support for the PostgreSQL plugin and that we used the SQLite which came with Qt. The first signs of problems came early on:

psql.cpp:40:22: fatal error: libpq-fe.h: No such file or directory
 #include "libpq-fe.h"
compilation terminated.
Makefile:198: recipe for target 'psql.o' failed
make: *** [psql.o] Error 1
PostgreSQL disabled.
PostgreSQL support cannot be enabled due to functionality tests!
 Turn on verbose messaging (-v) to /home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/configure to see th

Given I had quite a few distractions, I did some searching to see which Debian package provided that header and installed it. Yes, it’s okay. You can say it out loud. I’m stupid some times. I should have known right then and there this build procedure wasn’t worthless shit. I should have also went to the bottom of that post and looked at all of the comments from people trying to build on a 64-bit host asking if this procedure was ever tested.

sudo apt install libpq-dev

Stubborn can be good, but stubborn and stupid tends not to be a winning combination.

Adding insult to injury, this very site where I wish to write posts about this started having severe intestinal disorders so I was fighting that while working on this and getting on with my life.

I warned you at the start of this series, you aren’t getting one of my clean and polished books where I worked through everything the first time, then re-tested on a clean system so I knew everything I put in there worked. You are getting a merger of hundreds of note files taken while I was figuring it out. The bad part here is I’ve been away from this for a couple of weeks so you really are getting a compilation of note files I could find rather than a direct flow of conscious.

This build attempt proves what a horrible debacle these instructions are. I installed that package on both the Pi and my 64-bit compilation machine. I redid all of the rsync stuff and reran the fixup script before launching another attempt at getting PostgreSQL to work.

checking for PostgreSQL... 
/home/roland/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -c -pipe -march=armv7-a -marm -mthumb-interwork -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux -mfloat-abi=hard --sysroot=/home/roland/piBuild/sysroot -O2 -Wall -W -fPIC -I. -I/usr/include/postgresql -I../../../mkspecs/devices/linux-rasp-pi2-g++ -o psql.o psql.cpp
/home/roland/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/home/roland/piBuild/sysroot/opt/vc/lib -Wl,-rpath-link,/home/roland/piBuild/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/roland/piBuild/sysroot/lib/arm-linux-gnueabihf -mfloat-abi=hard -Wl,-O1 -o psql psql.o --sysroot=/home/roland/piBuild/sysroot -L/usr/lib/x86_64-linux-gnu -lpq 
/usr/lib/x86_64-linux-gnu/ file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Makefile:92: recipe for target 'psql' failed
make: *** [psql] Error 1
PostgreSQL disabled.
PostgreSQL support cannot be enabled due to functionality tests!
 Turn on verbose messaging (-v) to /home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/configure to see the final report.
 If you believe this message is in error you may use the continue
 switch (-continue) to /home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/configure to continue.
roland@roland-desktop:~/piBuild/qt-everywhere-opensource-src-5.7.1$ cd /
roland@roland-desktop:/$ sudo find -iname
[sudo] password for roland: 

You will note the library from the Pi is exactly where it should be. Either the instructions for configuring the environment are incorrect on the blog/wiki, or the cross compile configure scripts are incorrect.

Leaving PostgreSQL out of it, the build still crashes.

/home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/include/QtCore/../../src/corelib/tools/qhash.h:235:45: warning: cast from ‘QHashData::Node*’ to ‘QHash<QString, QVariant>::Node* {aka QHashNode<QString, QVariant>*}’ increases required alignment of target type [-Wcast-align]
 return reinterpret_cast<Node *>(node);
make[4]: *** [invoke_ninja] Error 1
make[3]: *** [sub-gyp_run-pro-make_first] Error 2
make[2]: *** [sub-core-make_first] Error 2
make[1]: *** [sub-src-make_first] Error 2
make: *** [module-qtwebengine-make_first] Error 2
make: *** Waiting for unfinished jobs....

As I said, neither wiki page nor the blog stated what their build machine was. They also didn’t state what was installed. There was one telling line in this post though.

Make sure your Qt Creator installation works for native development using a native Qt version running on your desktop, as this is a prerequisite to extending it to work for embedded development.

While it is all well and good to have some development machine which built and ran a desktop version of your application, it is a rather horrible idea to put together cross compile instructions based on that same machine. This would never fly in an FDA regulated environment where you have to be able to create from scorched earth your cross compile environment.

I finally used this configure command.

./configure -release -opengl es2 -opensource -confirm-license -qt-sql-sqlite -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=~/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- -sysroot ~/piBuild/sysroot -prefix /usr/local/qt5pi -extprefix ~/piBuild/qt5pi -hostprefix ~/piBuild/qt5 -v -skip webengine

While this does cleanly build, our PostgreSQL test application does not.



Related Posts:

QT Database book

AGILE book

Where Did My QDebug Output Go?

MOC Parse Error at “std”

KDE Neon – Distcc and Qt

CopperSpice Experiments

QtCreator – No qmlScene installed

So You Can’t Get Your Models to Work with QML?

How Far We’ve Come – Pt. 7

Originally I did a stupid thing. It was so stupid I made it the featured image for this post. I used the install/remove applications menu option to install postgresql and postgresql-contrib. Finding postgresql was like finding a needle in a haystack after using the search. The software manager for the Raspberry Pi doesn’t order by package name nor does it display that first. It displays the one-line human friendly description first and has a sort order which completely mystifies me. Seemed like there were over 100 entries to scroll through on that tiny screen. Searching for “postgresql-contr” yielded almost a direct hit.

I copied my postgres_tax_backups directory from the thumb drive, changed to that directory, flagged the shell script as executable and launched. It took a while before I noticed I was getting a different kind of fatal error than expected from psql.

psql: FATAL: Peer authentication failed for user "roland"
database created
Extracting ... 2015
psql: FATAL: Peer authentication failed for user "roland"
psql: FATAL: Peer authentication failed for user "roland"

Gotta (*^&)(*&)(*ing hate security! Postgres will no longer let you connect as a different user than the one you are logged into the OS as. *^)(*&^)(*&)_

Yes, I could have added an account for “roland” and went through everything again, but, it was just too much effort for a one time test. Ultimately, time allowing, we will get to cross compiling for the Pi, which was the original goal. So, I redid the command you see in the image to create a PostgreSQL account for pi. Then I did a quick hack to

export PGUSER=pi
export PGPASSWORD=raspberry

Yes, I should have gotten fancy, having the script prompt for user and password. I leave that as a programming exercise for the reader. I wrote this for me. You need to modify it for yourself.

After the quick hack and new user the script ran fine.

Pi after import image
Pi after import

The backup script required no modifications.

So, now we just need to compile the application on the Raspberry Pi to be certain all is well.

<Previous-part Next-Part>

Related posts:

QT Database book

AGILE book

Where Did My QDebug Output Go?

MOC Parse Error at “std”

KDE Neon – Distcc and Qt

CopperSpice Experiments

QtCreator – No qmlScene installed

So You Can’t Get Your Models to Work with QML?