Building & Compiling [Solved]

Alexzee

Well-Known Member
Joined
Jun 1, 2019
Messages
4,001
Reaction score
2,169
Credits
24,343
There's a few things I'm not familiar with during the build and compile process with programs.
Started digging in yesterday to learn the how to's:-:)

Pkg's or lib's listed as required for the build may not be called the same in Arch, Debian or Slackware....as I've found out.

*If libraries didn't install because they are named a different name, how would I determine/find out the name of lib in the repo?

*If I have to go get a .deb pkg or .rpm and convert it to a slack pkg will that effect the build?

*How many threads should I tell make -j to use during the compilation?

And watching a few videos online men have said that Trackback errors are where one would find problems.

How would I rectify those errors?
 


*If libraries didn't install because they are named a different name, how would I determine/find out the name of lib in the repo?
Normally you should go to GitHub or to place where the main codebase is hosted and read their docs about dependencies, like README.md

If nothing is stated there then simply ignore it and build, then look at errors and google them out to figure out which library is missing and also try determine which version is required.

In both cases prefer exact version not >= because never releases might come with changes that could make compilation fail.

Which ever method you have to use next step is to search your distro repo for that library and install it, and if not found then google out for package name for your distro, otherwise if it's not there you have to compile it including any dependencies it has on it's own.

for ex. in one distro it might be called libwhatever, in other distro, lwhatever, or whateverdev, or whateverdevel etc.
On Debian you can use apt search <whatever> --names-only where <whatever> is without prefix or suffix such as lib or dev.

But googling out exact name for your distro is better.

*If I have to go get a .deb pkg or .rpm and convert it to a slack pkg will that effect the build?
I've never tried this and I'd prefer to instead build it myself because if you get build errors it may be difficult to figure out what caused those errors.

while if you build dependency yourself you're sure to be using what is needed in it's true shape (not modified by package maintainers)

*How many threads should I tell make -j to use during the compilation?
As many physical cores as your CPU has, if it's quad core then 4, if your CPU supports hyperthreading then double amount of physical cores.
This is for fastest build, however your CPU will spike to 100% so you should leave your PC alone until it's done.

And watching a few videos online men have said that Trackback errors are where one would find problems.

How would I rectify those errors?
That's something related to python? it's traceback, can't help with that.
 
Last edited:
You can set jobs to automatically recognize your CPU. No need to specify the exact number.
You can convert/install deb or rpm but personally I would avoid it because they land in strange places. Better use sources if no package is available for the distro.
 
Normally you should go to GitHub or to place where the main codebase is hosted and read their docs about dependencies, like README.md
If a README or config isn't provided then I would just have to keep satisfying missing libs and re-run cmake right?

--Yes, traceback is associated with Python--

One more question:

If there is a patch would I apply it to the configuration file of the program?
 
You can set jobs to automatically recognize your CPU. No need to specify the exact number.
You can convert/install deb or rpm but personally I would avoid it because they land in strange places. Better use sources if no package is available for the distro.
How would I set a job to automatically see my AMD Ryzen?
Cron job?

To hit the strange places off at the pass, I should be able to control which directory the pkg's reside it right?
 
If a README or config isn't provided then I would just have to keep satisfying missing libs and re-run cmake right?
Yes, re-run cmake and see which libs it reports as missing then get them somehow and re-run again. (this is easy method)
But you also need to make CMAKE avare of your downloaded dependencies, this means adjusting Cmake parameters, for this I suggest Cmake-GUI because setting parameters is easier there than editing Cmake files (which requires you to know Cmake well)

I personally hate cmake because getting to know cmake is like trying to learn a brand new programming language.
My method when building something is to create brand new project (for ex. in Code::Blocks for C\C++) and then adding source files to it manually depending on subsequent build errors.

This let's me have clear look at what and why something is missing or why compile or build fails, but this method is harder and requires to know the language which you compile. If I don't know it, then cmake method above (or which ever other build system you happen to use such as ninja) is easier to handle.

After all it does require some practice with build systems to fix build errors without having to google out too much.

One more question:

If there is a patch would I apply it to the configuration file of the program?
Patches apply to code but also to build scripts sometimes, and patching is usually done with git patch command.
For instance you download a patch in some git source tree. to apply it to codebase you run git apply patchfile.patch

Then build process needs to be started again from zero to for the compiler to pick up the patch.
 
I found out that some dependencies are made known but this isn't always the case.

With Slackware I will have to install all dependency first. Then proceed to the build and compilation process.
Using my Debian 12 system, it may be different. I'll find out.

Thanks for confirming that re-running cmake will aid in the dependency resolution.
I'll look for a cmake GUI for setting parameters.

