PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Class libraries w/VS 2005
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Class libraries w/VS 2005

Réponse
 
LinkBack Outils de la discussion
Vieux 15/10/2007, 21h06   #1
djbaker@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Class libraries w/VS 2005

Greetings,
I am trying to create a class library/dll with C++ and I am running
into a lot of trouble. I know that this is a C++ forum and not one
specific to windows or VS 2005 but I'm hoping someone call me.

I would like to create a class library so that I can put classes that
I reuse a lot into their own modules. I played around with it for
awhile and had no luck. It was really easy to do in C# but C++ does
not seem to be so easy.

I saw a lot of websites referencing exporting and importing symbols
but they all seem to relate to functions. How do you decorate the
class so that you can export the whole class and create an instance of
it in the calling program.

Thanks.

  Réponse avec citation
Vieux 15/10/2007, 21h48   #2
Erik Wikström
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Class libraries w/VS 2005

On 2007-10-15 22:06, djbaker@gmail.com wrote:
> Greetings,
> I am trying to create a class library/dll with C++ and I am running
> into a lot of trouble. I know that this is a C++ forum and not one
> specific to windows or VS 2005 but I'm hoping someone call me.
>
> I would like to create a class library so that I can put classes that
> I reuse a lot into their own modules. I played around with it for
> awhile and had no luck. It was really easy to do in C# but C++ does
> not seem to be so easy.
>
> I saw a lot of websites referencing exporting and importing symbols
> but they all seem to relate to functions. How do you decorate the
> class so that you can export the whole class and create an instance of
> it in the calling program.


You are right about this not being a C++ question, so for future
questions regarding DLLs please use a more appropriate group (I think a
win32 programming group would be the right choice). Here is a tutorial
to get you started: http://www.codeproject.com/dll/RegDLL.asp

--
Erik Wikström
  Réponse avec citation
Vieux 15/10/2007, 22h59   #3
Kenneth Porter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Portable shared library design (was: Class libraries w/VS 2005)

=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= <Erik-wikstrom@telia.com> wrote in
news:imQQi.11431$ZA.7495@newsb.telia.net:

> You are right about this not being a C++ question, so for future
> questions regarding DLLs please use a more appropriate group (I think a
> win32 programming group would be the right choice). Here is a tutorial
> to get you started: http://www.codeproject.com/dll/RegDLL.asp


I think ghetto-izing shared library implementation should be discouraged.
Instead, consider ways to design sharable libraries that can be used on
many platforms (not just Win32). For example, is there any standardization
effort in creating syntactic linkage hints such as this kind of
import/export decorator?

For example, right now I'm working on a proprietary closed-source library
that's initially implemented as a Win32 DLL but I'd like to design it so
that it can be easily rebuilt on Linux, Solaris, Mac, etc. What's the best
way to structure one's code to accomplish that?

My approach has been to create an auxiliary header (<MyLibrary/_internal.h>
) that gets included in each public header and defines linkage macros that
get used for each class and function that needs this.

I put my headers in project/include/MyLibrary, and library clients add
project/include to their -I option. This allows me to use simple names for
headers and keeps them in a separate #include namespace. (Perhaps
project/include/Vendor/Library) would be preferable, if a vendor produces
several libraries.)

My biggest hassle so far in portable shared libraries is the use of STL
objects (particularly containers) in public classes. The MS compiler will
whine that those classes need DLL linkage. Is gcc under Linux subject to
the same problem? How can I design the classes so that I don't face this?
  Réponse avec citation
Vieux 15/10/2007, 23h53   #4
Erik Wikström
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Portable shared library design

On 2007-10-15 23:59, Kenneth Porter wrote:
> =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= <Erik-wikstrom@telia.com> wrote in
> news:imQQi.11431$ZA.7495@newsb.telia.net:
>
>> You are right about this not being a C++ question, so for future
>> questions regarding DLLs please use a more appropriate group (I think a
>> win32 programming group would be the right choice). Here is a tutorial
>> to get you started: http://www.codeproject.com/dll/RegDLL.asp

>
> I think ghetto-izing shared library implementation should be discouraged.
> Instead, consider ways to design sharable libraries that can be used on
> many platforms (not just Win32). For example, is there any standardization
> effort in creating syntactic linkage hints such as this kind of
> import/export decorator?


There is very little in the way of standardising shared libraries. The
latest effort I can find on standard committee's site (N2407) is little
more than a description of the problem, an investigation of how it is
done on Windows and Linux and a suggestion of how to specify what should
be exported or not. This late in the process I would not expect it to be
included in the next version of the standard.

> My biggest hassle so far in portable shared libraries is the use of STL
> objects (particularly containers) in public classes. The MS compiler will
> whine that those classes need DLL linkage. Is gcc under Linux subject to
> the same problem? How can I design the classes so that I don't face this?


I *think* that by default everything is exported on Linux, while you
have to explicitly export it on Windows.

--
Erik Wikström
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h51.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10450 seconds with 12 queries