|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I can't believe I've just spent an entire day writing Makefiles... At
this rate, it would almost be simpler to just write a loop to compile
every source file in every directory and then link them all! But, alas,
it turns out that you have to actually link them in the right order, or
it doesn't work.
I also enjoy how if you try to link an executable, it whines about
unresolved symbols, but if you link an SO file, it's NOT considered an
error to have missed half of the necessary object files... (!)
On the plus side, as a result of this, I got our Makefile down from 22KB
to 4KB...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 26/05/2016 20:11, Orchid Win7 v1 a écrit :
> I can't believe I've just spent an entire day writing Makefiles... At this rate, it
would almost be simpler to just write a loop to compile every source file in every
directory and then link them all! But, alas, it turns out that you have to actually
link them in the
> right order, or it doesn't work.
>
> I also enjoy how if you try to link an executable, it whines about unresolved
symbols, but if you link an SO file, it's NOT considered an error to have missed half
of the necessary object files... (!)
>
> On the plus side, as a result of this, I got our Makefile down from 22KB to 4KB...
Shared lib (.so) are allowed to be completed later by other libs, or even the loading
binary. It's at runtime that you will get your problems.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 26/05/2016 21:28, Le_Forgeron a écrit :
> Le 26/05/2016 20:11, Orchid Win7 v1 a écrit :
>> I can't believe I've just spent an entire day writing Makefiles... At this rate, it
would almost be simpler to just write a loop to compile every source file in every
directory and then link them all! But, alas, it turns out that you have to actually
link them in the
>> right order, or it doesn't work.
>>
>> I also enjoy how if you try to link an executable, it whines about unresolved
symbols, but if you link an SO file, it's NOT considered an error to have missed half
of the necessary object files... (!)
>>
>> On the plus side, as a result of this, I got our Makefile down from 22KB to 4KB...
>
> Shared lib (.so) are allowed to be completed later by other libs, or even the
loading binary. It's at runtime that you will get your problems.
>
Another trick against the "right order" of linking: put everything but the main in a
single archive library ( .a ).
Then compile the main source into a binary with the library on the command line.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I can't believe I've just spent an entire day writing Makefiles... At
> this rate, it would almost be simpler to just write a loop to compile
> every source file in every directory and then link them all! But, alas,
> it turns out that you have to actually link them in the right order, or
> it doesn't work.
Isn't there some tool to do that automatically?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 27.05.2016 um 12:31 schrieb scott:
>> I can't believe I've just spent an entire day writing Makefiles... At
>> this rate, it would almost be simpler to just write a loop to compile
>> every source file in every directory and then link them all! But, alas,
>> it turns out that you have to actually link them in the right order, or
>> it doesn't work.
>
> Isn't there some tool to do that automatically?
Absolutely. It is called "make", and needs a Makefile to work ;)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>>> I can't believe I've just spent an entire day writing Makefiles... At
>>> this rate, it would almost be simpler to just write a loop to compile
>>> every source file in every directory and then link them all! But, alas,
>>> it turns out that you have to actually link them in the right order, or
>>> it doesn't work.
>>
>> Isn't there some tool to do that automatically?
>
> Absolutely. It is called "make", and needs a Makefile to work ;)
Oh, what you can use make to make a makefile? Sounds like some IOCCC
entry...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 2016-05-27 08:39, also sprach clipka:
> Am 27.05.2016 um 12:31 schrieb scott:
>>> I can't believe I've just spent an entire day writing Makefiles... At
>>> this rate, it would almost be simpler to just write a loop to compile
>>> every source file in every directory and then link them all! But, alas,
>>> it turns out that you have to actually link them in the right order, or
>>> it doesn't work.
>>
>> Isn't there some tool to do that automatically?
>
> Absolutely. It is called "make", and needs a Makefile to work ;)
It's weird that in 2016 a 1980s program is still in charge of assembling
large swaths of code. Ant /tried/ to take over, but that's even worse.
--
dik
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 27/05/2016 14:39, clipka a écrit :
> Am 27.05.2016 um 12:31 schrieb scott:
>>> I can't believe I've just spent an entire day writing Makefiles... At
>>> this rate, it would almost be simpler to just write a loop to compile
>>> every source file in every directory and then link them all! But, alas,
>>> it turns out that you have to actually link them in the right order, or
>>> it doesn't work.
>>
>> Isn't there some tool to do that automatically?
>
> Absolutely. It is called "make", and needs a Makefile to work ;)
>
Actually you can ask gcc/g++ to output the dependencies on sources files. Then you can
have them read back by "make".
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 26/05/2016 08:28 PM, Le_Forgeron wrote:
> Le 26/05/2016 20:11, Orchid Win7 v1 a écrit :
>> I also enjoy how if you try to link an executable, it whines about unresolved
symbols, but if you link an SO file, it's NOT considered an error to have missed half
of the necessary object files... (!)
>
> Shared lib (.so) are allowed to be completed later by other libs, or even the
loading binary.
Presumably this requires the executable to load everything in exactly
the right order though?
> It's at runtime that you will get your problems.
Indeed. This is what I feared... So at some point, when the program is
running, it will suddenly segfault for no apparent reason, and it will
be mathematically impossible to ever determine why. Great.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 26/05/2016 08:31 PM, Le_Forgeron wrote:
> Another trick against the "right order" of linking: put everything but the main in a
single archive library ( .a ).
>
> Then compile the main source into a binary with the library on the command line.
Heh, don't even get me started on archive files!
I had the "brilliant idea" of turning each folder into an archive, and
then linking those together. Trouble is... it only works 95% of the
time. About 5% of the time, the resulting object behaves differently
(i.e., wrong). GTest in particular seems to not like it. I have no idea why.
I stripped all traces of .a files out of the Makefile, and half my
problems went away...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |