rpm – openSUSE Lizards https://lizards.opensuse.org Blogs and Ramblings of the openSUSE Members Fri, 06 Mar 2020 11:29:40 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.5 AMD Catalyst 15.12 for openSUSE – new makerpm-amd-script is available https://lizards.opensuse.org/2016/03/17/amd-catalyst-15-12-for-opensuse-new-makerpm-amd-script-is-available/ https://lizards.opensuse.org/2016/03/17/amd-catalyst-15-12-for-opensuse-new-makerpm-amd-script-is-available/#comments Thu, 17 Mar 2016 18:41:13 +0000 http://lizards.opensuse.org/?p=11773 AMD has released the new AMD Catalyst 15.12 (Radeon Crimson Edition). My script replaces the existing packaging script with an updated packaging script. It supports up to Kernel 4.5. (Official support up to Kernel 3.19)

Important note: The driver does not work on openSUSE Tumbleweed. Unfortunately, the version of X-server is too new for the driver.

SHA1 is obsolete by now. The script used SHA256 for integrity of the downloaded files.

New Feature from packaging script:

  • systemd support

Resolved Issues:

  • [SWDEV-82980] Ubuntu 15.10 fails when building the .deb packages

Link: AMD Catalyst 15.12 Release Notes

Downloads:

Installation guide (English):
http://en.opensuse.org/SDB:AMD_fglrx#Building_the_rpm_yourself

Bruno Friedmann will build the new RPM packages in the fglrx repository. Stay tune!

If you find any issue with the driver. Don’t hesitate to contact me. I am in contact with AMD and can forward your issue to the right place. Feedback are welcome.

A report of your system is very helpful beside your feedback. You can generate it with the script:
su -c 'sh makerpm-amd-15.12.sh -ur'

Have a lot of fun!

Sebastian
openSUSE member / Official AMD Packaging Script Maintainer for openSUSE
German Blog: openSUSE – proprietären Grafik-Treiber AMD Catalyst 15.12 als RPM installieren

]]>
https://lizards.opensuse.org/2016/03/17/amd-catalyst-15-12-for-opensuse-new-makerpm-amd-script-is-available/feed/ 3
AMD Catalyst 15.11 for openSUSE – new makerpm-amd-script is available https://lizards.opensuse.org/2015/12/05/amd-catalyst-15-11-for-opensuse-new-makerpm-amd-script-is-available/ https://lizards.opensuse.org/2015/12/05/amd-catalyst-15-11-for-opensuse-new-makerpm-amd-script-is-available/#comments Sat, 05 Dec 2015 23:00:55 +0000 http://lizards.opensuse.org/?p=11579 AMD has released the new AMD Catalyst 15.11 (Radeon Crimson Edition). My script replaces the existing packaging script with an updated packaging script. It supports up to Kernel 4.4. (Official support up to Kernel 3.19)

I have adapted the AMD driver to the Kernel 4.4 (rc3). For the moment it works for Kernel 4.4-rc3. Unfortunately the AMD driver has a compatibility issue in combination with the GNOME Desktopmanager and X-Server. As a workaround, I recommend for GNOME another Desktopmanager such as lightdm until the issue is hopefully fixed.

Resolved Issues:

  • [SWDEV-55204] Stuttering when running glxgears with VSync enabled
  • [SWDEV-7339] Intermittent mouse cursor corruption

Link: AMD Catalyst 15.11 Release Notes

Downloads:

Installation guide (English):
http://en.opensuse.org/SDB:AMD_fglrx#Building_the_rpm_yourself

Bruno Friedmann will build the new RPM packages in the fglrx repository. Stay tune!

If you find any issue with the driver. Don’t hesitate to contact me. I am in contact with AMD and can forward your issue to the right place. Feedback are welcome.

A report of your system is very helpful beside your feedback. You can generate it with the script:
su -c 'sh makerpm-amd-15.11.sh -ur'

Have a lot of fun!

