English Amiga Board


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

 
 
Thread Tools
Old 18 July 2017, 18:43   #1
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
[SOLVED] Vbcc on Win: Flag <-o> needs string

I'm getting this error when compiling a testing exe in c. Here's what it says:
Code:
 
vbcc -I "E:\\Amiga\\Dev\\NDK_3.9\\Include\\include_h" basicWin.c -o basicWin.exe
error 3: Flag <-o> needs string
aborting...
What am I doing wrong? TIA!

Last edited by guy lateur; 19 July 2017 at 17:56. Reason: Mark as solved and off topic
guy lateur is offline  
Old 18 July 2017, 18:55   #2
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Also, if I add -v to turn on verbose mode, it says 'Unknown Flag <-v>'.
guy lateur is offline  
Old 19 July 2017, 07:25   #3
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Use the front-end (vc) instead of calling the compiler directly, and don't put spaces between -I and its argument. Also, if you're still using the VBCC Windows installer then NDK 3.9 is already installed and configured, there's no need to manually point to it.
Leffmann is offline  
Old 19 July 2017, 12:32   #4
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by Leffmann View Post
Use the front-end (vc) instead of calling the compiler directly, and don't put spaces between -I and its argument. Also, if you're still using the VBCC Windows installer then NDK 3.9 is already installed and configured, there's no need to manually point to it.
Yep, that's way better, thanks!
I'm only getting 'Reference to undefined symbol' errors now..

I thought vbcc had an 'automatic opening of libraries used' option, but I can't seem to find it. Or do I have to open and close the libs myself? Below is an example (slightly modified) I got from here: http://www.pjhutchison.org/tutorial/windows.html So how do I compile/link this?

Code:
#include <proto/intuition.h>
#include <proto/gadtools.h>  /* Gadtools is needed for GetIMsg and ReplyIMsg */ 
#include <proto/exec.h>   /* Exec is needed for Wait function */
#include <exec/exec.h>   /* Exec is needed for Wait function */
#include <proto/dos.h>
#include <intuition/intuition.h>
 struct DosLibrary *DOSBase;
struct ExecLibrary *ExecBase;
// struct IntuitionLibrary *IntuitionBase;
 int main() 
{
    struct Window *myWindow;
    int closewin = FALSE;       /* Flag used to end program */
    struct IntuiMessage *msg;   /* Structure to store Intuition message data */
    ULONG msgClass;             /* Class value */
    
    myWindow = OpenWindowTags(NULL,
                              WA_Left, 20, WA_Top, 20,
                              WA_Width, 200, WA_Height, 150,
                              WA_IDCMP, IDCMP_CLOSEWINDOW,
                              WA_Flags, WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET    | WFLG_ACTIVATE,
                              WA_Title, "My Window",
                              WA_PubScreenName, "Workbench",
                              TAG_DONE);
         
    while (closewin == FALSE)  /* Run program until window is closed */
 {                       
        Wait(1L << myWindow->UserPort->mp_SigBit);      /* Wait for an event! */
        msg = GT_GetIMsg(myWindow->UserPort);           /* Get message data    */ 
        msgClass = msg->Class;                          /* What has been clicked? */
        GT_ReplyIMsg(msg);          /* Close message */
     
        if (msgClass == IDCMP_CLOSEWINDOW)     /* Check here if Close    Window selected */
  {           
            CloseWindow(myWindow);                      /* Close window    */ 
            closewin = TRUE;
        }
    }
    return(0);
}
guy lateur is offline  
Old 19 July 2017, 13:22   #5
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
If I comment out the declaration of the library-bases it compiles cleanly with
vc +aos68k -o foo foo.c -lamiga -lauto
alkis is offline  
Old 19 July 2017, 13:51   #6
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by alkis View Post
If I comment out the declaration of the library-bases it compiles cleanly with
vc +aos68k -o foo foo.c -lamiga -lauto
It does indeed, thanks for the tip! It doesn't even seem to require linking to amiga.lib, nor the specification of the aos68k config file -- although I may to keep the latter in, just for good measure.

