Author Topic: Cross platform "DLL" ?  (Read 7523 times)

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Cross platform "DLL" ?
« on: June 22, 2007, 06:27:45 pm »
Hi,

I have been using MS VisualStudio for many years, and I have been used to making MFC programs using many DLLs (sometimes DLLs without any GUI). Now I have moved to Code::Blocks and wxWidgets. This is great as my programs are targeting Windows and Linux. Code::Blocks and wxWidgets solves the problem of writing portable executable applications.

But I was wondering if there is anything in Code::Blocks that would help me write portable libraries that become DLLs on windows and .so (shared objects) on Linux? Which project wizard options would help me do that? I might also need info on how to export C++ classes from such projects, to make them usable from outside. I use VS2005 Express on Windows XP and GCC on Linux Kubuntu. I know the details of exporting C++ classes from Windows DLLs, but how to do the same for Linux shared objects is more unclear to me.

Will I have to use some feature of wxWidgets to achieve this?

Any info or pointers most welcome.

cacb

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Cross platform "DLL" ?
« Reply #1 on: June 22, 2007, 07:08:34 pm »
You can create Dynamic libs for Windows and Linux with Code::Blocks. You can just choose the DLL wizard I think. (I am not sure, never done that)
You can take a look to the source code of the Code::Blocks SDK. it is also a cross platform Dynamic Link Library.
You don't need wxWidgets, but you should use OS specific functionality with care.
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Cross platform "DLL" ?
« Reply #2 on: June 22, 2007, 07:57:19 pm »
Thanks for the reply. I just tried the DLL wizard, but it doesn't seem to be the way to go. It just creates a skeleton Windows DLL with entries such as "BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)" etc., I.e. definitely Windows specific and not portable. That DLL wizard does also not exist under my Kubuntu C::B installation.

Where do i find the Code::Blocks SDK example ?

On windows I have used mostly static linking to DLLs, i.e. application linking against the DLL import library. Not sure if the same feature exist for a shared object on Linux....? I want to export C++ class instances as one can do on Windows, not just call exported C-style functions. Another thing is using different compilers on the two platforms (VC2005 on windows and GCC on linux). This means 4 build targets are needed (i.e. separate Debug/Release for win and linux).

I believe these things should be possible... after all wxWidgets is linked as several .so files for example.

cacb

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Cross platform "DLL" ?
« Reply #3 on: June 22, 2007, 08:02:58 pm »
Code::Blocks itself currently uses an entirely separate project file for Unix systems. You should take a look at that. I'm not sure if it's currently possible to have Unix .so and Windows .dll targets in the same project file.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Cross platform "DLL" ?
« Reply #4 on: June 22, 2007, 08:35:29 pm »
Ok... my application project has currently different build targets, although manually set up. Maybe the same could be done for a shared library project, I was hoping there was a C::B wizard for it.

But to do it manually I need to know how .so files are made and how to export symbols from it under Linux. A combined C++ and project setup issue. Hmm.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Cross platform "DLL" ?
« Reply #5 on: June 22, 2007, 08:41:37 pm »
Read the following article more details on *.so creation.
Quote
http://www-128.ibm.com/developerworks/library/l-shobj/
Be a part of the solution, not a part of the problem.

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Cross platform "DLL" ?
« Reply #6 on: June 22, 2007, 09:13:59 pm »
Quote
Read the following article more details on *.so creation.
Quote
http://www-128.ibm.com/developerworks/library/l-shobj/

Excellent article... many thanks! That really says a lot about the things I was asking about. With this info it is maybe possible to make a single shared library project with both .dll and .so targets. Assuming that works maybe it could be basis for a C::B project wizard at some stage.

cacb