Sebastian
openSUSE member / Official AMD Packaging Script Maintainer for openSUSE
German Blog: openSUSE – proprietären Grafik-Treiber AMD Catalyst 15.11 als RPM installieren

]]>
https://lizards.opensuse.org/2015/12/05/amd-catalyst-15-11-for-opensuse-new-makerpm-amd-script-is-available/feed/ 3
AMD Catalyst 15.9 for openSUSE – new makerpm-amd-script is available https://lizards.opensuse.org/2015/09/27/amd-catalyst-15-9-for-opensuse-new-makerpm-amd-script-is-available/ https://lizards.opensuse.org/2015/09/27/amd-catalyst-15-9-for-opensuse-new-makerpm-amd-script-is-available/#comments Sun, 27 Sep 2015 16:15:14 +0000 http://lizards.opensuse.org/?p=11536 AMD has released the new AMD Catalyst 15.9. My script replaces the existing packaging script with an updated packaging script. It supports up to Kernel 4.2. (Official support up to Kernel 3.19)

Important note: The first beta version of openSUSE Leap (future openSUSE 42.1) was released a few days ago. However, the AMD driver has not been adapted yet to the new upcoming openSUSE version. In the next days I will working on this and release a new update for this script.

Important note 2: After some experimentation with the GNOME Desktopmanager, unfortunately it does not work with the driver. Because actually something seems to be amiss. To this end, I will contact the AMD developers. As a workaround, I recommend for GNOME another Desktopmanager such as lightdm until the issue is fixed.

Resolved Issues:

  • [425910] Driver installation sometimes fails on Ubuntu 14.04.3
  • [424450] Company of Heroes® 2 – Game crashes while running the performance test
  • [424794] Middle-earth™: Shadow of Mordor – Corruption observed in game
  • [424882] DIRT® Showdown – Corruption observed in game
  • [425234] DIRT® Showdown – Game crashes after the loading screen
  • [424802] DOTA™ 2 – Application hang observed while exiting the game
  • [424255] AMD Catalyst™ Installer removing EGL links resulting in Xserver/Xorg load failure
  • [423471] Unable to switch desktop mode after installing AMD Catalyst™ driver
  • [423735] Renaming Counter-Strike: GO and other Steam game binary improves performance

Known Issues:

  • [419960]: Vari-Bright on some configurations is not decreasing brightness as expected

Link: AMD Catalyst 15.9 Release Notes

Downloads:

Installation guide (English):
http://en.opensuse.org/SDB:AMD_fglrx#Building_the_rpm_yourself

Bruno Friedmann will build the new RPM packages in the fglrx repository. Stay tune!

If you find any issue with the driver. Don’t hesitate to contact me. I am in contact with AMD and can forward your issue to the right place. Feedback are welcome.

A report of your system is very helpful beside your feedback. You can generate it with the script:
su -c 'sh makerpm-amd-15.9.sh -ur'

Have a lot of fun!

Sebastian
openSUSE member / Official AMD Packaging Script Maintainer for openSUSE
German Blog: openSUSE – proprietären Grafik-Treiber AMD Catalyst 15.9 als RPM installieren

]]>
https://lizards.opensuse.org/2015/09/27/amd-catalyst-15-9-for-opensuse-new-makerpm-amd-script-is-available/feed/ 3
AMD Catalyst 15.7 for openSUSE – new makerpm-amd-script is available https://lizards.opensuse.org/2015/07/12/amd-catalyst-15-7-for-opensuse-new-makerpm-amd-script-is-available/ Sun, 12 Jul 2015 15:36:38 +0000 http://lizards.opensuse.org/?p=11497 AMD has released the new AMD Catalyst 15.7. My script replaces the existing packaging script with an updated packaging script. It supports up to Kernel 4.1. (Official support up to Kernel 3.19)

Important note: This driver supports also X-Server 1.17 on Tumbleweed. GNOME Desktopmanager (gdm) is working partially, so you need a workaround. Who has activated the automatic user login in GNOME and want to make a user change, they get a black screen on TTY-console and the login manager seems to be crashed. This issue can be solved when the automatic user login is disabled in GNOME.

For GNOME user with gdm: Execute the following command as root after the installation of the AMD driver and before restart the machine:
sh makerpm-amd-15.7.sh --install-gdm-fix

To revert the changes:
sh makerpm-amd-15.7.sh --uninstall-gdm-fix

New Features:

  • AMD PowerXpress support for laptops equipped with Intel 6th generation (Skylake) CPUs
  • Linux Platform Atomics & SVM Fine Grain Buffer support for Carrizo APUs
  • Multi-Device support for OpenCL 2.0

Resolved Issues:

  • [421317] Segmentation fault observed while launching some OpenGL games in RHEL7.1
  • [419365] Error message observed during installation through rpm package in RHEL 6.5, 7.0
  • [419162] System hangs while running Dying Light
  • [421858] clinfo could not recognize up to four GPU devices