Looks like git isn't installed:
Code:
debian-box:~$ dpkg -L git
dpkg-query: package 'git' is not installed
Use dpkg --contents (= dpkg-deb --contents) to list archive files contents.

It sounds like from your description, to apply a patch I'll need to install git, is that correct?


This let's me have clear look at what and why something is missing or why compile or build fails, but this method is harder and requires to know the language which you compile. If I don't know it, then cmake method above (or which ever other build system you happen to use such as ninja) is easier to handle.
Agreed, that method is harder however, I'm up for the challenge for one and two, if I can get the basic's down I can contribute my builds.

Not sure if I can contribute builds with Debian...?

Moons ago I studied and read an O'Reilly book for Python. Used it for a few weeks and forgot most of what I learned. Got my feet wet with "Code Block" last winter. Liked it:-

Would re-learning Python or Perl help?

Will there be times where GCC won't be the compiler that I can use?
 
Thanks for confirming that re-running cmake will aid in the dependency resolution.
Looks like setting variables and parameters with cmake-gui are straight forward here in the link below.
What you should absolutely know as a package maintainer is to differentiate (categorize) build error types, knowing the type of error will make error resolution easier, there are:

  • Build errors
  • Compile time errors
  • Link time errors
  • Syntax errors
  • Run time errors

Build error may be related to build scripts used by build system or be caused by build system itself (ex. Cmake itself or it's Cmake files) but it may also be any of the 3 other listed errors above because each one will also make whole build process fail, so when somebody says "build fails" they're not saying enough.

Compile time error is an error thrown by a compiler, it fails due an error in the code which is most commonly due to a syntax error.
To fix compile time error you either downgrade your source tree (ex. whole code which you clone with git and build) to some previous or later version or fix an error in the code yourself.

Link time errors happen after the compiler is done compiling, it happens in link stage because a linker cannot link together outputs of the compiler with dependencies (libs) if there are any. (usually because some dependencies or source files or symbols in source files or libs are missing).

When fixing linker errors first step is to figure out whether it's caused due to missing library or missing source file or missing symbol in the source file or external library. ("symbol" may refer to a function definition, a variable or any other language construct that's needed to be present in compiler output or linker input)

Syntax errors are programmer errors or typos in code and fixing them can only be done by editing code or by applying a patch if there is one.

Run time errors are those which happen while a program is executed and running, fixing those requires debugger, this is meaningful to you if in addition to building you also need to make sure build output (ex. an executable) executes and works fine on system.
These of course means that build process will always succeed but then program won't run as it should.
Run time error can be caused either due to a bug or due to logic in code which catches the error and terminates the program or displays (and logs) an error message.

It sounds like from your description, to apply a patch I'll need to install git, is that correct?
Yes, but patches are so rare, I can count on my fingers how many time I've stumbled upon a patch somewhere online.

You can think of every git commit that you can browse on GitHub or elsewhere as of a patch, so usually you simply use git to update your source tree or switch to another branch etc.

If you ever happen to stumble upon and need a patch it will be from some external website (ex. mailing list) or from GitHub but a commit that was not yet merged with current branch for what ever reason.

Would re-learning Python or Perl help?
Build process or debugging scripting languages is different or there is no build process at all, that's why they're called scripting languages because they're not compiled into an executable but consist of scripts that are outright run and processed by interpreter.

I know almost nothing about these but each scripting language does provide some tools to debug them or to confirm they're error free.

In some big projects such as game engines or games you'll find a mix of compiled language sources and scripts, the procedure there is different because usually a compiled language libs like C\C++ libs provide interfaces for scripting, ex. to bind with Python for AI logic, in these cases those scripts are not run by a user but by the main program that's compiled so build process will almost always succeed but if there is error it's going to be run time error or a bug related to those scripts.

So I think learning scripting languages is of very little use to someone who is package maintainer unless you also need to test what you build.

Agreed, that method is harder however, I'm up for the challenge for one and two, if I can get the basic's down I can contribute my builds.
I see, in this case, my suggestion to create custom project files for this is bad because you should use tools that are provided to you by distro for which you build.

Custom project method is great if you build something for yourself and plan to maintain it for yourself, for distros you'll go by their rules as they surely won't accept your build projects.

Custom project is still useful to figure out why build fails, but in the end you'll have to apply your failure discovery so that it's in line with their build rules.
 
Very critical and valuable information you gave in post #10.

I recognize your dedication and assistance on this. Thank you!

