473,408 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 help 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.

Oct 15 '07 #1
3 2203
On 2007-10-15 22:06, dj*****@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 help 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
Oct 15 '07 #2
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= <Er***********@telia.comwrote in
news:im*****************@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?
Oct 15 '07 #3
On 2007-10-15 23:59, Kenneth Porter wrote:
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= <Er***********@telia.comwrote in
news:im*****************@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
Oct 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rinku24 | last post by:
We have two C++ libraries (Unix Shared objects) with the same class name and no namespace. Is there any way to load both the libraries and selectivly create the instance of the class from...
15
by: bugzilla | last post by:
hi,all, I have a C++ program need to convert to c language to be used in a emabedded system. the problem is that the original code was writtern in C++ language with Parent class and some child...
22
by: Sensei | last post by:
Hi! I'm looking for useful libraries that are strictly ISO C. Any kind of library, from lists, stacks, to trees, searching tools, sorting tools... really *any* kind. Do you have any idea? :)...
6
by: Heloise | last post by:
Hi, ..NET version: Visual C++ 2005 Express Edition Beta OS: XP I have a set of dlls built with .NET 2003. They are unmanaged C++ and C code. I am writing a managed C++ dll layer...
1
by: Jim Heavey | last post by:
I have a web application which accesses Class Libraries in another project. Can I add an "App.config" file to my Class Libraries project and be able to use that configuration information from my...
34
by: Guch Wu | last post by:
Boost has many terrific libraries. But I want to know whether they are ready for using in real projects. Which of them are mature enough, or just only in progress?
3
by: pb | last post by:
Is it possible to create a class library in visual web developer 2005 express edition and complie into a dll? If so how?
3
by: Med | last post by:
Hi, I use Visual C# Express 2005 and Visual Web Developer Express 2005. In my Visual C# Express 2005 Solution, I have following two class library projects: _ DataAccess (Namespace name:...
2
by: Frank | last post by:
Hi, Originally I was planning to do some code reuse (yeah.. that exists..didn't want to believe it either) with some class library projects that I now want to use in a asp.net 2.0 web app in VS...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.