Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #97551 > unrolled thread

C newb - third party libs and using and testing suite

Started byS390 <s390@tampascanner.info>
First post2016-11-27 01:05 +0000
Last post2016-12-03 02:11 +0000
Articles 20 on this page of 32 — 8 participants

Back to article view | Back to comp.lang.c


Contents

  C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-11-27 01:05 +0000
    Re: C newb - third party libs and using and testing suite Richard Heathfield <rjh@cpax.org.uk> - 2016-11-27 01:41 +0000
      Re: C newb - third party libs and using and testing suite Richard Heathfield <rjh@cpax.org.uk> - 2016-11-27 13:21 +0000
        Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-11-28 03:35 +0000
          Re: C newb - third party libs and using and testing suite Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 10:19 +0000
            Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-02 19:25 +0000
              Re: C newb - third party libs and using and testing suite "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-02 14:44 -0500
              Re: C newb - third party libs and using and testing suite BartC <bc@freeuk.com> - 2016-12-02 19:49 +0000
                Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-04 13:27 +0000
            Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-02 20:35 +0000
          Re: C newb - third party libs and using and testing suite James Kuyper <jameskuyper@verizon.net> - 2016-11-28 09:27 -0500
            Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-02 20:43 +0000
              Re: C newb - third party libs and using and testing suite "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-02 16:35 -0500
                Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-05 14:50 +0000
                  Re: C newb - third party libs and using and testing suite James Kuyper <jameskuyper@verizon.net> - 2016-12-05 23:48 -0500
                    Re: C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-09 22:12 +0000
                      Re: C newb - third party libs and using and testing suite "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-09 18:38 -0500
                        Re: C newb - third party libs and using and testing suite Keith Thompson <kst-u@mib.org> - 2016-12-09 16:34 -0800
                      Re: C newb - third party libs and using and testing suite Keith Thompson <kst-u@mib.org> - 2016-12-09 15:54 -0800
                        Re: C newb - third party libs and using and testing suite BartC <bc@freeuk.com> - 2016-12-10 00:09 +0000
                          Re: C newb - third party libs and using and testing suite jameskuyper@verizon.net - 2016-12-09 16:37 -0800
                            Re: C newb - third party libs and using and testing suite BartC <bc@freeuk.com> - 2016-12-10 01:09 +0000
                              Re: C newb - third party libs and using and testing suite jameskuyper@verizon.net - 2016-12-09 17:32 -0800
                              Re: C newb - third party libs and using and testing suite Keith Thompson <kst-u@mib.org> - 2016-12-09 17:36 -0800
    Re: C newb - third party libs and using and testing suite "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-26 21:14 -0500
      Re: C newb - third party libs and using and testing suite Richard Heathfield <rjh@cpax.org.uk> - 2016-11-27 09:21 +0000
        Re: C newb - third party libs and using and testing suite "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-27 10:36 -0500
    Re: Part II - C newb - third party libs and using and testing suite S390 <s390@tampascanner.info> - 2016-12-02 21:20 +0000
      Re: Part II - C newb - third party libs and using and testing suite "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-02 16:55 -0500
        Re: Part II - C newb - third party libs and using and testing suite Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-02 17:14 -0800
          Re: Part II - C newb - third party libs and using and testing suite BartC <bc@freeuk.com> - 2016-12-03 13:39 +0000
        Re: Part II - C newb - third party libs and using and testing suite BartC <bc@freeuk.com> - 2016-12-03 02:11 +0000

Page 1 of 2  [1] 2  Next page →


#97551 — C newb - third party libs and using and testing suite

FromS390 <s390@tampascanner.info>
Date2016-11-27 01:05 +0000
SubjectC newb - third party libs and using and testing suite
Message-ID<ujq_z.26434$YA2.10127@fx16.iad>
I am not a C person for normal things... tweak and edit or fix a few 
things, etc. to C programs... but I've come up against a program which 
needs more than my normal tweaking...

For most of what I do I take little things and build them to little 
blocks and then combine all the blocks after having rigorously tested 
them outside of each other.

In this case that definitely is a plus since I didn't write the original 
program, and deciphering some of its workings is little difficult to 
follow at times.

What I am trying to do is use this library: JAMLib

https://sourceforge.net/projects/jamlib/

Trying to follow the doc in this and use the "examples" is not getting me 
any traction due to my C lack of knowledge...

Example:

#include <~/jamtest/jamlib/jam.h>
#include <~/jamtest/jamlib/structrw.h>

void main()
        {
          int Result_I;
	  struct Base_PS;

          Result_I = JAM_OpenMB( "TEST", &Base_PS );
          if ( Result_I )
            printf("JAM_OpenMB returned %d.\n", Result_I );
        }


leads to:

~/jamtest $ gcc jamtest.c -l~/jamtest/jamlib/jamlib.a
jamtest.c: In function ‘main’:
jamtest.c:9: error: ‘Base_PS’ undeclared (first use in this function)
jamtest.c:9: error: (Each undeclared identifier is reported only once
jamtest.c:9: error: for each function it appears in.)

This "Base_PS" needs to be some sort of "structure" which well, for me 
doesn't compute...

I am looking for some input on how to test with this library and come up 
with what I need.. I am just not following how to integrate this in..



Info on this function and the source of the test:
================================
JAM_OpenMB - Open a message base
================================

Syntax
        int JAM_OpenMB( uchar* Basename_PC, t_JamBase** NewBase_PPS );

Description
        Opens a message base. Only one message base can be open at a time.

Parameters
        Basename_PC     The path and base filename of the message base.
                        "Base filename" means the filename without the
                        JAM-specific extension.

        NewBase_PPS     A pointer to a message base handle where the new
                        message base handle will be written. On error you
                        must free() this memory if (*NewBase_PPS) not 
NULL.

Returns
        0               if successful
        JAM_IO_ERROR    if an I/O error occured. see JAM_Errno()
        JAM_BAD_PARAM   if NewBas_PPS is NULL

Example
        {
          int Result_I;

          Result_I = JAM_OpenMB( "c:\\jam\\mybase", &Base_PS );
          if ( Result_I )
            printf("JAM_OpenMB returned %d.\n", Result_I );
        }




-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [next] | [standalone]


#97552

FromRichard Heathfield <rjh@cpax.org.uk>
Date2016-11-27 01:41 +0000
Message-ID<o1ddh9$5ba$1@dont-email.me>
In reply to#97551
On 27/11/16 01:05, S390 wrote:
>
<snip>
> What I am trying to do is use this library: JAMLib
>
> https://sourceforge.net/projects/jamlib/
>
> Trying to follow the doc in this and use the "examples" is not getting me
> any traction due to my C lack of knowledge...
>
> Example:
>
> #include <~/jamtest/jamlib/jam.h>
> #include <~/jamtest/jamlib/structrw.h>

