English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 20 October 2014, 00:03   #1
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
gcc .lib

I have gotten my project to compile with GCC (was using SAS/C) but I can't get it to link the reaction.lib. How do I do this from shell and makefile.
mritter0 is offline  
Old 20 October 2014, 00:49   #2
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
on the shell, did you tried this: gcc code.c reaction.lib -o code.exe ?
in the makefile just add reaction.lib at the end of the lines with your files to be compiled.

may work, maybe not

edit: post your makefile and some error messages. may help to find a solution.
emufan is offline  
Old 20 October 2014, 11:04   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
IIRC gcc does not like .lib files, it needs .a files instead. There should be a libtoa program somewhere, probably coming with gcc.

Anyway, what is in reaction.lib you cannot work around?
thomas is offline  
Old 20 October 2014, 17:06   #4
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
thomas is right, but wrong tool name - read full article here:
Quote:
Optionally I copied over the reaction.lib file too, but the doc says it will only work with SAS/C.
...
From your Ram: folder run hunk2aout amiga.lib reaction.lib(reaction.lib is optional)
This will create an a.out object file for every lib function in the amiga.lib hunk file.
(and any other lib files you include in your ram: folder and command line)
There will be many with names of obj*.
emufan is offline  
Old 20 October 2014, 17:23   #5
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
When you've converted from .lib to .a format, use
-lreaction
to link with Reaction. GCC (or LD) will look for "libreaction.a" in the default library directories, which are usually hard-coded into GCC, but you can specify additional directories with
-Lsome:path/
Leffmann is offline  
Old 20 October 2014, 18:49   #6
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
I have to link the reaction.lib for these functions:

ChooserLabels(), FreeChooserLabels(), GetAttrs()

If there is a way to not use the lib, that would be great.
mritter0 is offline  
Old 20 October 2014, 20:01   #7
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
the hunk2aout doesnt work here with reaction.lib. but on amiga.org i found a hint to a replacement for reaction.lib:
Stephan Rupprecht PD Software - reactionlib.lha 12K 03-04-03 reaction.lib replacement
your three functions are listed, so this may work. give it a try.

Last edited by emufan; 20 October 2014 at 20:10.
emufan is offline  
Old 21 October 2014, 11:23   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Theoretically you can use vlink to convert from any supported format to another. But it is recommended to split all the modules from reaction.lib into single object files first.

Otherwise you can get a single module with all functions from reaction.lib converted to a.out format like this:
Code:
vlink -baoutsun020 -Bforcearchive -r -o reaction.o reaction.lib
phx is offline  
Old 21 October 2014, 21:22   #9
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
I am at work and have not tried anything yet. Keep the posts coming, please.

What I don't understand is that if it is this "big of a deal" to link reaction.lib with GCC, why is there no reference to it in SDK? Why isn't there a converted lib already in there?

GCC is the preferred compiler for OS4.x. How is everyone else linking the lib? Or is it just an OS3.x issue?

Hopefully I will get a chance to try some ideas out tonight.
mritter0 is offline  
Old 22 October 2014, 00:52   #10
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
I had the bright idea of compiling the source myself, using SAS/C on OS3.9, and not link the original lib, from Stephan Rupprecht's source above. The window opens, gadgets laid out, won't respond to any input.

From what I can tell this call
Code:
	GetAttrs(Objects[OID_WINDOW],
		WINDOW_SigMask,				&SignalsMask,
	TAG_DONE);
isn't been handled correctly??? The next call, Wait(), doesn't get any signals.

Last edited by mritter0; 22 October 2014 at 00:58.
mritter0 is offline  
Old 27 November 2014, 19:48   #11
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
I tried this again today.....same problem. First call of any function in the "lib" freezes execution.

It was intended for VBCC and GCC. I am using SAS/C. Some conflict maybe?
mritter0 is offline  
Old 28 November 2014, 13:00   #12
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by mritter0 View Post
I tried this again today.....same problem. First call of any function in the "lib" freezes execution.
When your freeze is perfectly reproducible, then it should be no problem to use a debugger and analyze the cause of the problem.