Known Issues:

  • [419960]: Vari-Bright on some configurations is not decreasing brightness as expected

Link: AMD Catalyst 15.7 Release Notes

Downloads:

Installation guide (English):
http://en.opensuse.org/SDB:AMD_fglrx#Building_the_rpm_yourself

Bruno Friedmann will build the new RPM packages in the fglrx repository. Stay tune!

If you find any issue with the driver. Don’t hesitate to contact me. I am in contact with AMD and can forward your issue to the right place. Feedback are welcome.

A report of your system is very helpful beside your feedback. You can generate it with the script:
su -c 'sh makerpm-amd-15.7.sh -ur'

Have a lot of fun!

Sebastian
openSUSE member / Official AMD Packaging Script Maintainer for openSUSE
German Blog: openSUSE – proprietären Grafik-Treiber AMD Catalyst 15.7 als RPM installieren

]]>
AMD Catalyst 15.5 for openSUSE – new makerpm-amd-script is available https://lizards.opensuse.org/2015/06/15/amd-catalyst-15-5-for-opensuse-new-makerpm-amd-script-is-available/ https://lizards.opensuse.org/2015/06/15/amd-catalyst-15-5-for-opensuse-new-makerpm-amd-script-is-available/#comments Mon, 15 Jun 2015 20:58:57 +0000 http://lizards.opensuse.org/?p=11476 AMD has released the new AMD Catalyst 15.5. Unfortunately AMD has forgot to update the packaging script. The new feature (SLED 12) is currently broken by the original AMD Catalyst 15.5. My script corrects this mainly issue with an updated packaging script. It included the Kernel patches for 4.0 and 4.1.

Warning: This driver based on an old development fork and does not support X-Server 1.17 on Tumbleweed. GNOME Desktopmanager (gdm) is also broken for the moment. My suggestion for you, stay on the latest AMD Catalyst 15.3 Beta.

New Features:

  • Support for SUSE® Linux Enterprise Desktop 12

Resolved Issues:

  • [417630]: Fixes the issue of discrete GPU not being powered off in Power-Saving mode on some PowerXpress AMD GPU + AMD APU platforms
  • [416499]: Fixes minor screen corruption when resuming from S3 caused by display hot plugging

Known Issues:

  • [419960]: Vari-Bright on some configurations is not decreasing brightness as expected

Link: AMD Catalyst 15.5 Release Notes

Downloads:

Installation guide (English):
http://en.opensuse.org/SDB:AMD_fglrx#Building_the_rpm_yourself

Bruno Friedmann will build the new RPM packages in the fglrx repository. Stay tune!

If you find any issue with the driver. Don’t hesitate to contact me. I am in contact with AMD and can forward your issue to the right place. Feedback are welcome.

A report of your system is very helpful beside your feedback. You can generate it with the script:
su -c 'sh makerpm-amd-15.5.sh -ur'

Have a lot of fun!

Sebastian
openSUSE member / Official AMD Packaging Script Maintainer for openSUSE
German Blog: openSUSE – proprietären Grafik-Treiber AMD Catalyst 15.5 als RPM installieren

]]>
https://lizards.opensuse.org/2015/06/15/amd-catalyst-15-5-for-opensuse-new-makerpm-amd-script-is-available/feed/ 1
zypper tab-completion and some thoughts https://lizards.opensuse.org/2015/04/26/zypper-tab-completion-and-some-thoughts/ Sun, 26 Apr 2015 19:45:11 +0000 http://lizards.opensuse.org/?p=11367 Today I spent some hours implementing nice tab-completion for zypper. There was already a lot done 6 years ago, but the part about installing/removing packages was missing.

Now the thinking part is about the speed. For the tab-completion I needed a list of installed packages and of course we have that in our RPM database (using berkeley DB as a backend). However querying the list with rpm -qa already took over a second on a modern and fast system. On my poor netbook with a cold cache, it took 25 seconds (5 secs on second try with hot cache)… And the point is that you probably do not want to wait 5 seconds for your tab-completion to react.

So to avoid this problem, I used caching via make to produce a better format (plain text). This is then post-processed with sed in a fraction of a second – a speedup factor somewhere between 15 and 150. This makes a big difference.

In the end, I still wonder why plain text is so much faster than a DB. I guess, one reason is that the DB is optimized for retrieval of single values – e.g. rpm -q bash – this is very fast (but even there an egrep “^bash-[^-]+-[^-]+$” is more than twice as fast).

