Author Topic: Static Linking  (Read 21915 times)

pbergqvist

  • Guest
Static Linking
« on: January 13, 2014, 03:10:17 PM »
I am currently evaluating this library in my application. According to the release notes, I believe the currently released version should support static linking.

Quote
What's new in 6.10.1.0:

* WCL C++ Edition now ca be used as a static linked library;

First of all, the wclAPI header is not really suitable for static linking since it always performs either dllexport or dllimport. I solved this by adding an additional definition check (see below) in the wclAPI header. I can then simply define WCL_STATIC in my application.

Code: [Select]
#ifdef WCL_STATIC
    #define WCL_API
#else
    #ifdef WCL_API_EXPORT
        #define WCL_API __declspec(dllexport)
    #else
        #define WCL_API __declspec(dllimport)
        ...
    #endif
#endif

I created a simple test application. I added the WCL source directory as an Additional Include Directory. I added the correct WCL build directory as an Additional Library Directory. I also added wcl.lib to my linker input list. My test application just attempts to load the API:

Code: [Select]
int _tmain(int argc, _TCHAR* argv[])
{
wcl::CwclAPI api;
api.Load();
api.Unload();
return 0;
}

Compiling and linking works fine, however once my application starts I get the following error:

Quote
The program can't start because wcl.dll is missing from your computer.
Try reinstalling the program to fix this problem.

If I place wcl.dll in the same directory as my executable my application works fine. So, there still seems to be some dll importing going on.

What am I doing wrong, or is this a bug in WCL?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Static Linking
« Reply #1 on: January 13, 2014, 04:46:17 PM »
WCL without source code can not be staticaly linked. It can be used as DLL only. If you purchase WCL with source code then you can link the WCL code together with your application.

 

Sitemap 1 2 3 4 5 6 7