static function in dll

M

Markus Demetz

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
 
J

Jack Klein

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top