I still want to optimize zypper for better speed, so that a search might some day return in under 2 seconds. One idea for that is to not parse all those config+repo files every time, but only when they change. It could use mmaped files under /var/cache/zypp* as memory to store the binary representations. Though it might become complicated, if dynamic structures such as linked lists are involved.

The future will be interesting…

]]>
AMD Catalyst 15.3 Beta for openSUSE – new makerpm-amd-script is available https://lizards.opensuse.org/2015/04/08/amd-catalyst-15-3-beta-for-opensuse-new-makerpm-amd-script-is-available/ https://lizards.opensuse.org/2015/04/08/amd-catalyst-15-3-beta-for-opensuse-new-makerpm-amd-script-is-available/#comments Wed, 08 Apr 2015 14:34:50 +0000 http://lizards.opensuse.org/?p=11327 AMD has released the new AMD Catalyst 15.3 Beta. They have not yet released a public beta driver for all other distributions. It is currently available for Ubuntu. *sigh* So, it is a bit hard work to implement this in the makerpm-amd-script to replace the latest AMD Catalyst 14.12 with AMD Catalyst 15.3 Beta. So do not confused if the script downloads the AMD Catalyst 14.12. 🙂

Unfortunately there is no release notes from AMD. This update can solve the issue with PowerXpress but I can not really verified this because lack of such hardware.

Another side note I have implemented a workaround in the script to get the driver works with the GNOME Displaymanager + GNOME. It is a little cruel hack but it works for the moment. Thanks to the user that they posted the article in my blog. 😉

For GNOME user with gdm: Execute the following command as root after the installation of the AMD driver and before restart the machine:
sh makerpm-amd-15.3-beta.sh --install-gdm-fix
If you update the AMD driver, so the workaround does not work anymore. It is important that you do not delete the file /amd_xversion and is needed for the workaround.

To revert the changes:
sh makerpm-amd-15.3-beta.sh --uninstall-gdm-fix

Before I forget it: All user from openSUSE Tumbleweed can also install the driver. But remember, Tumbleweed is under heavy development. I can not guarantee that the driver works in the future yet.

Downloads:

Installation guide (English):
http://en.opensuse.org/SDB:AMD_fglrx#Building_the_rpm_yourself

The above named installation guide is only for the stable driver but you can adapt it for the beta driver.

Bruno Friedmann will build the new RPM packages in the fglrx repository. Stay tune!

If you find any issue with the driver. Don’t hesitate to contact me. I am in contact with AMD and can forward your issue to the right place. Feedback are welcome.

A report of your system is very helpful beside your feedback. You can generate it with the script:
su -c 'sh makerpm-amd-15.3-beta.sh -ur'

Have a lot of fun!

Sebastian
openSUSE member / Official AMD Packaging Script Maintainer for openSUSE

German Blog: openSUSE – proprietären Grafik-Treiber AMD Catalyst 15.3 Beta als RPM installieren

]]>
https://lizards.opensuse.org/2015/04/08/amd-catalyst-15-3-beta-for-opensuse-new-makerpm-amd-script-is-available/feed/ 5
openSUSE and GCC part 9: Open Build Service why should I use it? https://lizards.opensuse.org/2013/12/11/opensuse-and-gcc-part-9/ Wed, 11 Dec 2013 13:52:40 +0000 http://lizards.opensuse.org/?p=10255 Imagine yourself in place where: you have succeeded to create best open source project ever appeared in face of earth. Your project has most fabulous source management system ever imagined (mostly coded by you) and you release tar balls often with plenty new neat features. You have managed that your project users provide some binary builds for Windows, Mac OS X and some bunch of Linux distributions. So your ride is smooth and pleasant (Mr. Maslow just waves to you from bottom of pyramid). Then black clouds arise and some Linux build manager who is doing binary builds for spefic important Linux distribution just vanishes upon the earth or you notice it would be nice to support more wide range of distributions than you allready have. Then you should consider using Open Build Service or openSUSE version of it known as OBS.

OBS in nutshell

Open Build Service started as named ‘openSUSE build Service’ but name changed long time a go. Basic idea is that you can compile source package to binary package and do it on many different distributions and architectures same time. It sounds good and mostly it’s better than that.
So last time I showed how to make RPM package and now I’ll transfer it to OBS and build it. For not wasting time I have already made project for it under my home project. In project page there is plenty of stuff most of them we talk in last episode. As you can notice OBS has very good and clean web gui. All thought I’m hardcore fan of shell I really enjoy OBS webgui.