So I suppose the linking with auto.lib is what makes it open the necessary libraries for us. Hmm, I wonder how that works..
guy lateur is offline  
Old 19 July 2017, 14:14   #7
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
something like that, more or less..

http://cahirwpz.users.sourceforge.ne...ning-interface
alkis is offline  
Old 19 July 2017, 14:20   #8
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by alkis View Post
something like that, more or less..

http://cahirwpz.users.sourceforge.ne...ning-interface
Nice, thanks!
guy lateur is offline  
Old 19 July 2017, 14:56   #9
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Are all these libraries (even intuition and gadtools) located in ROM? Because I don't have any of them as a .library file in my LIBS: folder, and yet the example runs perfectly fine. I have 3.X ROMs.
guy lateur is offline  
Old 19 July 2017, 15:25   #10
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Well, they're documented in the libraries section of the ROM kernel reference manual, so I guess they're in ROM..

http://amigadev.elowar.com/read/ADCD.../node0002.html
guy lateur is offline  
Old 19 July 2017, 17:20   #11
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by guy lateur View Post
It doesn't even seem to require linking to amiga.lib, nor the specification of the aos68k config file
Vbcc's standard Amiga config files automatically link against vc.lib and amiga.lib.

Quote:
although I may to keep the latter in, just for good measure.
Yes. You never know the default config file in an installation.

Quote:
So I suppose the linking with auto.lib is what makes it open the necessary libraries for us. Hmm, I wonder how that works..
Through compiler/linker-specific constructors and destructors. With vbcc a function starting with _INIT... is automatically entered in the constructor list and with _EXIT... into the destructor list. The format is _INIT_<pri>_name, with <pri> defining the priority between 0 and 9. The linker (vlink) builds the lists of constructors and destructors automatically and assigns the symbols __CTOR_LIST__[] and __DTOR_LIST__[], which are used by the vclib startup code to run them before main() / after exit().

Quote:
Originally Posted by alkis View Post
something like that, more or less..

http://cahirwpz.users.sourceforge.ne...ning-interface
As mentioned above this is highly compiler / linker specific. Your example only works with gcc, ld and a.out format (SET). Mine only works with vlink.
phx is offline  
Old 19 July 2017, 17:51   #12
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by phx View Post
Through compiler/linker-specific constructors and destructors. With vbcc a function starting with _INIT... is automatically entered in the constructor list and with _EXIT... into the destructor list. The format is _INIT_<pri>_name, with <pri> defining the priority between 0 and 9. The linker (vlink) builds the lists of constructors and destructors automatically and assigns the symbols __CTOR_LIST__[] and __DTOR_LIST__[], which are used by the vclib startup code to run them before main() / after exit().
Alright, so vclib is where the magic is at. That would make sense, always being linked in anyway. So I guess this contains some code that is always run near the end of the linking stage, that adds in some extra initialisation and clenaup code to the executable? Because that sounds like a very exotic thing to program.. And autolib contains those special constructors/destructors for multiple libs, right?

Anyway, thanks for the info, phx! You know it almost feels like cheating, having you around here..
guy lateur is offline  
Old 19 July 2017, 19:30   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by guy lateur View Post
So I guess this contains some code that is always run near the end of the linking stage, that adds in some extra initialisation and clenaup code to the executable?
No, it just runs the function pointers from the constructor and destructor list. Here is vclib's portable _main.c. __main() is called by the lowlevel m68k-amigaos startup-code.
Code:
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>

struct __exitfuncs *__firstexit;

extern int main(int, char **);
extern void __exit();  /* from startup-code */

/* from linker */
extern void (*__CTOR_LIST__[])(void),(*__DTOR_LIST__[])(void);


/* Specified in c99. */
void _Exit(int returncode)
{
  void (**dtors)(void);
  int i;

  if (dtors = __DTOR_LIST__) {
    for (i=1; *dtors[i]; i++);
    while (--i) (*dtors[i])();  /* call destructors */
  }

  __exit(returncode);
}