Quote:
It was intended for VBCC and GCC. I am using SAS/C. Some conflict maybe?
VBCC and SAS/C are very compatible. Same ABI, same object and library format.
phx is offline  
Old 25 October 2018, 14:33   #13
alpyre
Registered User
 
Join Date: Jul 2008
Location: Samsun / Turkey
Posts: 66
Four years and no proggress on this? What a shame! I think we should solve this for all... so here we go!

I was preparing platform independent cross-compiler "HelloWorld" templates for the next update of my Atom package and realized that I can't compile my reaction HelloWorld for OS3 target because a reaction linker was missing for gcc. After some search I found out that this happens to be the only forum thread on the web about this problem.

Before we start thanks to mritter0 for the thread and all the repliers for all the valuable information.

Firstly what does not work:
- hunk2aout on reaction.lib does not work (no objects are extracted)
- vlink -baoutsun020 -Bforcearchive -r -o reaction.o reaction.lib seems to work fine but when you try compile your code it crashes the ld.

Here's what I did:
- I've downloaded the reaction.lib replacement by Stephan Rupprecht (as emufan mentioned above).
- Opened the c source on my IDE and enabled the auto init section:
Code:
#if 0 /* Enable it, if you need the autoinit code 
        (some are opened by the default init code)! */
- Within that section, I edited the libs[] array initialization as below to avoid confusing "near initialization" warnings by gcc.
Code:
 libs[] = {
            {(STRPTR)"window.class",       40L, &WindowBase},
            {(STRPTR)"requester.class",    42L, &RequesterBase},
            ...
            {(STRPTR)"images/glyph.image", 40L, &GlyphBase}
          };
- Saved and compiled it as below:
Code:
m68k-amigaos-gcc -c -Os reactionlib.c
- Renamed the output reactionlib.o as libreaction.o (for naming consistency with other linkers present).
- Then I packed the object with ar:
Code:
m68k-amigaos-ar rs libreaction.a libreaction.o
- Copied the created libreaction.a file into the libnix/lib directory (where libamiga.a and libmui.a are).
- Compiled my HelloWorld code with -noixemul -lamiga -lreaction flags and found out the executable freezes at the first call to any reaction function (just as mritter0 mentioned).

But I recognized this kind of freeze from previous experience. Amiga freezes just like this when you mistakingly call a function from a library before opening it. Where do the reaction libraries get opened then? I suppose OS4 startup code does it automatically, but where do our OS3 code opens them? Nowhere!

Looking back at the reaction.lib code, I realized that Stephan Rupprecht supplied two functions which open and close reaction libraries:
INIT_3_ReActionLibs()
EXIT_3_ReActionLibs()

Since my code tries to be platform independent I've added them to my code as below:
at the top of my buildGUI() function:
Code:
#ifndef __amigaos4__
  INIT_3_ReActionLibs();
#endif
and Into my cleanUp() function:
Code:
#ifndef __amigaos4__
  EXIT_3_ReActionLibs();
#endif
...and voila! It works flawlessly now (both with gcc 2.95.3 and gcc 6).

NOTE: These calls would be nicer in a custom startup code but in my case it will complicate things much so I'll stick to linking with -lamiga.a.

NOTE2: I'm new in Amiga coding so any further advice on this is highly appreciated. Thanks for reading.

Last edited by alpyre; 10 February 2019 at 12:39.
alpyre is offline  
Old 27 October 2018, 02:13   #14
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,400
Cool, great work
NovaCoder is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
debugging session with exec lib pixel Coders. Asm / Hardware 4 20 May 2014 23:49
Help Creating a Graphics Lib View bodhi Coders. System 11 15 January 2014 20:49
060 processor lib's and OS 3.9 videofx support.Hardware 9 01 August 2013 09:29
Easynet and bsdsocket.lib Prob twizzle support.Apps 1 31 July 2009 05:43
Xadmaster lib registration Rod_cl support.Apps 4 24 August 2007 00:34

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:14.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14461 seconds with 13 queries