Show me code

If you sign up for OBS you get your own home directory and you can create sub-projects there like I did home:illuusio:example/sdl_displaybitmap . Under package there is plenty of distributions currently build: Debian, Fedora, Arch and openSUSE of course. ‘sdl_displaybitmap.spec’ is the same SPEC file as used last time with out any tuning and same goes with tar-ball file ‘sdl_displaybitmap-1.0.tar.bz2’. Other files you can ignore in this point.
OBS thing is you can just push (with some excuses and oopses) your rpm spec file and get it compile. Now you should really read openSUSE packaging documentation because if you just gun ho forward like me did at the begin you gonna suffer and then suffer little more and then you probably die in misery and your children will be send in salt mines.

This was it? now what?

Look around and think if it’s for you. I like OBS enough to drop you a tip about it but it’s just my opinion. Take some time and learn how to use OBS and probably command line util ‘osc‘. Then you start to make extraneous RPM packages with OBS and start distributing your best-on-earth open source project binary packages for multiple Linux distributions with ease and speed you never have seen before or you just keep on doing what you are doing.

But but I got closed source application and want to use this system

Okay this is shameless commercial part! Don’t read any futher if you don’t want to. Then you can contact me and i’ll consult you out or read one more what reads here. Like you probably find out they have version of OBS that is open source and if you set it up all by yourself it doesn’t cost you a dime or save some time and buy support from B1 . it’s up to you again ;).

]]>
openSUSE and GCC part 8: RPMs and how to write them https://lizards.opensuse.org/2013/12/03/opensuse-and-gcc-part-8-rpms-and-how-to-write-them/ Tue, 03 Dec 2013 09:30:00 +0000 http://lizards.opensuse.org/?p=10208 It seems this it’s already 8 of this 10 part series of using GCC with openSUSE. This time topic is: RPM. RPM started as Redhat Package Manager and then it involved to RPM package manager (self explaining acronym like GNU). RPM packages are just files containing all the needed stuff to install application, font or something else in to openSUSE system.
RPM is currently wide adopted in Linux distributions openSUSE, embedded Yocto, Fedora and Madriva for name few. Although Yocto can use Debian packages also as base. I have been using an example program to show how to develop very easy application with openSUSE and GCC. Currently it uses Autotools tools. Take my advise your application is not worth of anything if you can’t delivery it to users. Most of the applications (especially closed source) under Linux are distributed as tar-ball format. RPM is not about having Windows style setup it’s about knowing what is installed in you system.

RPM agnostics

There is actually two kinds of RPMs. Binary RPM and then there is Source RPM. Source RPM contains everything needed to compile this package again. Source rpm ending is ‘.src.rpm’ or ‘nosrc.rpm’. Binary RPM is architecture specific. So if you have ‘arm7v.rpm’ it wont run your x86_64 or x86 machine because it’s ARM7 binary code. There is also noarch.rpm that is architectural non specific.
In openSUSE traditionally if you build RPM it goes to ‘/usr/src/packages’ directory and there is sub directories