void exit(int returncode)
{
  static int in_exit = 0;

  if (!in_exit) {
    struct __exitfuncs *p=__firstexit;

    /* run atexit-functions */
    in_exit = 1;
    while(p) {
      p->func();
      p=p->next;
    }
    _Exit(returncode);
  }
}


/*
  This function has to be called by the startup-code.

  The startup-code typically has to:
  - setup hardware, stack etc. (if needed)
  - initialize variables (if needed)
  - parse command line (if needed)
  - call __main
*/

void __main(int argc,char **argv)
{
  void (**ctors)(void) = __CTOR_LIST__;

  if (ctors++) {
    while (*ctors)
      (*ctors++)();  /* call constructors */
  }

  exit(main(argc,argv));
}
Quote:
And autolib contains those special constructors/destructors for multiple libs, right?
Yes. Example for asl.library:
Code:
#include <exec/libraries.h>
#include <proto/exec.h>
#include <stdlib.h>

struct Library *AslBase = NULL;
extern unsigned long _AslBaseVer;

void _INIT_5_AslBase()
{
  if (!(AslBase = OpenLibrary("asl.library",_AslBaseVer)))
    exit(20);
}

void _EXIT_5_AslBase()
{
  if (AslBase)
    CloseLibrary(AslBase);
}
As soon as AslBase is referenced, the linker pulls this module in and adds its constructor and destructor to the list.
_AslBaseVer is in an extra object, so you have the possibility to overwrite the default version.
phx is offline  
Old 19 July 2017, 20:04   #14
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by phx View Post
No, it just runs the function pointers from the constructor and destructor list. Here is vclib's portable _main.c. __main() is called by the lowlevel m68k-amigaos startup-code.
Code:
<snip>
Ok, I see, I think. Although I don't fully understand the _main/__main/exit/_exit thing (please allow me to let this sink in), that does seem to make a lot more sense than whatever it was I was thinking of..

Quote:
Originally Posted by phx View Post
Yes. Example for asl.library:
Code:
#include <exec/libraries.h>
#include <proto/exec.h>
#include <stdlib.h>

struct Library *AslBase = NULL;
extern unsigned long _AslBaseVer;

void _INIT_5_AslBase()
{
  if (!(AslBase = OpenLibrary("asl.library",_AslBaseVer)))
    exit(20);
}

void _EXIT_5_AslBase()
{
  if (AslBase)
    CloseLibrary(AslBase);
}
As soon as AslBase is referenced, the linker pulls this module in and adds its constructor and destructor to the list.
_AslBaseVer is in an extra object, so you have the possibility to overwrite the default version.
Am I right in assuming that, given that I'd wanted to build a custom .library myself (just assuming I could actually do that, for now), I'd only have to link to a file that contains definitions similar to those above to have the auto con/destruction kick in? Because that would be really sweet..
guy lateur is offline  
Old 19 July 2017, 20:26   #15
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by guy lateur View Post
Am I right in assuming that, given that I'd wanted to build a custom .library myself (just assuming I could actually do that, for now), I'd only have to link to a file that contains definitions similar to those above to have the auto con/destruction kick in?
Yes.

For a single library you can easily modify this file. I am auto-generating all those sources for auto.lib from the FD-files (looking for ##base), of course.
phx is offline  
Old 19 July 2017, 20:31   #16
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by phx View Post
Yes. For a single library you can easily modify this file.
Fantastically sweet with sugar on top!
guy lateur 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
Plotter / Dot Flag pmc Coders. Tutorials 45 19 January 2011 19:02
Flag by Gremlin BippyM project.aGTW 43 22 December 2010 22:24
Floppy verify flag of AmigaOS Leandro Jardim support.Apps 0 15 May 2010 19:40
Bitmap Flag = 0x00000001? andreas support.Other 2 14 October 2009 22:29
save flag Marcuz HOL suggestions and feedback 1 08 September 2006 01:18

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 02:39.

Top

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