delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/14/22:00:22

From: "Chia" <chia AT top DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Library Creation
Date: Sat, 14 Nov 1998 20:36:25 -0600
Organization: 404 Software
Lines: 50
Message-ID: <72leem$1vs@nnrp3.farm.idt.net>
NNTP-Posting-Host: flex-10.top.net
X-Newsreader: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've got a C++ GUI that I'm trying to turn into a library.  It uses allegro
for keyboard and graphics support.

Now, how I've set this up is that I've got two files for each class, a
header and an implementation.  Each file has

    #ifndef [this file]
    #define [this file]
        // stuff
    #endif

And they include the headers for the classes which they inherit from and
use.

In addition to this, I have about twenty helper functions.  They have
prototypes in "jgui.h" and bodies in "jgui.cpp."  These functions are
required by almost every class.

I have gotten every class to turn into object code through:
    gxx -c file.cpp

I have then run the following command to turn them into a library:
    ar rvs libjgui.a *.o

I then copied libjgui.a to my djgpp\lib directory and copied jgui.h to the
include directory.

I then made a simple test program:

    #include <jgui.h>
    int main(void) {
        jgui_init();  // one of the helper functions
    }

And tried to compile like this:

    gxx test.cpp -o test.exe -ljgui -lalleg

This produced a bunch of "first defined here / multiple definition" errors
for each of the functions and some of the globals.

Does anyone have an idea as to why this would happen?

Thanks!

// chia AT top DOT net -- http://www.top.net/chia/




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019