#include <stdlib.h> /* for free() */

>
> void main()

int main(void)

>         {
>           int Result_I;
> 	  struct Base_PS;

             struct t_JamBase *Base_PS = NULL;

>
>           Result_I = JAM_OpenMB( "TEST", &Base_PS );
>           if ( Result_I )
>             printf("JAM_OpenMB returned %d.\n", Result_I );


             free(Base_PS); /* when you've finished with it */

>         }
>


-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#97566

FromRichard Heathfield <rjh@cpax.org.uk>
Date2016-11-27 13:21 +0000
Message-ID<o1emir$i1m$1@dont-email.me>
In reply to#97552
On 27/11/16 01:41, Richard Heathfield wrote:
> On 27/11/16 01:05, S390 wrote:
>>
> <snip>
>> What I am trying to do is use this library: JAMLib
>>
>> https://sourceforge.net/projects/jamlib/
>>
>> Trying to follow the doc in this and use the "examples" is not getting me
>> any traction due to my C lack of knowledge...
>>
>> Example:
>>
>> #include <~/jamtest/jamlib/jam.h>
>> #include <~/jamtest/jamlib/structrw.h>
>
> #include <stdlib.h> /* for free() */
>
>>
>> void main()
>
> int main(void)
>
>>         {
>>           int Result_I;
>>       struct Base_PS;

I didn't make it clear that the following line (see correction below!) 
is a /replacement/ for the above line. Sorry.

>
>             struct t_JamBase *Base_PS = NULL;

I made a mistake here. t_JamBase has presumably already been typedef'd, 
so it should just be:

              t_JamBase *Base_PS = NULL;

>
>>
>>           Result_I = JAM_OpenMB( "TEST", &Base_PS );
>>           if ( Result_I )
>>             printf("JAM_OpenMB returned %d.\n", Result_I );

While I'm at it: before you use Base_PS, you should check that it is not 
NULL:

              if(Base_PS != NULL)
              {
                it's okay to carry on and use Base_PS
              }

>
>
>             free(Base_PS); /* when you've finished with it */
>
>>         }
>>
>
>


-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#97619

FromS390 <s390@tampascanner.info>
Date2016-11-28 03:35 +0000
Message-ID<IBN_z.58541$BE2.16599@fx22.iad>
In reply to#97566
On Sun, 27 Nov 2016 13:21:43 +0000, Richard Heathfield wrote:

> I didn't make it clear that the following line (see correction below!)
> is a /replacement/ for the above line. Sorry.
> 

From your post:

#include </home/me/jamtest/jamlib/jam.h>
#include </home/me/jamtest/jamlib/structrw.h>
#include <stdlib.h> 

int main(void)
        {
          int Result_I;
	  struct s_JamBase *Base_PS = NULL;

          Result_I = JAM_OpenMB( "TEST", &Base_PS );
          if ( Result_I )
            printf("JAM_OpenMB returned %d.\n", Result_I );
	  free(Base_PS); 
        }

Two issues:


 $ gcc jamtest.c -L/home/me/jamtest/jamlib/ -l/home/me/jamtest/jamlib/
jamlib.a
jamtest.c: In function ‘main’:
jamtest.c:10: warning: passing argument 2 of ‘JAM_OpenMB’ from 
incompatible pointer type
/home/me/jamtest/jamlib/jam.h:242: note: expected ‘struct s_JamBase **’ 
but argument is of type ‘struct s_JamBase **’
/usr/bin/ld: cannot find -l/home/me/jamtest/jamlib/jamlib.a
collect2: ld returned 1 exit status
me@cleo-me-desktop ~/jamtest $ 

Did this so ld can find things, but still whines:
~/jamtest $ export LD_LIBRARY_PATH=/home/rec9140/jamtest/jamlib:
$LD_LIBRARY_PATH



 ~/jamtest/jamlib $ ls -la
total 248
drwxr-xr-x 2 me me  4096 2016-11-26 12:26 .
drwxr-xr-x 3 me me  4096 2016-11-27 21:09 ..
-rw-r--r-- 1 me me  4508 2016-11-26 12:26 crc32.c
-rw-r--r-- 1 me me  2096 2016-11-26 12:26 crc32.o
-rw-r--r-- 1 me me 10972 2016-11-26 12:26 jam.h
-rw-r--r-- 1 me me 26804 2016-11-26 12:26 jamlib.a
-rw-r--r-- 1 me me 44583 2016-11-26 12:26 jamlib.doc
-rw-r--r-- 1 me me  4588 2016-11-26 12:26 lastread.c
-rw-r--r-- 1 me me  2204 2016-11-26 12:26 lastread.o
-rw-r--r-- 1 me me 26430 2016-11-26 12:26 LICENSE
-rw-r--r-- 1 me me   556 2016-11-26 12:26 Makefile.linux
-rw-r--r-- 1 me me   570 2016-11-26 12:26 Makefile.os2
-rw-r--r-- 1 me me   537 2016-11-26 12:26 Makefile.win32
-rw-r--r-- 1 me me 15208 2016-11-26 12:26 mbase.c
-rw-r--r-- 1 me me  6136 2016-11-26 12:26 mbase.o
-rw-r--r-- 1 me me 16465 2016-11-26 12:26 message.c
-rw-r--r-- 1 me me  6980 2016-11-26 12:26 message.o
-rw-r--r-- 1 me me   551 2016-11-26 12:26 origMakefile.linux
-rw-r--r-- 1 me me  8638 2016-11-26 12:26 structrw.c
-rw-r--r-- 1 me me  3011 2016-11-26 12:26 structrw.h
-rw-r--r-- 1 me me  5916 2016-11-26 12:26 structrw.o
-rw-r--r-- 1 me me  5679 2016-11-26 12:26 subpack.c
-rw-r--r-- 1 me me  2216 2016-11-26 12:26 subpack.o

jam.h
~/jamtest/jamlib $ cat jam.h
/*
    JAMLIB - A JAM subroutine library
    Copyright (C) 1999 Bjrn Stenberg

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA

    Changes made by Johan Billing 2000-04-16:

    - Added #defines for JAM_NO_MESSAGE and JAM_CORRUPT_MSG
    - Added #ifndef linux around typedefs for ushort and ulong
    - Added prototype for JAM_AddEmptyMessage()

    Backported changes from JAMLIB 1.4.7 made by Johan Billing 2003-10-26

    - Added prototype for JAM_DeleteMessage()
*/