Custom project method is great if you build something for yourself and plan to maintain it for yourself, for distros you'll go by their rules as they surely won't accept your build projects.
Roger that. You're right.
The Slackware contributors and maintainers have spelled it out how I need to create my SlackBuilds.
I'm in the process of learning how to do those things.

I've downloaded the current version of Shutter 0.995 from their homepage. It's a src tar.gz.
I'll start with that.
Then I can compare the Shutter 0.94.3 SlackBuild script templates to learn how to write my own.

Thanks for the confirmation on scripting languages.
In the future I should test what I've build to ensure the script runs correctly and produces a tgz pkg. Once the script finishes it will place the .tgz in the /tmp for the user to install it.

I've got a lot to focus on and learn during this coming week.
I'll share the progression in 2 days, this coming Monday.
 
I've created a file in vim so I have your advise and instructions to refer to.
Pluma works really well in Debian 12 Mate.
 

Attachments

  • Caffine Addicts Inst.png
    Caffine Addicts Inst.png
    246 KB · Views: 54
I found the src code page and instructions for Shutter.

Code:
To install the source code with standard prefix (/usr/local) run

make install

for a non-standard prefix run

make prefix=YOURPREFIX install

I'll see how it goes.
 
Already had Shutter installed. I'm in the process of reading the prerequisites and installing dependencies for Krita.
Reading through the build instructions at the moment.

Code:
root@devartbox:~# apt install docker docker.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  cgroupfs-mount containerd criu git git-man imvirt-helper iptables
  libemail-date-format-perl liberror-perl libfile-slurp-perl libimvirt-perl
  libintl-perl libintl-xs-perl libip4tc2 libip6tc2 libmime-lite-perl
  libmime-types-perl libmodule-find-perl libmodule-scandeps-perl libnet1
  needrestart python3-protobuf runc tini wmdocker
Suggested packages:
  containernetworking-plugins docker-doc aufs-tools btrfs-progs debootstrap rinse
  rootlesskit xfsprogs zfs-fuse | zfsutils-linux git-daemon-run
  | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki
  git-svn imvirt firewalld libmojolicious-perl iucode-tool
The following NEW packages will be installed:
  cgroupfs-mount containerd criu docker docker.io git git-man imvirt-helper
  iptables libemail-date-format-perl liberror-perl libfile-slurp-perl
  libimvirt-perl libintl-perl libintl-xs-perl libip4tc2 libip6tc2 libmime-lite-perl
  libmime-types-perl libmodule-find-perl libmodule-scandeps-perl libnet1
  needrestart python3-protobuf runc tini wmdocker
0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
Need to get 76.8 MB of archives.
After this operation, 321 MB of additional disk space will be used.
Do you want to continue? [Y/n]
 
Seeing errors now so this may take a while.
Googling what I don't understand- Learning as I go.:)

Code:
Package aufs-tools is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'aufs-tools' has no installation candidate

Checked on aufs-tools as a .deb pkg. It's available as OldStable for Buster.
However. this is Devuan 5 that I'm doing this build on.
Long story short:
Devuan package repositories are exclusive. Other repositories, including Debian, Ubuntu, Mint etc, should not be used directly.


Turns out (looking in the Devuan Forum) aufs is no longer used overlayfs is used instead. From other reading I've done overlayfs has to be configured.

Haven't gotten to the build yet and I now see how challenging things can be.

This could take a long time and I don't want to make a super long thread. Our member @CaffeineAddict has given me plenty of good advise, instructions and details.

I can always write an article on this over on my Wix Linux Blog. That is once this build is complete.

@wizardfromoz Your suggestions and ideas are valuable and respected here.

@KGIII Any ideas, thoughts or practices on things in this post and what you think are appreciated.
 
@Alexzee

aufs is not supported by modern kernels, so you should skip to overlayfs from aufs. Just restart your docker daemon with the option:
--storage-driver=overlay2

overlay2 is the preferred storage driver for all currently supported Linux distributions, and requires no extra configuration.
 
@wizardfromoz Your suggestions and ideas are valuable and respected here.

Beyond my paygrade, Alex, but I am watching with interest. ;)
 
Beyond my paygrade, Alex, but I am watching with interest. ;)

Thanks Chris.

Endeavoring in the department of learning how to build and compile plus writing SlackBuild scripts at the same time is going well. Upping my game, applying the advice, instructions, and etc. that Caffine Addict and others have given me are paying off!

No regrets, brother just enjoying riding the waves!
 

Attachments

  • Surf.jpg
    Surf.jpg
    36.2 KB · Views: 45
Tending to a few things that have to be dealt with. Taking a break for a while.
Be back to continue the build and compile of Krita soon.
 

Staff online

Members online


Latest posts

Top