Discussion:
how to detect extension of shared library in cpp file
(too old to reply)
Lukasz Michalski
2009-10-28 20:54:27 UTC
Permalink
Hi,

Bakefile creates .dll files on MSW, .so files on Unix and .bundle files
on Mac.



I use autoconf and have code like this:

void
DbPlugin::load(const char* pFilename) {
std::string name;
name.append(pFilename);
#ifdef _MSC_VER
name.append(".dll");
mLibHandle = ::LoadLibrary(TEXT(name));
#elif defined(HAVE_DLOPEN)
name.append(".so");
mLibHandle = dlopen(name.c_str(), RTLD_LAZY);
#endif
};

My problem is that both Mac and Linux uses dlopen but bakefile creates
files with different extensions. Does anyone know what is the best way
to detect in .cpp file what extension should be appended to filename?

Any hints greatly appreciated,

Regards,
--
Lukasz Michalski
pgp key: http://www.zork.pl/lm.asc
Scott Bailey
2009-10-28 21:30:48 UTC
Permalink
I search for shared libs using defines.

#if defined(NDEBUG)
# if defined(_WIN32)
const std::string PLUG_NAME("\\*plug.dll");
# elif defined(__APPLE__)
const std::string PLUG_NAME("/*plug.dylib");
# else
const std::string PLUG_NAME("/*plug.so");
# endif
#else

# if defined(_WIN32)
const std::string PLUG_NAME("\\*plugd.dll");
# elif defined(__APPLE__)
const std::string PLUG_NAME("/*plugd.dylib");
# else
const std::string PLUG_NAME("/*plugd.so");
# endif
#endif
Post by Lukasz Michalski
Hi,
Bakefile creates .dll files on MSW, .so files on Unix and .bundle files
on Mac.
void
DbPlugin::load(const char* pFilename) {
std::string name;
name.append(pFilename);
#ifdef _MSC_VER
name.append(".dll");
mLibHandle = ::LoadLibrary(TEXT(name));
#elif defined(HAVE_DLOPEN)
name.append(".so");
mLibHandle = dlopen(name.c_str(), RTLD_LAZY);
#endif
};
My problem is that both Mac and Linux uses dlopen but bakefile creates
files with different extensions. Does anyone know what is the best way
to detect in .cpp file what extension should be appended to filename?
Any hints greatly appreciated,
Regards,
--
Lukasz Michalski
pgp key: http://www.zork.pl/lm.asc
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Bakefile-devel mailing list
https://lists.sourceforge.net/lists/listinfo/bakefile-devel
--
Scott Bailey
Loading...