/***********************************************************************
**
**  JAM Definitions
**
***********************************************************************/

#ifndef __JAM_H__
#define __JAM_H__

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

#ifndef linux
typedef unsigned short ushort;   /* must be 16 bits wide */
typedef unsigned long  ulong;    /* must be 32 bits wide */
#endif

typedef unsigned char  uchar;    /* must be  8 bits wide */

/*
**  Error codes
*/
#define JAM_BAD_PARAM   1  /* one or more parameters are wrong */
#define JAM_IO_ERROR            2  /* i/o error. check JAM_Errno() for 
details */
#define JAM_LOCK_FAILED 3  /* lock could not be set */
#define JAM_NOT_LOCKED  4  /* the message base was not locked before 
writing */
#define JAM_NO_MEMORY   5  /* out of memory! */
#define JAM_NO_USER     6       /* user not found */
#define JAM_NO_MESSAGE  7  /* message has been deleted */
#define JAM_CORRUPT_MSG 8  /* message header is corrupt */

/*
**  CRC definitions
*/

#define JAM_NO_CRC      0xffffffff

/*
**  File extensions
*/
#define EXT_HDRFILE     ".jhr"
#define EXT_TXTFILE     ".jdt"
#define EXT_IDXFILE     ".jdx"
#define EXT_LRDFILE     ".jlr"

/*
**  Revision level and header signature
*/
#define CURRENTREVLEV   1
#define HEADERSIGNATURE "JAM\0"

/*
**  Header file information block, stored first in all .JHR files
*/
typedef struct {
    uchar  Signature[4];      /* <J><A><M> followed by <NUL> */
    ulong  DateCreated;       /* Creation date */
    ulong  ModCounter;        /* Last processed counter */
    ulong  ActiveMsgs;        /* Number of active (not deleted) msgs */
    ulong  PasswordCRC;       /* CRC-32 of password to access */
    ulong  BaseMsgNum;        /* Lowest message number in index file */
    uchar  RSRVD[1000];       /* Reserved space */
} s_JamBaseHeader;

/*
**  Message status bits
*/
#define MSG_LOCAL       0x00000001L /* Msg created locally */
#define MSG_INTRANSIT   0x00000002L /* Msg is in-transit */
#define MSG_PRIVATE     0x00000004L /* Private */
#define MSG_READ        0x00000008L /* Read by addressee */
#define MSG_SENT        0x00000010L /* Sent to remote */
#define MSG_KILLSENT    0x00000020L /* Kill when sent */
#define MSG_ARCHIVESENT 0x00000040L /* Archive when sent */
#define MSG_HOLD        0x00000080L /* Hold for pick-up */
#define MSG_CRASH       0x00000100L /* Crash */
#define MSG_IMMEDIATE   0x00000200L /* Send Msg now, ignore restrictions 
*/
#define MSG_DIRECT      0x00000400L /* Send directly to destination */
#define MSG_GATE        0x00000800L /* Send via gateway */
#define MSG_FILEREQUEST 0x00001000L /* File request */
#define MSG_FILEATTACH  0x00002000L /* File(s) attached to Msg */
#define MSG_TRUNCFILE   0x00004000L /* Truncate file(s) when sent */
#define MSG_KILLFILE    0x00008000L /* Delete file(s) when sent */
#define MSG_RECEIPTREQ  0x00010000L /* Return receipt requested */
#define MSG_CONFIRMREQ  0x00020000L /* Confirmation receipt requested */
#define MSG_ORPHAN      0x00040000L /* Unknown destination */
#define MSG_ENCRYPT     0x00080000L /* Msg text is encrypted */
#define MSG_COMPRESS    0x00100000L /* Msg text is compressed */
#define MSG_ESCAPED     0x00200000L /* Msg text is seven bit ASCII */
#define MSG_FPU         0x00400000L /* Force pickup */
#define MSG_TYPELOCAL   0x00800000L /* Msg is for local use only (no 
export) */
#define MSG_TYPEECHO    0x01000000L /* Msg is for conference distribution 
*/
#define MSG_TYPENET     0x02000000L /* Msg is direct network mail */
#define MSG_NODISP      0x20000000L /* Msg may not be displayed to user */
#define MSG_LOCKED      0x40000000L /* Msg is locked, no editing possible 
*/
#define MSG_DELETED     0x80000000L /* Msg is deleted */

/*
**  Message header
*/
typedef struct {
    uchar  Signature[4];              /* <J><A><M> followed by <NUL> */
    ushort Revision;                  /* CURRENTREVLEV */
    ushort ReservedWord;              /* Reserved */
    ulong  SubfieldLen;               /* Length of Subfields */
    ulong  TimesRead;                 /* Number of times message read */
    ulong  MsgIdCRC;                  /* CRC-32 of MSGID line */
    ulong  ReplyCRC;                  /* CRC-32 of REPLY line */
    ulong  ReplyTo;                   /* This msg is a reply to.. */
    ulong  Reply1st;                  /* First reply to this msg */
    ulong  ReplyNext;                 /* Next msg in reply chain */
    ulong  DateWritten;               /* When msg was written */
    ulong  DateReceived;              /* When msg was received/read */
    ulong  DateProcessed;             /* When msg was processed by packer 
*/
    ulong  MsgNum;                    /* Message number (1-based) */
    ulong  Attribute;                 /* Msg attribute, see "Status bits" 
*/
    ulong  Attribute2;                /* Reserved for future use */
    ulong  TxtOffset;                 /* Offset of text in text file */
    ulong  TxtLen;                    /* Length of message text */
    ulong  PasswordCRC;               /* CRC-32 of password to access msg 
*/
    ulong  Cost;                      /* Cost of message */
} s_JamMsgHeader;

/*
**  Message header Subfield types
*/
#define JAMSFLD_OADDRESS    0
#define JAMSFLD_DADDRESS    1
#define JAMSFLD_SENDERNAME  2
#define JAMSFLD_RECVRNAME   3
#define JAMSFLD_MSGID       4
#define JAMSFLD_REPLYID     5
#define JAMSFLD_SUBJECT     6
#define JAMSFLD_PID         7
#define JAMSFLD_TRACE       8
#define JAMSFLD_ENCLFILE    9
#define JAMSFLD_ENCLFWALIAS 10
#define JAMSFLD_ENCLFREQ    11
#define JAMSFLD_ENCLFILEWC  12
#define JAMSFLD_ENCLINDFILE 13
#define JAMSFLD_EMBINDAT    1000
#define JAMSFLD_FTSKLUDGE   2000
#define JAMSFLD_SEENBY2D    2001
#define JAMSFLD_PATH2D      2002
#define JAMSFLD_FLAGS       2003
#define JAMSFLD_TZUTCINFO   2004
#define JAMSFLD_UNKNOWN     0xffff

