Using non-default compiler to build PPA package

Asked by Jan Dolinár


What is the simplest way to change the compiler used when creating binary package in PPA?

I package an application which doesn't work properly when build with g++-4.2. Unfortunately, that is the default compiler in Hardy. I have tried to avoid it by using
      Build-Depends: g++ (= 4.1) | g++ (>= 4.3)

But this has no effect:
      Checking for already installed source dependencies...
      g++: non-matching version installed (4:4.2.3-1ubuntu6 ! = 4.1)
      g++: would have to downgrade!
      g++: already installed (4:4.2.3-1ubuntu6 >= 4.3 is satisfied)

For some reasons g++ is epoched which I didn't spotted earlier. But even if I specified the epoch in the dependecies, it would probably lead to unsatisfiable dependencies, because of downgrade is not allowed and there is nothing newer in Hardy.

So the question is: what is the easiest way to force the build install and use gcc-4.1?

The only option I see so far is to specify gcc-4.1 in Build-Depends and use it explicitly in Makefile (that is CXX=g++-4.1 instead of CXX=g++). I don't like this solution because I produce packages for all ubuntu versions, so I would have to put an exception in the hardy process and that looks to me as a poor practice :-) So if anyone has better, universal solution, I'll be glad to adopt it...

Question information

English Edit question
Launchpad itself Edit question
No assignee Edit question
Solved by:
Julian Edwards
Last query:
Last reply:
Revision history for this message
LaMont Jones (lamont) said :

The build will try to use the first extant package in an or-list. so Build-Depends: g++-4.3 || g++-4.1 might stand a chance of working (by choosing the newer g++-4.3 instead of g++-4.1 and the attempted downgrade)

In the end, anything that requires a downgrade will fail.

Revision history for this message
Jan Dolinár (dolik-rce) said :

Thanks for answer, but it doesn't really solve the problem because g++-4.3 is not available in hardy. That leaves version 4.1 as my only choice, I'm just asking what is the cleanest and simplest way to force soyuz to use it?

Revision history for this message
Best Julian Edwards (julian-edwards) said :


As Lamont said, "anything that requires a downgrade will fail", so it's not possible to force 4.1.

What you could do is find a backport of 4.3 and include it in your PPA, or add a PPA dependency to someone else's PPA that has it.

Revision history for this message
Jan Dolinár (dolik-rce) said :

Thanks Julian Edwards, that solved my question.

Revision history for this message
Jan Dolinár (dolik-rce) said :

One last comment, mainly for those who will have similar question in future:

It turned out, that the easiest way to solve the problem is to change the dependencies in control file for hardy to "Build-Depends: g++-4.1, ..." because having two compilers side by side doesn't qualify as downgrade. Then I just force make to use it by adding CC=gcc-4.1 to the commandline.