using C to create a Static lib

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ralph

    #1

    using C to create a Static lib



    Hi all,
    Recently I have tried to create a static lib using MS VC++.

    The following are some of the excerpt of my codes:


    ********* MyFirstStaticLi b.c *************** ****

    #include <stdlib.h>
    #include <string.h>

    int getA(int a, int b){
    ....

    }

    int getB(int a, int b){
    ....

    }

    *************** *************** **********

    Both function 'getA' and 'getB' will be used in my other program.

    I compiling my other program... I alway got "__cdecl int getA()" errors
    same fot 'getB' function.

    Anyone know the cause?

    Thanks.
  • Richard Bos

    #2
    Re: using C to create a Static lib

    Ralph <RALPH@cwazy.RE MOVETHIS.co.uk> wrote:
    [color=blue]
    > Recently I have tried to create a static lib using MS VC++.[/color]

    Note that creating libraries is system-specific, and therefore
    off-topic. However...
    [color=blue]
    > Both function 'getA' and 'getB' will be used in my other program.
    >
    > I compiling my other program... I alway got "__cdecl int getA()" errors
    > same fot 'getB' function.
    >
    > Anyone know the cause?[/color]

    ....you might check that you are compiling (both the library and the
    program which uses it) in C mode, not as C++. Ditto for linking and/or
    library-collecting.

    Richard

    Comment

    • kal

      #3
      Re: using C to create a Static lib

      rlb@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<40b35dfe. 536899026@news. individual.net> ...

      <OT>
      [color=blue]
      > Ralph <RALPH@cwazy.RE MOVETHIS.co.uk> wrote:
      >[color=green]
      > > Recently I have tried to create a static lib using MS VC++.[/color]
      >
      > Note that creating libraries is system-specific, and therefore
      > off-topic. However...
      >[color=green]
      > > Both function 'getA' and 'getB' will be used in my other program.
      > >
      > > I compiling my other program... I alway got "__cdecl int getA()" errors
      > > same fot 'getB' function.
      > >
      > > Anyone know the cause?[/color]
      >
      > ...you might check that you are compiling (both the library and the
      > program which uses it) in C mode, not as C++. Ditto for linking and/or
      > library-collecting.
      >
      > Richard[/color]

      1. You need to do more reading about creating libraries.

      2. Do not use functions names like "getA". The "A" won't make
      your function name unique. Most of the MS library functions
      are implemented in two versions, one appended with A (for Ascii)
      and the other appended with W (for Wide char/Unicode).

      3. When you implement a library, always specify the calling
      convention. MS VC has __cdecl, __stdcall and __fastcall.
      Generallly you should use __stdcall but the default is __cdecl.
      There are compiler options (/Gz, /Gd) to specify which
      convention to use as the default.

      4. Distribute your library with a headerfile.

      5. Post brief but complete information on here. It does not seem
      that "__cdecl int getA()" is the complete error message.

      </OT>

      Comment

      • Dan Pop

        #4
        Re: using C to create a Static lib

        In <a5da4cc1.04052 51718.3ef903d2@ posting.google. com> k_amir7@yahoo.c om (kal) writes:
        [color=blue]
        ><OT>[/color]
        <snip>[color=blue]
        ></OT>[/color]

        When your post is off topic from one end to the other, you prepend the
        [OT] tag to the subject line.

        Dan
        --
        Dan Pop
        DESY Zeuthen, RZ group
        Email: Dan.Pop@ifh.de

        Comment

        • Richard Bos

          #5
          Re: using C to create a Static lib

          k_amir7@yahoo.c om (kal) wrote:
          [color=blue]
          > rlb@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<40b35dfe. 536899026@news. individual.net> ...
          >[color=green]
          > > Ralph <RALPH@cwazy.RE MOVETHIS.co.uk> wrote:
          > >[color=darkred]
          > > > Recently I have tried to create a static lib using MS VC++.[/color]
          > >
          > > Note that creating libraries is system-specific, and therefore
          > > off-topic. However...
          > >[color=darkred]
          > > > Both function 'getA' and 'getB' will be used in my other program.
          > > >
          > > > I compiling my other program... I alway got "__cdecl int getA()" errors
          > > > same fot 'getB' function.
          > > >
          > > > Anyone know the cause?[/color]
          > >
          > > ...you might check that you are compiling (both the library and the
          > > program which uses it) in C mode, not as C++. Ditto for linking and/or
          > > library-collecting.[/color]
          >
          > 1. You need to do more reading about creating libraries.[/color]

          No, I don't. Be careful whom you address.
          [color=blue]
          > 2. Do not use functions names like "getA". The "A" won't make
          > your function name unique. Most of the MS library functions
          > are implemented in two versions, one appended with A (for Ascii)
          > and the other appended with W (for Wide char/Unicode).[/color]

          If M$ VC++ declares the function getA() when it is asked to compile an
          ISO C program, it is a vile, malodorous, miscreant abomination. That
          identifier is in the user's namespace, and it is the OP's full right to
          use it. It isn't even a very unlikely name to occur. Any implementation
          which prevents an ISO C program from defining a function called getA()
          is severely broken.
          [color=blue]
          > 3. When you implement a library, always specify the calling
          > convention. MS VC has __cdecl, __stdcall and __fastcall.[/color]

          This is massively off-topic.
          [color=blue]
          > 4. Distribute your library with a headerfile.[/color]

          Obviously, but how is that pertinent to the problem?
          [color=blue]
          > 5. Post brief but complete information on here.[/color]

          No, don't. Post it somewhere where making libraries with M$ VC++ is
          on-topic.

          Richard

          Comment

          • Joona I Palaste

            #6
            Re: using C to create a Static lib

            Richard Bos <rlb@hoekstra-uitgeverij.nl> scribbled the following:[color=blue]
            > k_amir7@yahoo.c om (kal) wrote:[color=green]
            >> 2. Do not use functions names like "getA". The "A" won't make
            >> your function name unique. Most of the MS library functions
            >> are implemented in two versions, one appended with A (for Ascii)
            >> and the other appended with W (for Wide char/Unicode).[/color][/color]
            [color=blue]
            > If M$ VC++ declares the function getA() when it is asked to compile an
            > ISO C program, it is a vile, malodorous, miscreant abomination.[/color]

            In other words, a rather usual M$ product. =)

            --
            /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
            \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
            "When a man talks dirty to a woman, that's sexual harassment. When a woman talks
            dirty to a man, that's 14.99 per minute + local telephone charges!"
            - Ruben Stiller

            Comment

            • kal

              #7
              Re: OT - using C to create a Static lib

              Dan.Pop@cern.ch (Dan Pop) wrote in message news:<c924qg$k0 3$6@sunnews.cer n.ch>...
              [color=blue]
              > When your post is off topic from one end to the other, you prepend the
              > [OT] tag to the subject line.[/color]

              Sorry about that. I really ought not to have posted that one. But the
              OP seemed to be adrift without a paddle and since I happened to know a
              little bit about that...

              P.S. I have often wondered, "why HELVETICA?"

              Comment

              • Joona I Palaste

                #8
                Re: OT - using C to create a Static lib

                kal <k_amir7@yahoo. com> scribbled the following:[color=blue]
                > Dan.Pop@cern.ch (Dan Pop) wrote in message news:<c924qg$k0 3$6@sunnews.cer n.ch>...[color=green]
                >> When your post is off topic from one end to the other, you prepend the
                >> [OT] tag to the subject line.[/color][/color]
                [color=blue]
                > Sorry about that. I really ought not to have posted that one. But the
                > OP seemed to be adrift without a paddle and since I happened to know a
                > little bit about that...[/color]
                [color=blue]
                > P.S. I have often wondered, "why HELVETICA?"[/color]

                What "why Helvetica"? What does Helvetica have to do with this?

                --
                /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
                \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
                "C++. C++ run. Run, ++, run."
                - JIPsoft

                Comment

                • Richard Bos

                  #9
                  Re: OT - using C to create a Static lib

                  Joona I Palaste <palaste@cc.hel sinki.fi> wrote:
                  [color=blue]
                  > kal <k_amir7@yahoo. com> scribbled the following:[color=green]
                  > > Dan.Pop@cern.ch (Dan Pop) wrote in message news:<c924qg$k0 3$6@sunnews.cer n.ch>...[color=darkred]
                  > >> When your post is off topic from one end to the other, you prepend the
                  > >> [OT] tag to the subject line.[/color][/color]
                  >[color=green]
                  > > Sorry about that. I really ought not to have posted that one. But the
                  > > OP seemed to be adrift without a paddle and since I happened to know a
                  > > little bit about that...[/color]
                  >[color=green]
                  > > P.S. I have often wondered, "why HELVETICA?"[/color]
                  >
                  > What "why Helvetica"? What does Helvetica have to do with this?[/color]

                  I presume he means "Why does Dan Pop have an address in Switzerland?"
                  And I presume the answer is because Dan Pop has a job in Switzerland...

                  Richard

                  Comment

                  • Dan Pop

                    #10
                    Re: OT - using C to create a Static lib

                    In <40b6dd6d.15797 8131@news.indiv idual.net> rlb@hoekstra-uitgeverij.nl (Richard Bos) writes:
                    [color=blue]
                    >Joona I Palaste <palaste@cc.hel sinki.fi> wrote:
                    >[color=green]
                    >> kal <k_amir7@yahoo. com> scribbled the following:[color=darkred]
                    >> > Dan.Pop@cern.ch (Dan Pop) wrote in message news:<c924qg$k0 3$6@sunnews.cer n.ch>...
                    >> >> When your post is off topic from one end to the other, you prepend the
                    >> >> [OT] tag to the subject line.[/color]
                    >>[color=darkred]
                    >> > Sorry about that. I really ought not to have posted that one. But the
                    >> > OP seemed to be adrift without a paddle and since I happened to know a
                    >> > little bit about that...[/color]
                    >>[color=darkred]
                    >> > P.S. I have often wondered, "why HELVETICA?"[/color]
                    >>
                    >> What "why Helvetica"? What does Helvetica have to do with this?[/color]
                    >
                    >I presume he means "Why does Dan Pop have an address in Switzerland?"
                    >And I presume the answer is because Dan Pop has a job in Switzerland...[/color]

                    A presumption flatly contradicted by Dan Pop's signature block...

                    Dan
                    --
                    Dan Pop
                    DESY Zeuthen, RZ group
                    Email: Dan.Pop@ifh.de

                    Comment

                    • Martin Dickopp

                      #11
                      Re: OT - using C to create a Static lib

                      rlb@hoekstra-uitgeverij.nl (Richard Bos) writes:
                      [color=blue]
                      > Joona I Palaste <palaste@cc.hel sinki.fi> wrote:
                      >[color=green]
                      >> kal <k_amir7@yahoo. com> scribbled the following:[color=darkred]
                      >> > Dan.Pop@cern.ch (Dan Pop) wrote in message news:<c924qg$k0 3$6@sunnews.cer n.ch>...
                      >> >> When your post is off topic from one end to the other, you prepend the
                      >> >> [OT] tag to the subject line.[/color]
                      >>[color=darkred]
                      >> > Sorry about that. I really ought not to have posted that one. But the
                      >> > OP seemed to be adrift without a paddle and since I happened to know a
                      >> > little bit about that...[/color]
                      >>[color=darkred]
                      >> > P.S. I have often wondered, "why HELVETICA?"[/color]
                      >>
                      >> What "why Helvetica"? What does Helvetica have to do with this?[/color]
                      >
                      > I presume he means "Why does Dan Pop have an address in Switzerland?"
                      > And I presume the answer is because Dan Pop has a job in Switzerland...[/color]

                      IIRC, CERN's main computing center is located France. At least a few
                      years ago, when the question of whether it is in Switzerland or France
                      was of utmost importance to me, I presumed it is in France...

                      Martin


                      --
                      ,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
                      / ,- ) http://www.zero-based.org/ ((_/)o o(\_))
                      \ `-' `-'(. .)`-'
                      `-. Debian, a variant of the GNU operating system. \_/

                      Comment

                      • CBFalconer

                        #12
                        Re: OT - using C to create a Static lib

                        Dan Pop wrote:[color=blue]
                        > (Richard Bos) writes:[color=green]
                        >> Joona I Palaste <palaste@cc.hel sinki.fi> wrote:[color=darkred]
                        >>> kal <k_amir7@yahoo. com> scribbled the following:
                        >>>[/color][/color][/color]
                        .... snip ...[color=blue][color=green][color=darkred]
                        >>>
                        >>>> P.S. I have often wondered, "why HELVETICA?"
                        >>>
                        >>> What "why Helvetica"? What does Helvetica have to do with this?[/color]
                        >>
                        >> I presume he means "Why does Dan Pop have an address in Switzerland?"
                        >> And I presume the answer is because Dan Pop has a job in Switzerland...[/color]
                        >
                        > A presumption flatly contradicted by Dan Pop's signature block...[/color]

                        But not by his 'From:' header.

                        --
                        fix (vb.): 1. to paper over, obscure, hide from public view; 2.
                        to work around, in a way that produces unintended consequences
                        that are worse than the original problem. Usage: "Windows ME
                        fixes many of the shortcomings of Windows 98 SE". - Hutchison


                        Comment

                        • Dik T. Winter

                          #13
                          Re: OT - using C to create a Static lib

                          In article <40B74E18.E7714 9B8@yahoo.com> cbfalconer@worl dnet.att.net writes:[color=blue]
                          > Dan Pop wrote:[color=green]
                          > > (Richard Bos) writes:[/color][/color]
                          ....[color=blue][color=green][color=darkred]
                          > >> I presume he means "Why does Dan Pop have an address in Switzerland?"
                          > >> And I presume the answer is because Dan Pop has a job in Switzerland...[/color]
                          > >
                          > > A presumption flatly contradicted by Dan Pop's signature block...[/color]
                          >
                          > But not by his 'From:' header.[/color]

                          But what has a From header to do with the place where someone works, or
                          lives, or whatever?
                          --
                          dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
                          home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

                          Comment

                          • CBFalconer

                            #14
                            Re: OT - using C to create a Static lib

                            "Dik T. Winter" wrote:[color=blue]
                            > cbfalconer@worl dnet.att.net writes:[color=green]
                            >> Dan Pop wrote:[color=darkred]
                            >>> (Richard Bos) writes:[/color][/color]
                            > ...[color=green][color=darkred]
                            >>>> I presume he means "Why does Dan Pop have an address in Switzerland?"
                            >>>> And I presume the answer is because Dan Pop has a job in Switzerland...
                            >>>
                            >>> A presumption flatly contradicted by Dan Pop's signature block...[/color]
                            >>
                            >> But not by his 'From:' header.[/color]
                            >
                            > But what has a From header to do with the place where someone works, or
                            > lives, or whatever?[/color]

                            It is the only connection his present day posts show with
                            Switzerland, or Helvitica. Which (for some unknown and possibly
                            benighted reason) became a matter of urgent curiosity to someone
                            here, since snipped.

                            --
                            fix (vb.): 1. to paper over, obscure, hide from public view; 2.
                            to work around, in a way that produces unintended consequences
                            that are worse than the original problem. Usage: "Windows ME
                            fixes many of the shortcomings of Windows 98 SE". - Hutchison


                            Comment

                            • Mark McIntyre

                              #15
                              Re: OT - using C to create a Static lib

                              On Sat, 29 May 2004 06:21:47 GMT, in comp.lang.c , CBFalconer
                              <cbfalconer@yah oo.com> wrote:
                              [color=blue]
                              >"Dik T. Winter" wrote:[color=green]
                              >> cbfalconer@worl dnet.att.net writes:[color=darkred]
                              >>> Dan Pop wrote:
                              >>>> (Richard Bos) writes:[/color]
                              >> ...[color=darkred]
                              >>>>> I presume he means "Why does Dan Pop have an address in Switzerland?"
                              >>>>> And I presume the answer is because Dan Pop has a job in Switzerland...
                              >>>>
                              >>>> A presumption flatly contradicted by Dan Pop's signature block...
                              >>>
                              >>> But not by his 'From:' header.[/color]
                              >>
                              >> But what has a From header to do with the place where someone works, or
                              >> lives, or whatever?[/color]
                              >
                              >It is the only connection his present day posts show with
                              >Switzerland, or Helvitica.[/color]

                              What do my From: headers show? Any obvious connection with where I live or
                              work?

                              --
                              Mark McIntyre
                              CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
                              CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>


                              ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
                              http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                              ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


                              ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
                              http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                              ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

                              Comment

                              Working...