/*
**  Message header Subfield
*/
typedef struct {
    ushort LoID;       /* Field ID, 0 - 0xffff */
    ushort HiID;       /* Reserved for future use */
    ulong  DatLen;     /* Length of buffer that follows */
    uchar* Buffer;     /* DatLen bytes of data */
} s_JamSubfield;

typedef struct {
    ushort LoID;       /* Field ID, 0 - 0xffff */
    ushort HiID;       /* Reserved for future use */
    ulong  DatLen;     /* Length of buffer that follows */
} s_JamSaveSubfield;

/*
**  Message index record
*/
typedef struct {
    ulong  UserCRC;    /* CRC-32 of destination username */
    ulong  HdrOffset;  /* Offset of header in .JHR file */
} s_JamIndex;

/*
**  Lastread structure, one per user
*/
typedef struct {
    ulong  UserCRC;     /* CRC-32 of user name (lowercase) */
    ulong  UserID;      /* Unique UserID */
    ulong  LastReadMsg; /* Last read message number */
    ulong  HighReadMsg; /* Highest read message number */
} s_JamLastRead;

/*
**  JAMLIB message base handle
*/
typedef struct {
    FILE* HdrFile_PS;      /* File handle for .JHR file */
    FILE* TxtFile_PS;      /* File handle for .JDT file */
    FILE* IdxFile_PS;      /* File handle for .JDX file */
    FILE* LrdFile_PS;      /* File handle for .JLR file */
    int   Errno_I;         /* last i/o error */
    int   Locked_I;        /* is area locked? */
    ulong LastUserPos_I;   /* last position of lastread record */
    ulong LastUserId_I;    /* userid for the last read lastread record */
} s_JamBase;

/*
**  JAMLIB subfield packet
*/
typedef struct {
    s_JamSubfield** Fields;
    ulong           NumFields;
    ulong           NumAlloc;
} s_JamSubPacket;


/*
**  JAMLIB function declarations
*/

/* mbase.c */
int JAM_OpenMB          ( uchar*                Basename_PC,
                          s_JamBase**           NewArea_PPS );
                                                  
int JAM_CloseMB         ( s_JamBase*            Area_PS );

int JAM_CreateMB        ( uchar*                Basename_PC,
                          ulong                 BaseMsg_I,
                          s_JamBase**           NewArea_PPS );

int JAM_RemoveMB        ( s_JamBase*            Area_PS,
                          uchar*                Basename_PC );

int JAM_LockMB          ( s_JamBase*            Area_PS,
                          int                   Timeout_I );

int JAM_UnlockMB        ( s_JamBase*            Area_PS );

int JAM_ReadMBHeader    ( s_JamBase*            Area_PS,
                          s_JamBaseHeader*      Header_PS );
                                                          
int JAM_WriteMBHeader   ( s_JamBase*            Area_PS,
                          s_JamBaseHeader*      Header_PS );
                                                                  
int JAM_FindUser        ( s_JamBase*            Area_PS,
                          ulong                 UserCrc_I,
                          ulong                 StartMsg_I,
                          ulong*                MsgNo_PI );

int JAM_GetMBSize       ( s_JamBase*            Area_PS,
                          ulong*                Messages_PI );

/* message.c */

int JAM_ReadMsgHeader   ( s_JamBase*            Area_PS, 
                          ulong                 MsgNo_I,
                          s_JamMsgHeader*       Header_PS, 
                          s_JamSubPacket**      SubfieldPack_PPS );
                          
int JAM_ReadMsgText     ( s_JamBase*            Area_PS, 
                          ulong                 Offset_I,
                          ulong                 Length_I,
                          uchar*                Buffer_PC );
                                                          
int JAM_AddMessage      ( s_JamBase*            Area_PS,
                          s_JamMsgHeader*       Header_PS, 
                          s_JamSubPacket*       SubPack_PS,
                          uchar*                Text_PC,
                          ulong                 TextLen_I );
                                                          
int JAM_AddEmptyMessage ( s_JamBase*            Area_PS );

int JAM_DeleteMessage   ( s_JamBase*            Base_PS,
                          ulong                 MsgNo_I );

int JAM_ChangeMsgHeader ( s_JamBase*            Area_PS,
                          ulong                 MsgNo_I,
                          s_JamMsgHeader*       Header_PS );

int JAM_ClearMsgHeader  ( s_JamMsgHeader*       Header_PS );

int JAM_Errno           ( s_JamBase*            Area_PS );

/* lastread.c */

int JAM_ReadLastRead    ( s_JamBase*            Area_PS,
                          ulong                 User_I,
                          s_JamLastRead*        Record_PS );

int JAM_WriteLastRead   ( s_JamBase*            Area_PS,
                          ulong                 User_I,
                          s_JamLastRead*        Record_PS );

/* subpacket.c */

s_JamSubPacket* JAM_NewSubPacket        ( void );

int             JAM_DelSubPacket        ( s_JamSubPacket* SubPack_PS );

s_JamSubfield*  JAM_GetSubfield         ( s_JamSubPacket* SubPack_PS );

s_JamSubfield*  JAM_GetSubfield_R       ( s_JamSubPacket* SubPack_PS , 
                                          ulong* Count_PI);

int             JAM_PutSubfield         ( s_JamSubPacket* SubPack_PS,
                                          s_JamSubfield*  Field_PS );

/* crc32.c */

ulong JAM_Crc32         ( uchar* Buffer_PC, ulong Length_I );

#endif



-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#97623

FromRichard Heathfield <rjh@cpax.org.uk>
Date2016-11-28 10:19 +0000
Message-ID<o1h08c$5kl$1@dont-email.me>
In reply to#97619
On 28/11/16 03:35, S390 wrote:
> On Sun, 27 Nov 2016 13:21:43 +0000, Richard Heathfield wrote:
>
>> I didn't make it clear that the following line (see correction below!)
>> is a /replacement/ for the above line. Sorry.

That's from my second article, which I presume you have therefore read.

