By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

static function in dll

P: n/a
Hi,

I'm quite new to C++.

I'm developing under Microsoft Visual Studio, andI've written some
classes and want them to be exported to a .dll. I use a macro DLL_EXPORT
and everything goes well.

But when I try to export a static function, the client, which imports
the function gives a linking error.

class Station {
...

/* database */
DLL_EXPORT void write2db(bool recursive);
DLL_EXPORT virtual void removeFromDb();
static DLL_EXPORT Station* loadFromDb(int id, bool recursive);

...

};

DLL_EXPORT is changed accordingly to __declspec(dllexport) and
__declspec(dllimport).

The clients main function:
int main() {
Station *st = Station::loadFromDb(1, true);
...
}
leads to a linker error.

Is it possible to export static functions and how?

Thank you for any help,
Markus
Jun 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 28 Jun 2006 17:31:26 +0200, Markus Demetz
<ma*******@webeffects.it> wrote in comp.lang.c++:
Hi,

I'm quite new to C++.

I'm developing under Microsoft Visual Studio, andI've written some
classes and want them to be exported to a .dll. I use a macro DLL_EXPORT
and everything goes well.

But when I try to export a static function, the client, which imports
the function gives a linking error.

class Station {
...

/* database */
DLL_EXPORT void write2db(bool recursive);
DLL_EXPORT virtual void removeFromDb();
static DLL_EXPORT Station* loadFromDb(int id, bool recursive);

...

};

DLL_EXPORT is changed accordingly to __declspec(dllexport) and
__declspec(dllimport).

The clients main function:
int main() {
Station *st = Station::loadFromDb(1, true);
...
}
leads to a linker error.

Is it possible to export static functions and how?


You need to ask in a Windows programming group like
news:comp.os.ms-windows.programmer.win32, or one of Microsoft support
groups on the server msnews.microsoft.com. DLLs are not defined by
the C++ language, they are a Windows operating system specific
extension.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jun 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.