BUILD/ - Building is done here
SOURCES/ - Contains needed sources for building including patches
SRPMS/ - Where Source RPMS are placed after build
BUILDROOT/ - This is ROOT place where make install places installed files (because you don't want them to go real root dir) 
RPMS/ - All the RPMs are placed here (It contains i686, x86_64 and noarch subdirs where those arch files are placed)
SPECS/ - Where .spec files are placed

So if you build i686 RPM with your x86 openSUSE then it would go to ‘/usr/src/packages/RPMS/i686’ directory and Source RPM ‘/usr/src/packages/SRPMS’ directory.

Example

Now you should read Part 7 and part 6 of this series to have example application and autotools installed. then we install rpm-build

zypper install rpm-build

and make distribution tar-ball of sdl_displaybitmap with

make dist

there should be ‘sdl_displaybitmap-1.0.tar.bz2’ file now in same directory. then copy this SPEC file to file named ‘sdl_displaybitmap.spec’ in same directory you have ‘sdl_displaybitmap-1.0.tar.bz2’

Name:           sdl_displaybitmap
Version:        1.0
Release:        1%{?dist}
Summary:        Some SDL Sample

Group:          Amusements/Toys/Other
License:        SUSE-Public-Domain
URL:            http://content.gpwiki.org/index.php/SDL:Tutorials:Displaying_a_Bitmap
Source0:        sdl_displaybitmap-1.0.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  gcc
BuildRequires:  SDL_image-devel
BuildRequires:  libtool
BuildRequires:  automake
BuildRequires:  autoconf

%description
Small example how to use SDL to display bitmap

%prep
%setup -q

%build
%configure
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
# There is nothing to install so we do it with hand
#make install DESTDIR=$RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}
cp SDL_DisplayBitmap  $RPM_BUILD_ROOT%{_bindir}
chmod +x $RPM_BUILD_ROOT%{_bindir}/*
cp image.bmp $RPM_BUILD_ROOT%{_datadir}/%{name}

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc LICENSE.TXT
%{_bindir}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*


%changelog

and copy our tar-ball to ‘/usr/src/packages/SOURCES’. After that we build rpmbuild command to create RPM packages

rpmbuild -ba sdl_displaybitmap.spec

If everything goes right you should have this RPM in ‘/usr/src/packages/RPMS/YOURARCHHERE/sdl_displaybitmap-1.0-1.YOURARCHHERE.rpm’ and SRPM in ‘/usr/src/packages/SRPMS/sdl_displaybitmap-1.0-1.src.rpm’. You can check with less that what files it contains

less /usr/src/packages/RPMS/YOURARCHHERE/sdl_displaybitmap-1.0-1.YOURARCHHERE.rpm

OBS If you install this RPM it won’t work! Application only works if you go to folder ‘/usr/share/sdl_displaybitmap’ and run it there. Next time we patch our app to work from other places also.

What does this mean?

There is better documentation else where than I can write. For openSUSE conventions see Packaging in Wiki. If you curious read it from there and learn. Next time we make OBS (openSUSE Build Service) build from this RPM and last part is how we use OBS to create also Debian, Ubuntu and Fedora packages from our marvelous app.

]]>
openSUSE and GCC part 4: Pkg-config and what one can do with it https://lizards.opensuse.org/2013/10/28/opensuse-and-gcc-part4/ Mon, 28 Oct 2013 16:37:38 +0000 http://lizards.opensuse.org/?p=10083 When I re-booted my blogging habits with very UN-sexy and technical topic ‘GNU C Compiler and how to make it with openSUSE’. I thought nobody bothers to read these because A) Everyone who reads openSUSE blogs are PRO B) everyone wants to do Javascript, Python or ‘Put your script language here not C. I can tell actually C ain’t that bad you just have to shoot yourself to leg and then learn how to walk again.
Last blog entry was about ‘openSUSE and GCC part 3: RPM devel packages‘ someone (thanks for pointing that out really!) noted that I should fix C-Code example I was stunned! There were someone that really readied blog entry. Okay he/she didn’t say did he/she like it but some one read it.
I have one real reason to this blog-stuff. I hope I have found something like this when I young and I was starting my journey in Linux land. Currently there is so many more people now in populating it and it’s coming up fast. So If you find errors or don’t understand something be welcome to ask or want to know about something specific let me know! Now we get on today’s topic that is ‘pkg-config and what one can do with it’.

Pkg-config makes things easy/complicated (choose one)

You can live you whole C developer life with Linux and GCC without ever toughing ‘pkg-config‘. pkg-config is just something that can make you life easier with C. It’s not easy to say in couple of words what it does but closest I can get it provides information how to compile application with specific C-library. In other words if you read blog before there were these bare ‘gcc’ library entries in command-line (-lname stuff).
With more complicated libaries: like GTK+ or SDL you can get yourself wondering what libraries shall I include and what not that I can get my application build. Every self respecting developer wants to keep library dependencies as low as possible. So if you don’t want to wonder anymore you can use ‘pkg-config’.

So what it really does?

Last time I promised SDL_image 1.2 example as it’s little bit more complicated to get build. Actually it’s not that complicated but it’s simple example library and you get nice GUI stuff. First we have to zypper or YaST pkg-config, unzip and SDL_image-devel packages so we can use and link against SDL_image.

zypper install pkg-config SDL_image-devel unzip

after you have managed to install it you can download this blog example application made by Ryan Clark from here: ‘SDL_DisplayBitmap.zip‘. It comes from nice SDL gaming wiki (This tutorial actually) and so if you are interested making games with SDL 1.2 or 2.0 you should pop there. You can download files and unzip it or you can crap same source below and save it as ‘SDL_DisplayBitmap.c’ if you do that remember to have some BMP-image in same directory where you compile named: ‘image.bmp‘. Real nerds goes with unzip. If you do it like me it goes like this.

unzip SDL_DisplayBitmap.zip
cd SDL_DisplayBitmap

Or code for copying

// THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION
// AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN.
//
// THE ORIGINAL AUTHOR IS RYAN CLARK.
//
// THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY
// OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF
// MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE,
// ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE
// RESULTING FROM THE USE, MODIFICATION, OR
// REDISTRIBUTION OF THIS SOFTWARE.

#include <stdlib.h>
#include <SDL/SDL.h&lgt;

int main(int argc, char *argv[])
{
	SDL_Surface *screen;	//This pointer will reference the backbuffer
	SDL_Surface *image;	//This pointer will reference our bitmap sprite
	SDL_Surface *temp;	//This pointer will temporarily reference our bitmap sprite
	SDL_Rect src, dest;	//These rectangles will describe the source and destination regions of our blit
	
	//We must first initialize the SDL video component, and check for success
	if (SDL_Init(SDL_INIT_VIDEO) != 0) {
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}
	
	//When this program exits, SDL_Quit must be called
	atexit(SDL_Quit);
	
	//Set the video mode to fullscreen 640x480 with 16bit colour and double-buffering
	screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF | SDL_FULLSCREEN);
	if (screen == NULL) {
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}
	
	//Load the bitmap into a temporary surface, and check for success
	temp = SDL_LoadBMP("image.bmp");
	if (temp == NULL) {
		printf("Unable to load bitmap: %s\n", SDL_GetError());
		return 1;
	}
	
	//Convert the surface to the appropriate display format
	image = SDL_DisplayFormat(temp);
	
	//Release the temporary surface
	SDL_FreeSurface(temp);
	
	//Construct the source rectangle for our blit
	src.x = 0;
	src.y = 0;
	src.w = image->w;	//Use image->w to display the entire width of the image
	src.h = image->h;	//Use image->h to display the entire height of the image
	
	//Construct the destination rectangle for our blit
	dest.x = 100;		//Display the image at the (X,Y) coordinates (100,100)
	dest.y = 100;
	dest.w = image->w;	//Ensure the destination is large enough for the image's entire width/height
	dest.h = image->h;
	
	//Blit the image to the backbuffer
	SDL_BlitSurface(image, &src, screen, &dest);
	
	//Flip the backbuffer to the primary
	SDL_Flip(screen);
	
	//Wait for 2500ms (2.5 seconds) so we can see the image
	SDL_Delay(2500);
	
	//Release the surface
	SDL_FreeSurface(image);
	
	//Return success!
	return 0;
}

I chose this one because it doesn’t have any compiling aid for poor fellow in ZIP. So we can compile it in openSUSE and most of Linux distros like this:

gcc -o SDL_Display Bitmap SDL_DisplayBitmap.c $(pkg-config --libs --cflags SDL_image)
./SDL_Display

You should just see nice spaceship for 2.5 seconds nothing more or you own nice BMP-image.

Do I have to be BASH wizard and what even is BASH?

If you are reading this in openSUSE you probably use BASH (Bourne Again Shell) and that is all I want to say about that. It’s not the topic and you can forget all about it. You don’t have to be wizard of BASH to understand what happens in that sentence above. again we are compiling with ‘gcc‘ file named ‘SDL_DisplayBitmap.c‘ to binary ‘SDL_DisplayBitmap‘. New stuff starts after that. It just tells to BASH ask from ‘pkg-config’ libraries and needed c-flags that comes with SDL_image and attach them here. If you just run you get something like this

pkg-config --libs --cflags SDL_image
-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL  -lSDL_image -lSDL -lpthread

So compile string is actual then

gcc -o SDL_Display Bitmap SDL_DisplayBitmap.c -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL  -lSDL_image -lSDL -lpthread

But in every distro tends to tune these cflags stuff and every release of ‘SDL_image’ can tune needed libraries. This what you don’t want to know anything about! You don’t want to hassle openSUSE’s or Fedora’s or Ubuntu’s global building flags or include neither library locations by hand. You should just go with the automatic ‘pkg-config’ way. If I can give you one bit of advise other than always use suncream for libraries have ‘pkg-config’-config files and use them. Next we get on ‘make’ and Makefiles. As I’m too lazy to copy’n’paste my ‘gcc‘ strings here.

]]>