>>
>
> From your post:
>
> #include </home/me/jamtest/jamlib/jam.h>
> #include </home/me/jamtest/jamlib/structrw.h>
> #include <stdlib.h>
>
> int main(void)
>         {
>           int Result_I;
> 	  struct s_JamBase *Base_PS = NULL;

That's from my first, which the second supersedes.

You should also read James Kuyper's article.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#97895

FromS390 <s390@tampascanner.info>
Date2016-12-02 19:25 +0000
Message-ID<bVj0A.41446$%J2.315@fx20.iad>
In reply to#97623
On Mon, 28 Nov 2016 10:19:04 +0000, Richard Heathfield wrote:

> That's from my first, which the second supersedes.
> 
> You should also read James Kuyper's article.

Read both...

#include </home/me/jamtest/jamlib/jam.h>
#include </home/me/jamtest/jamlib/structrw.h>
#include <stdlib.h> 

int main(void)
        {
          int Result_I;
	  t_JamBase *Base_PS = NULL;

          Result_I = JAM_OpenMB( "TESTJAMNNTPD", &Base_PS );
          if ( Result_I )
            printf("JAM_OpenMB returned %d.\n", Result_I );
	  free(Base_PS); 
        }


~/jamtest $ gcc jamtest.c -L/home/rec9140/jamtest/jamlib/ -l/home/rec9140/
jamtest/jamlib/jamlib.a
jamtest.c: In function ‘main’:
jamtest.c:8: error: ‘t_JamBase’ undeclared (first use in this function)
jamtest.c:8: error: (Each undeclared identifier is reported only once
jamtest.c:8: error: for each function it appears in.)
jamtest.c:8: error: ‘Base_PS’ undeclared (first use in this function)



-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#97898

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-12-02 14:44 -0500
Message-ID<cc76e096-b3c3-0a39-b134-b640badb7d78@verizon.net>
In reply to#97895
On 12/02/2016 02:25 PM, S390 wrote:
> On Mon, 28 Nov 2016 10:19:04 +0000, Richard Heathfield wrote:
>
>> That's from my first, which the second supersedes.
>>
>> You should also read James Kuyper's article.
>
> Read both...
...
> 	  t_JamBase *Base_PS = NULL;

If you actually read and understood my article, why did you still 
declare this as t_JamBase rather than s_JamBase? If you didn't 
understand my article, feel free to ask me questions about it.

[toc] | [prev] | [next] | [standalone]


#97900

FromBartC <bc@freeuk.com>
Date2016-12-02 19:49 +0000
Message-ID<o1sj52$9nk$1@dont-email.me>
In reply to#97895
On 02/12/2016 19:25, S390 wrote:
> On Mon, 28 Nov 2016 10:19:04 +0000, Richard Heathfield wrote:
>
>> That's from my first, which the second supersedes.
>>
>> You should also read James Kuyper's article.
>
> Read both...
>
> #include </home/me/jamtest/jamlib/jam.h>
> #include </home/me/jamtest/jamlib/structrw.h>
> #include <stdlib.h>
>
> int main(void)
>         {
>           int Result_I;
> 	  t_JamBase *Base_PS = NULL;
>
>           Result_I = JAM_OpenMB( "TESTJAMNNTPD", &Base_PS );
>           if ( Result_I )
>             printf("JAM_OpenMB returned %d.\n", Result_I );
> 	  free(Base_PS);
>         }
>
>
> ~/jamtest $ gcc jamtest.c -L/home/rec9140/jamtest/jamlib/ -l/home/rec9140/
> jamtest/jamlib/jamlib.a
> jamtest.c: In function ‘main’:
> jamtest.c:8: error: ‘t_JamBase’ undeclared (first use in this function)
> jamtest.c:8: error: (Each undeclared identifier is reported only once
> jamtest.c:8: error: for each function it appears in.)
> jamtest.c:8: error: ‘Base_PS’ undeclared (first use in this function)


I managed to compile your code, but modified a little (see below; I 
copied the include files locally, and changed t_JamBase).

However it then fails to link as it needs a function 'JAM_OpenMB'. That 
appears in reside in 'base.c', so presumably those .c files need to be 
compiled and linked in too. But this appears to be one of those Unix 
projects relying on some massively complicated configure files, so all 
you have to do is type 'make'! (In theory of course...)

#include "jam.h"
#include "structrw.h"
#include <stdlib.h>

int main(void)
         {
           int Result_I;
	  struct s_JamBase *Base_PS = NULL;

           Result_I = JAM_OpenMB( "TESTJAMNNTPD", &Base_PS );
           if ( Result_I )
             printf("JAM_OpenMB returned %d.\n", Result_I );
	  free(Base_PS);
         }


-- 
Bartc






[toc] | [prev] | [next] | [standalone]


#97976

FromS390 <s390@tampascanner.info>
Date2016-12-04 13:27 +0000
Message-ID<kRU0A.187165$vF2.165104@fx43.iad>
In reply to#97900
On Fri, 02 Dec 2016 19:49:01 +0000, BartC wrote:

> I managed to compile your code, but modified a little (see below; I
> copied the include files locally, and changed t_JamBase).
> 
> However it then fails to link as it needs a function 'JAM_OpenMB'. That
> appears in reside in 'base.c', so presumably those .c files need to be
> compiled and linked in too. But this appears to be one of those Unix
> projects relying on some massively complicated configure files, so all
> you have to do is type 'make'! (In theory of course...)

See Part II for the follow up...

The underlying JAMlib used by something else, does have a make file to 
compile it... I've done that.. this should then let this lib be used in 
other programs... which it will, IF you remember that this thing was 
written with only 32b systems in mind...it has not bearing or 
understanding that in 2016, 64b systems exists....this begs another 
question for something else, but not relevant at this point for this 
discussion...that fubar was me! My setup for this to compile it was 
fubar'd by my stupid click... the editor will compile it with the options 
I pass it, but if you give it the wrong stuff.. boom.

I test in blocks... and build up those blocks to what I want... thus my 
desire to get this lib to work outside this other program...see Part II, 
as that is done... the underlying lib works....

The bigger issue is C is not my thing, never was, never will be... quick 
hacks, tweaks, fixes, fine... we've went beyond that for this... 

I am not opposed to learning about this, but unfortunately like many 
things the documentation for this reads like wahahwahhaha, because my 
brain no work that way...its not just C, alot of documentation doesn't 
work for me.. as it just jumps off the deep end of stuff.

IE: Tell me pass variable x,y,z to the function like

 SomeSuperFunction(x,y,z)

Where x = 1, y=2, z=3, 

The function will return :

"It worked!"

"YOU FAILED DUFUS!"

"6"

etc...




-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#97904

FromS390 <s390@tampascanner.info>
Date2016-12-02 20:35 +0000
Message-ID<UVk0A.41447$%J2.20289@fx20.iad>
In reply to#97623
On Mon, 28 Nov 2016 10:19:04 +0000, Richard Heathfield wrote:

> 
> That's from my first, which the second supersedes.
> 
> You should also read James Kuyper's article.

Never mind... I've found the issue(s)... see follow up

Thanks for the guidance... see follow up for further Q's......

-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#97637

FromJames Kuyper <jameskuyper@verizon.net>
Date2016-11-28 09:27 -0500
Message-ID<o1hepq$npk$1@dont-email.me>
In reply to#97619
On 11/27/2016 10:35 PM, S390 wrote:
> On Sun, 27 Nov 2016 13:21:43 +0000, Richard Heathfield wrote:
> 
>> I didn't make it clear that the following line (see correction below!)
>> is a /replacement/ for the above line. Sorry.
>>
> 
> From your post:
> 
> #include </home/me/jamtest/jamlib/jam.h>
> #include </home/me/jamtest/jamlib/structrw.h>
> #include <stdlib.h> 
> 
> int main(void)
>         {
>           int Result_I;
> 	  struct s_JamBase *Base_PS = NULL;
> 
>           Result_I = JAM_OpenMB( "TEST", &Base_PS );
>           if ( Result_I )
>             printf("JAM_OpenMB returned %d.\n", Result_I );
> 	  free(Base_PS); 
>         }
> 
> Two issues:
> 
> 
>  $ gcc jamtest.c -L/home/me/jamtest/jamlib/ -l/home/me/jamtest/jamlib/
> jamlib.a

The -l option expects to be followed by a library name. For instance
-lz, where z is the name of the library. It looks for a corresponding
archive file named libz.a in one of the current library search
directories. The sole purpose of the -l option is to add the "lib"
prefix and the ".a" suffix.

Since jamlib.a doesn't conform to the naming convention that -l was
designed to implement, you can't use -l to link to it. Since the -L
option is only meaningful in connection with the -l option, you don't
need the -L option, either. Instead, you should simply give the full
path name of the library file directly:

    gcc jamtext.c /home/me/jamtest/jamlib/jamlib.a


> jamtest.c: In function ‘main’:
> jamtest.c:10: warning: passing argument 2 of ‘JAM_OpenMB’ from 
> incompatible pointer type
> /home/me/jamtest/jamlib/jam.h:242: note: expected ‘struct s_JamBase **’ 
> but argument is of type ‘struct s_JamBase **’

That message confuses me. The expected and actual types appear to me to
be exactly identical. Am I missing something? If I had time, I'd build
jamlib and test this code myself - but I don't have time for that.

[toc] | [prev] | [next] | [standalone]


#97905

FromS390 <s390@tampascanner.info>
Date2016-12-02 20:43 +0000
Message-ID<J1l0A.41448$%J2.7846@fx20.iad>
In reply to#97637
On Mon, 28 Nov 2016 09:27:18 -0500, James Kuyper wrote:

> The -l option expects to be followed by a library name. For instance
> -lz, where z is the name of the library. It looks for a corresponding
> archive file named libz.a in one of the current library search
> directories. The sole purpose of the -l option is to add the "lib"
> prefix and the ".a" suffix.
> 
> Since jamlib.a doesn't conform to the naming convention that -l was
> designed to implement, you can't use -l to link to it. Since the -L
> option is only meaningful in connection with the -l option, you don't
> need the -L option, either. 

I am confused then, trying to following something else 

https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html

(3b) you could also build an ARCHIVE FILE (a statically linked library, 
libmylib.a) from one or more .o files. If you link with a static library, 
its code is copied into the a.out file at runtime.

See gcc documentation for more information on how to build .a and .so 
files.

(4) USE the library in other programs:

    step 1: Add an include line (#include "mylib.h") in all program 
source files that use library definitions (e.g., test.c).

    step 2: Link the program's .c file with the library object file 
            (i.e. specify the mylib.o file as a command line argument to 
gcc): 

             gcc  test.c mylib.o

        OR to link in libmylib.so (or libmylib.a):

             gcc  test.c -lmylib

        OR to link with a library not in the standard path:

             gcc  test.c -L/home/newhall/lib -lmylib


>Instead, you should simply give the full
> path name of the library file directly:
> 
>     gcc jamtext.c /home/me/jamtest/jamlib/jamlib.a
>

That resolves it...


> That message confuses me. The expected and actual types appear to me to
> be exactly identical. Am I missing something? If I had time, I'd build
> jamlib and test this code myself - but I don't have time for that.


I've found the issue(s)... see follow up

Thanks for the guidance... see follow up for further Q's......



-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!





-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#97909

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-12-02 16:35 -0500
Message-ID<1373812a-ef07-88fe-0ef1-84dff44fc96f@verizon.net>
In reply to#97905
On 12/02/2016 03:43 PM, S390 wrote:
> On Mon, 28 Nov 2016 09:27:18 -0500, James Kuyper wrote:
>
>> The -l option expects to be followed by a library name. For instance
>> -lz, where z is the name of the library. It looks for a corresponding
>> archive file named libz.a in one of the current library search
>> directories. The sole purpose of the -l option is to add the "lib"
>> prefix and the ".a" suffix.
>>
>> Since jamlib.a doesn't conform to the naming convention that -l was
>> designed to implement, you can't use -l to link to it. Since the -L
>> option is only meaningful in connection with the -l option, you don't
>> need the -L option, either.
>
> I am confused then, trying to following something else
>
> https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html

I'm rather surprised that they describe how to create and link in your 
own libraries, but fail to mention the file naming conventions that 
needs to be followed if you're going to use -l to find them.

> (3b) you could also build an ARCHIVE FILE (a statically linked library,
> libmylib.a) from one or more .o files. If you link with a static library,
> its code is copied into the a.out file at runtime.
>
> See gcc documentation for more information on how to build .a and .so
> files.
>
> (4) USE the library in other programs:
>
>     step 1: Add an include line (#include "mylib.h") in all program
> source files that use library definitions (e.g., test.c).
>
>     step 2: Link the program's .c file with the library object file
>             (i.e. specify the mylib.o file as a command line argument to
> gcc):
>
>              gcc  test.c mylib.o
>
>         OR to link in libmylib.so (or libmylib.a):

Note that libmylib.a matches the file naming convention described above. 
I didn't want to complicate the issue by mentioning shared-object (.so) 
files as well. gcc will look for both types of archives, and can be 
instructed to use only one or the other.

[toc] | [prev] | [next] | [standalone]


#98009

FromS390 <s390@tampascanner.info>
Date2016-12-05 14:50 +0000
Message-ID<F8f1A.282099$8F2.113429@fx42.iad>
In reply to#97909
On Fri, 02 Dec 2016 16:35:27 -0500, James R. Kuyper wrote:
> I'm rather surprised that they describe how to create and link in your
> own libraries, but fail to mention the file naming conventions that
> needs to be followed if you're going to use -l to find them.
> 

> Note that libmylib.a matches the file naming convention described above.
> I didn't want to complicate the issue by mentioning shared-object (.so)
> files as well. gcc will look for both types of archives, and can be
> instructed to use only one or the other.

Well, I guess for the forest for the trees I don't see the issue

jamlib.a is there  ie: jamtest/jamlib/jamlib.a

include <jamlib.h> ie: <include /home/me/jamtest/jamlib/jamlib.h>

so umm.. .I don't see why -ljamlib
or
-l/home/me/jamtest/jamlib/jamlib

Doesn't work???? that would be this "archive" file....

Its supposed to find -l <file.a> with the -l adding in the .a???

Unless it doesn't like paths.. but that seems rather against this whole 
process..

so -L should be the path to *.a and thus....

-ljamlib -L/home/me/jamtest/jamlib



-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#98123

FromJames Kuyper <jameskuyper@verizon.net>
Date2016-12-05 23:48 -0500
Message-ID<o25frm$9re$1@dont-email.me>
In reply to#98009
On 12/05/2016 09:50 AM, S390 wrote:
> On Fri, 02 Dec 2016 16:35:27 -0500, James R. Kuyper wrote:
>> I'm rather surprised that they describe how to create and link in your
>> own libraries, but fail to mention the file naming conventions that
>> needs to be followed if you're going to use -l to find them.
>>
> 
>> Note that libmylib.a matches the file naming convention described above.
>> I didn't want to complicate the issue by mentioning shared-object (.so)
>> files as well. gcc will look for both types of archives, and can be
>> instructed to use only one or the other.
> 
> Well, I guess for the forest for the trees I don't see the issue
> 
> jamlib.a is there  ie: jamtest/jamlib/jamlib.a
> 
> include <jamlib.h> ie: <include /home/me/jamtest/jamlib/jamlib.h>
> 
> so umm.. .I don't see why -ljamlib

Because -ljamlib takes "jamlib", and prefixes it with "lib", and then
adds a ".a" suffix. Net result: it's looking for a file named
libjamlib.a. Which is fine, if that's the name of the file you want to
link to. Since the file you actually want to link to is jamlib.a, that's
a bit of a problem.

> or
> -l/home/me/jamtest/jamlib/jamlib

I believe that would cause it to look for a file with the path name
lib/home/me/jamtest/jamlib/jamlib.a. Again, that's not a problem if
there's a file of that name in that location. Is there?

> Doesn't work???? that would be this "archive" file....
> 
> Its supposed to find -l <file.a> with the -l adding in the .a???

-lfile causes it to look for libfile.a.

> Unless it doesn't like paths.. but that seems rather against this whole 
> process..

-L is supposed to add a directory to the list of directories to be
searched. -l is supposed to tell it the core portion of the name of the
file it should look for in those directories.

Keep in mind that you can always link to a library file with an
arbitrary name, simply by providing the full pathname of the file on the
command line.

> so -L should be the path to *.a and thus....
> 
> -ljamlib -L/home/me/jamtest/jamlib

I believe that -L commands only affect things that appear after then on
the command line, so that should be

    -L/home/me/jamtest/jamlib -ljamlib

assuming, of course, that the full pathname of the library file that
you're trying to link to is

    /home/me/jamtest/jamlib/libjamlib.a

Is that in fact the right name?

[toc] | [prev] | [next] | [standalone]


#98619

FromS390 <s390@tampascanner.info>
Date2016-12-09 22:12 +0000
Message-ID<m%F2A.45496$Cx7.18500@fx11.iad>
In reply to#98123
On Mon, 05 Dec 2016 23:48:05 -0500, James Kuyper wrote:

>> Well, I guess for the forest for the trees I don't see the issue

> Because -ljamlib takes "jamlib", and prefixes it with "lib", and then
> adds a ".a" suffix. Net result: it's looking for a file named
> libjamlib.a. Which is fine, if that's the name of the file you want to
> link to. Since the file you actually want to link to is jamlib.a, that's
> a bit of a problem.

Like my quoted line above...I hate to belabor this point.. but this like 
some other things in this is really starting to just frost my cake! ;) :) 

I am using this as an education to understand this... although its really 
just starting to annoy me and reinforce why I remember why I never liked 
C to start, and trust me I've got axes to grind on things like Python 
with its idiotic spacing rules! 

UMMM... where did anything state that -l 

looks for /lib/<string>.a I get from that thing I was reading it needs 
appends .a, but where is this prepending of "lib" coming from????

That swarthmore or some snooty place link never mentioned this....

Seems to me that

-l<string>

then <string> = {string.a | string.so} and LD_LIB or what ever it was for 
that var points to someplace to default look to, or add additional path, 
to search, to find {string.a | string.so}

IF -L is present ie: -L/this/the/way/home 

then look in /this/the/way/home for {string.a | string.so}

Seems like some one is forcing some sort of naming convention that need 
not be to me.

>/home/me/jamtest/jamlib/libjamlib.a

>Is that in fact the right name?

No its just jamlib.a, which is why I am asking this... to me this seems 
like, above, a forced naming convention that serves no purpose.

-l<string> then LOOK FOR <string>! don't just start deciding to look for 
LIB<string>.a by prepending and appending crap!

-l should literally be what I am telling it to look for! URRRGHH!!

I certainly don't remember this crap from TurboPascal. I had some super 
fav lib I liked to use in my TP stuff at the time, and I just dumped in 
some place and then had a line to tell TP where it was.. it looked for 
that.. it didn't decide, no, I am going to look for 
LIBsuperFav.SomeExtensionIadded

Thanks for the insight and info!



-- 
I MADE America Great Again! President Trump! I put a stake in that bitch 
for good!

[toc] | [prev] | [next] | [standalone]


#98621

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-12-09 18:38 -0500
Message-ID<3520e708-6b9e-4672-a5f6-248174d84ef1@verizon.net>
In reply to#98619
On 12/09/2016 05:12 PM, S390 wrote:
> On Mon, 05 Dec 2016 23:48:05 -0500, James Kuyper wrote:
...
>> Because -ljamlib takes "jamlib", and prefixes it with "lib", and then
>> adds a ".a" suffix. Net result: it's looking for a file named
>> libjamlib.a. Which is fine, if that's the name of the file you want to
>> link to. Since the file you actually want to link to is jamlib.a, that's
>> a bit of a problem.
>
> Like my quoted line above...I hate to belabor this point.. but this like
> some other things in this is really starting to just frost my cake! ;) :)
>
> I am using this as an education to understand this... although its really
> just starting to annoy me and reinforce why I remember why I never liked
> C to start, and trust me I've got axes to grind on things like Python
> with its idiotic spacing rules!
>
> UMMM... where did anything state that -l
>
> looks for /lib/<string>.a ...

