开发者

Compile dynamicaly linkable libraries

I'm currently trying to compile dynamicaly linkable libraries, which would link during run-time with 开发者_如何学Can application I'm writing. I'm not sure how these libraries are called, so just to be sure : they're those libraries you load not during compilation, but during runtime using :

- dlopen / dlsync using libdl

- LoadLibrary / (another one with a complicated name) using Windows.

The thing is I can't find a CMake-way to compile those librairies under Windows : using Linux, this works perfectly :

set(libName  myLib)
set(srcFiles myLib.cpp)

add_library(${libName} MODULE ${srcFiles})

Still, running Windows, it doesn't work at all : the Makefile is trying to link some pieces of code the myLib.cpp is referencing to (but it shouldn't... those symbols should be resolved at runtime).

I'm using the CodeBlocks MinGW generator if it may helps.


I think this would help:

add_library(${libname} SHARED ${srcfiles})

As CMake documentation says, MODULE should be used for building libraries that should be dynamically loaded using dlopen-like functionality. On Windows use SHARED instead of MODULE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