473,624 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2216
On 2007-10-15 22:06, dj*****@gmail.c om 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?RXJpayBXaWt zdHLDtm0=?= <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?RXJpayBXaWt zdHLDtm0=?= <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
2783
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 different library? e.g. We have class Process in libABC.so and libXYZ.so. Can I instantiate object of class Process from libABC.so or libXYZ.so by specifying symbol name or some other way?? I know can do that for global function using dlsym...
15
3776
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 class. How can I invert these C++ code into pure c code by using struct in C language? Can somebody give me any ideas? thanks. For example, how to conver the following code into pure c code?
22
1917
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? :) -- Sensei <senseiwa@mac.com>
6
1683
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 to call my unmanaged libraries using IJW.
1
258
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 web application which has a reference to the Class Libraries project? My issue is the connection string to my database. I have been placing it into the web config file and having my web application read it an pass it to the class out of the...
34
3152
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
1878
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
1672
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: DataAccess) _ SystemLibrary (Namespace name: SystemLibrary) which they both build in their own "bin\Release\" folders.
2
2498
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 2005. The solution contains both the web app and the class libraries. Inside the class libraries there are some xml files marked as content files and configured to be copied to the output directory on build. This worked perfectly fine for a...
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.