Nowhere. It looks for lib<string>.a. As for where that's stated, type 
"man gcc" at the unix command line:

"-l library
...
       The linker searches a standard list of directories for the
       library, which is actually a file named liblibrary.a."

> ... I get from that thing I was reading it needs
> appends .a, but where is this prepending of "lib" coming from????

Because naming library files lib<name>.a is the convention generally 
followed in a wide variety of environments. I'm not willing to commit 
myself to the exact range of places where you can expect that convention 
to be followed; my personal experience isn't sufficient broad. However, 
it's pretty nearly universal on the unix-like systems I'm most familiar 
with.

...
> Seems like some one is forcing some sort of naming convention that need
> not be to me.

Every naming convention is something that "need not be". Naming 
conventions are always conveniences, they're never necessities. That's 
why they're called "conventions" rather than "rules".

You're not forced to follow this convention. This convention is enforced 
by the -l option, but you don't have to use -l; you could just use the 
library's full path name directly:

     gcc jamtest.c /home/me/jamtest/jamlib/jamlib.a

If you take that approach, you're free to name the library file anything 
you want (圖書館果醬.歸檔, for instance). This will cause problems with other 
tools that rely upon the file naming conventions, but most of the 
resulting difficulties can be worked around, if you're sufficiently 
motivated.

