2

My users complain that they have to install the linux thread building blocks on machines they do not own, and many hosts don't want intel thread building blocks to be installed of my end users, so I want to create a static version of my dynamic library / plugin / module / extension (whatever the corrct term is for a plugable C++ program / dll / so).

I found out that for Windows I have to use the /MT (multi threaded) instead of the default /MD switch (Multi Threaded DLL) so my program will have no dependencies (but, windows has a concurrent container library so I don't need to use TBB there).

I just cannot figure out what the equivalent for linux is?

Or is there maybe a .sln to makefile converter which can figure out all the options?

I'm developing on Windows, but most of my end users use linux so I would like to make sure they don't have any burden on them and I want them to be very comfortable using my open source releases.

Gizmo
  • 1,990
  • 1
  • 24
  • 50
  • /MTd instructs the linker to use the **Multi-threaded debug** run-time library ([see MSDN](http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=vs.71).aspx)). – Casey Jul 17 '13 at 22:59
  • @Casey sorry fixed, /MD :S – Gizmo Jul 18 '13 at 00:30
  • so does anyone know the switches to link library dependencies into the executable? – Gizmo Jul 27 '13 at 23:13
  • Intel intentionally does not support this scenario. Nor should you, this will turn out *very* poorly when the final program uses *two* copies of TBB. Each of them thinking that they can control the threads in the program. – Hans Passant Jul 28 '13 at 15:11
  • TBB was just an example ;o and probably a bad one. :$ And didn't know that, thanks for the info, will link complaining users here. – Gizmo Jul 28 '13 at 19:28

2 Answers2

1

The /MT flag in the Microsoft C++ compiler causes the linker to link against the static versions of the C and C++ run-time libraries. Microsoft ships static and dynamic versions of the run-time libraries, so this option effectively selects which set of libs to link against. This flag does not affect linking against third party libraries.

On the Linux side you have the -static option to tell the linker to use static libraries. this option is not library specific like on Windows, it affects all libraries. But if you use this option you have to provide static versions of all the libraries that you need, the linker will not convert dynamic libraries automatically. This includes system and run-time libraries, which are not always available as static libs. It also includes the Intel TBB, which you will probably need to compile yourself as a static lib if Intel doesn't provide it in that form.

Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152
0

I'm guessing that you mean that your users have to install Intel Threading Building Blocks (TBB) on their Linux machines. If you're using the Intel TBB functionality and your clients have to compile your source code then they need to have Intel TBB installed. An alternative approach would be to compile the source code for your clients and only supply them with your solution binaries and not the source code - then they would not have to install TBB.

  • My binary somehow requires the TBB libraries to be present on the system, that is what I want to avoid – Gizmo Jul 18 '13 at 00:29
  • `Intel grants to you a non-exclusive, non-assignable copyright license to distribute (except under an Evaluation License as specified below) the Redistributables, or any portions thereof, as part of the product or application you developed.` - [Link to Intel redistribute tbb libs and dlls](http://software.intel.com/en-us/tags/21728) . From this it seems to me that you can redistribute the TBB libraries for the Linux platform with your solution. –  Jul 18 '13 at 02:17
  • I'm sorry, but there are no Intel TBB libraries that you can link statically, and it would be impossible to compile and statically link _any_ C/C++ library on Windows and make it work on Linux - so what you want to do can not be done. What you need to do is dynamically link Intel TBB libraries and let the Linux users download the Intel TBB redistributables so that they don't have to buy any of the Intel products that include Intel TBB. –  Jul 18 '13 at 02:47
  • @IngeHenriksen I suppose you haven't heard about the recent invention of [cross compilers](http://en.wikipedia.org/wiki/Cross_compiler) that make it possible to compile software on one platform that runs on a different platform, but I don't think it's really important since Gizmo never said he wanted to compile and link Linux releases on Windows. You also seem unaware that TBB is [dual licensed under both GPLv2 and a commercial license](http://threadingbuildingblocks.org/Licensing). – Casey Jul 18 '13 at 03:45
  • @Casey That might work as long as the cross-compiler is ISO compliant, but I'm not experienced with cross-compilers. –  Jul 18 '13 at 03:54