Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #163067
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Universal Build System for C |
| Date | 2021-10-09 17:29 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <sjscgb$rm8$1@dont-email.me> (permalink) |
| References | (7 earlier) <c18afb66-66dd-496b-b57a-3f09de87cdc7n@googlegroups.com> <2f5ffa4f-052d-45d8-a610-c36743ab1c22n@googlegroups.com> <87sfxa6ekf.fsf@nosuchdomain.example.com> <sjrscj$e3b$1@dont-email.me> <51858c1a-2b04-4150-992f-b4da86f52746n@googlegroups.com> |
On 09/10/2021 15:30, Thiago Adams wrote:
> On Saturday, October 9, 2021 at 7:54:18 AM UTC-3, David Brown wrote:
>> On 09/10/2021 05:51, Keith Thompson wrote:
>>> Thiago Adams <thiago...@gmail.com> writes:
>>>> On Friday, October 8, 2021 at 7:30:24 PM UTC-3, Thiago Adams wrote:
>>>> ...
>>>>> For Linux it is using default but I guess it could auto select as well, or show
>>>>> some options..
>>>>
>>>> This is what I found how to change default gcc (because build script has hardcoded gcc)
>>>>
>>>> "
>>>> 1. Open the terminal window in LINUX and execute the command:
>>>> $ which gcc
>>>> This will provide the symbolic link (softlink) to the default version of GCC.
>>>> 2. Navigate to the directory which has this softlink.
>>>> Change the softlink to point to the version of GCC that you want to use.
>>>> For example, for a standard GCC version 4.7 installed (where the compiler command is put at /usr/bin/gcc-4.7),
>>>> this can be done using the following command:
>>>> $ sudo ln -f -s /usr/bin/gcc-4.7 gcc
>>>> "
>>>> from
>>>> https://www.mathworks.com/matlabcentral/answers/454659-how-can-i-change-my-current-gcc-g-version-to-a-supported-one
>>>>
>>>>
>>>> also added
>>>> system(""gcc --version") inside the build script to know
>>>> what version is being used.
>>>>
>>>> this is an extra step , however I guess all linux programmers
>>>> must know about this.
>>>
>>> That's bad advice. Telling users to mess around with system-owned
>>> directories like /usr/bin is dangerous. I know Linux pretty well, and I
>>> don't do that myself.
>>>
>>> On my system, for example, /usr/bin/gcc is a symbolic link to "gcc-9",
>>> which is provided by the "gcc-9" package. That package provides 55
>>> files; the compiler executable is just one of them. If I manually
>>> change just the /usr/bin/gcc symlink, I'm likely to leave my system in
>>> an inconsistent state.
>>>
>>> And g++ (the C++ compiler) is provided by another package "g++9", which
>>> should normally be kept in synch with the gcc package.
>>>
>>> On Ubuntu, the "update-alternatives" command can be used to safely
>>> change the default version of a command. Other systems are likely to
>>> have something similar.
>>>
>> Ubuntu gets that from Debian, and so the same method is usable for other
>> Debian-based distributions.
>>
>> As a general point, if you want to be sure you are using gcc version 9,
>> I'd much rather write "gcc-9" than change the system default. For my
>> embedded work, I have the exact compiler (indeed full toolchain,
>> including library and headers) specified in the project makefile.
>>
>> You can also happily put symbolic links in ~/bin, or /usr/local/bin,
>> giving your own choice of names and linking to whatever versions of
>> programs you want. That too is far better than messing with /usr/bin.
>
> If the name of gcc is fixed like gcc-10 gcc-11 etc..
This may vary by distribution or installation. If the user puts there
own links in ~/bin, they can decide the names themselves.
> I can create the following macro:
>
> #define STR(a) #a
> #define F(a) STR(a)
> #define GCC F(gcc-__GNUC__)
>
> GCC
>
> This macro expand to "gcc-11" "gcc-10" etc..
>
> Then
> gcc-11 build.c && ./build
>
> would use gcc-11 to create the "build script" and the build script would
> use "gcc-11" to compile the target.
>
> It is very nice we can use the preprocessor. For instance
> if the code does not support gcc < 7 I can show an error
>
> #if __GNUC__ < 7
> #error "this build requires gcc > 7"
> #endif
>
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-04 05:33 -0700
Re: Universal Build System for C Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 15:54 +0000
Re: Universal Build System for C fir <profesor.fir@gmail.com> - 2021-10-04 09:26 -0700
Re: Universal Build System for C fir <profesor.fir@gmail.com> - 2021-10-04 09:47 -0700
Re: Universal Build System for C fir <profesor.fir@gmail.com> - 2021-10-04 10:13 -0700
Re: Universal Build System for C fir <profesor.fir@gmail.com> - 2021-10-05 04:12 -0700
Re: Universal Build System for C Guillaume <message@bottle.org> - 2021-10-04 19:49 +0200
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-04 11:00 -0700
Re: Universal Build System for C Bart <bc@freeuk.com> - 2021-10-06 20:37 +0100
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-07 06:18 -0700
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-07 06:25 -0700
Re: Universal Build System for C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-07 07:41 -0700
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-08 14:05 -0700
Re: Universal Build System for C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-08 14:22 -0700
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-08 14:44 -0700
Re: Universal Build System for C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-08 23:25 +0100
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-08 15:37 -0700
Re: Universal Build System for C Bart <bc@freeuk.com> - 2021-10-08 22:51 +0100
Re: Universal Build System for C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-09 01:39 -0700
Re: Universal Build System for C Bart <bc@freeuk.com> - 2021-10-09 11:00 +0100
Re: Universal Build System for C scott@slp53.sl.home (Scott Lurndal) - 2021-10-10 18:09 +0000
8-bit ASCII (was Re: Universal Build System for C) scott@slp53.sl.home (Scott Lurndal) - 2021-10-10 20:55 +0000
Re: Universal Build System for C Bart <bc@freeuk.com> - 2021-10-08 23:05 +0100
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-08 15:30 -0700
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-08 18:12 -0700
Re: Universal Build System for C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-08 20:51 -0700
Re: Universal Build System for C David Brown <david.brown@hesbynett.no> - 2021-10-09 12:54 +0200
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-09 06:30 -0700
Re: Universal Build System for C David Brown <david.brown@hesbynett.no> - 2021-10-09 17:29 +0200
Re: Universal Build System for C Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-10-08 23:39 +0000
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-10-08 17:50 -0700
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-11-22 04:26 -0800
Re: Universal Build System for C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-22 20:39 +0000
Re: Universal Build System for C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-11-22 13:18 -0800
Re: Universal Build System for C Bart <bc@freeuk.com> - 2021-11-22 21:49 +0000
Re: Universal Build System for C scott@slp53.sl.home (Scott Lurndal) - 2021-11-23 14:45 +0000
Re: Universal Build System for C Bart <bc@freeuk.com> - 2021-11-23 16:03 +0000
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2022-04-18 14:39 -0700
Re: Universal Build System for C Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-04-18 22:17 +0000
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2022-04-18 16:07 -0700
Re: Universal Build System for C scott@slp53.sl.home (Scott Lurndal) - 2021-11-23 14:44 +0000
Re: Universal Build System for C Thiago Adams <thiago.adams@gmail.com> - 2021-11-22 16:19 -0800
Re: Universal Build System for C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-23 01:00 +0000
csiph-web