[toc] | [prev] | [next] | [standalone]


#98634

FromKeith Thompson <kst-u@mib.org>
Date2016-12-09 16:34 -0800
Message-ID<lnzik4wrio.fsf@kst-u.example.com>
In reply to#98621
"James R. Kuyper" <jameskuyper@verizon.net> writes:
> On 12/09/2016 05:12 PM, S390 wrote:
[...]
>> UMMM... where did anything state that -l
>>
>> looks for /lib/<string>.a ...
>
> Nowhere. It looks for lib<string>.a. As for where that's stated, type 
> "man gcc" at the unix command line:
[...]

I forgot to mention in my previous followup, I think S390 meant the "/"
characters to denote emphasis, not literal "/" directory delimiters.
I suggest avoiding that usage when, as here, it can cause confusion.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#98627

FromKeith Thompson <kst-u@mib.org>
Date2016-12-09 15:54 -0800
Message-ID<ln4m2cy7yc.fsf@kst-u.example.com>
In reply to#98619
S390 <s390@tampascanner.info> writes:
> On Mon, 05 Dec 2016 23:48:05 -0500, James Kuyper wrote:
>>> Well, I guess for the forest for the trees I don't see the issue
>
>> Because -ljamlib takes "jamlib", and prefixes it with "lib", and then
>> adds a ".a" suffix. Net result: it's looking for a file named
>> libjamlib.a. Which is fine, if that's the name of the file you want to
>> link to. Since the file you actually want to link to is jamlib.a, that's
>> a bit of a problem.
>
> Like my quoted line above...I hate to belabor this point.. but this like 
> some other things in this is really starting to just frost my cake! ;) :) 
>
> I am using this as an education to understand this... although its really 
> just starting to annoy me and reinforce why I remember why I never liked 
> C to start, and trust me I've got axes to grind on things like Python 
> with its idiotic spacing rules! 
>
> UMMM... where did anything state that -l 
>
> looks for /lib/<string>.a I get from that thing I was reading it needs 
> appends .a, but where is this prepending of "lib" coming from????

It's documented in the GNU ld manual, among other places (ld is part of
the "binutils" package).  If you're using a linker other than the GNU
binutils version, it should be documented in that linker's manual.

Quoting https://sourceware.org/binutils/docs-2.27/ld/Options.html :

    -l namespec
    --library=namespec

        Add the archive or object file specified by namespec to the 
        list of files to link. This option may be used any number of
        times. If namespec is of the form :filename, ld will search
        the library path for a file called filename, otherwise it
        will search the library path for a file called libnamespec.a.

        On systems which support shared libraries, ld may also 
        search for files other than libnamespec.a. Specifically, 
        on ELF and SunOS systems, ld will search a directory for a
        library called libnamespec.so before searching for one called 
        libnamespec.a. (By convention, a .so extension indicates a
        shared library.) Note that this behavior does not apply to
        :filename, which always specifies a file called filename.

Note that if you want to specify an exact file name, you can do so.

The libFOO.a naming convention is a bit odd.  No doubt there are
historical reason for it, but I don't recall exactly what they are.

[SNIP]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#98631

FromBartC <bc@freeuk.com>
Date2016-12-10 00:09 +0000
Message-ID<o2fh0t$gjp$1@dont-email.me>
In reply to#98627
On 09/12/2016 23:54, Keith Thompson wrote:
> S390 <s390@tampascanner.info> writes:

>> looks for /lib/<string>.a I get from that thing I was reading it needs
>> appends .a, but where is this prepending of "lib" coming from????
>
> It's documented in the GNU ld manual, among other places (ld is part of
> the "binutils" package).  If you're using a linker other than the GNU
> binutils version, it should be documented in that linker's manual.
>
> Quoting https://sourceware.org/binutils/docs-2.27/ld/Options.html :
>
>     -l namespec
>     --library=namespec
>
>         Add the archive or object file specified by namespec to the
>         list of files to link. This option may be used any number of
>         times. If namespec is of the form :filename, ld will search
>         the library path for a file called filename, otherwise it
>         will search the library path for a file called libnamespec.a.
>
>         On systems which support shared libraries, ld may also
>         search for files other than libnamespec.a. Specifically,
>         on ELF and SunOS systems, ld will search a directory for a
>         library called libnamespec.so before searching for one called
>         libnamespec.a. (By convention, a .so extension indicates a
>         shared library.) Note that this behavior does not apply to
>         :filename, which always specifies a file called filename.
>
> Note that if you want to specify an exact file name, you can do so.

With -L, I've never managed to make it work when there's a problem 
finding object files. I've just tested it, put one of two .obj files I 
need in library C:\X, specified both .obj files with no path but 
followed or preceded by -LC:\X\ (-LC:/X/ or -LC:/x etc), and it can't 
find the file that is in X.

So I always specify a full path on each file to avoid problems.

(I've no idea how -l workd except that on Linux I sometimes have to use 
-lm and -ldl to link my programs.)

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.c


csiph-web