# Juce as DLL

**URL:** <https://forum.juce.com/t/juce-as-dll/861>\
**Category:** Windows\
**Created:** [May 30, 2006, 10:42am UTC](https://forum.juce.com/t/juce-as-dll/861 "2006-05-30T10:42:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [May 30, 2006, 10:42am UTC](https://forum.juce.com/t/juce-as-dll/861/1 "2006-05-30T10:42:53Z")

</div>

Hi all,  
I am having trouble building juce as a DLL on windows. I get LNK2019  
errors. I tried versions 1.33 and 1.29. Can any one tell me, how to build juce  
as a DLL?

Thanks,  
Yogesh Kini

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 30, 2006, 11:45am UTC](https://forum.juce.com/t/juce-as-dll/861/2 "2006-05-30T11:45:27Z")

</div>

I build it here as a dll in vcexpress and it works fine. What compiler are you using?

---

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [May 30, 2006, 11:49am UTC](https://forum.juce.com/t/juce-as-dll/861/3 "2006-05-30T11:49:46Z")

</div>

I am using VC++ 7.1 .net.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 30, 2006, 12:05pm UTC](https://forum.juce.com/t/juce-as-dll/861/4 "2006-05-30T12:05:43Z")

</div>

Ok - but what are the actual link errors? Did you define JUCE\_DLL before including juce.h?

---

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [May 30, 2006, 12:13pm UTC](https://forum.juce.com/t/juce-as-dll/861/5 "2006-05-30T12:13:04Z")

</div>

Hi,

I get the errors when I try to compile JUCE.  
I changed configuration type to dll in project settings and  
Rumtime Library to “MultiThreaded DLL” from “Multithreaded debug”

Should I declare JUCE\_DLL in juce.h or something?

I get the following errors:

error LNK2019: unresolved external symbol \_\_imp\_\_midiInGetDevCapsW@12 referenced in function “public: static class juce::StringArray const \_\_cdecl juce::MidiInput::getDevices(void)” (?getDevices@MidiInput@juce@@SA?BVStringArray@2@XZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInGetNumDevs@0 referenced in function “public: static class juce::StringArray const \_\_cdecl juce::MidiInput::getDevices(void)” (?getDevices@MidiInput@juce@@SA?BVStringArray@2@XZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInOpen@20 referenced in function “public: static class juce::MidiInput \* \_\_cdecl juce::MidiInput::openDevice(int,class juce::MidiInputCallback \*)” (?openDevice@MidiInput@juce@@SAPAV12@HPAVMidiInputCallback@2@@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInUnprepareHeader@12 referenced in function “public: virtual void \_\_thiscall juce::MidiInThread::run(void)” (?run@MidiInThread@juce@@UAEXXZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInAddBuffer@12 referenced in function “public: void \_\_thiscall juce::MidiInThread::writeBlock(int)” (?writeBlock@MidiInThread@juce@@QAEXH@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInPrepareHeader@12 referenced in function “public: void \_\_thiscall juce::MidiInThread::writeBlock(int)” (?writeBlock@MidiInThread@juce@@QAEXH@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInClose@4 referenced in function “public: virtual \_\_thiscall juce::MidiInThread::~MidiInThread(void)” (??1MidiInThread@juce@@UAE@XZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInStop@4 referenced in function “public: void \_\_thiscall juce::MidiInThread::stop(void)” (?stop@MidiInThread@juce@@QAEXXZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInReset@4 referenced in function “public: void \_\_thiscall juce::MidiInThread::stop(void)” (?stop@MidiInThread@juce@@QAEXXZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiInStart@4 referenced in function “public: void \_\_thiscall juce::MidiInThread::start(void)” (?start@MidiInThread@juce@@QAEXXZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutGetDevCapsW@12 referenced in function “public: static class juce::StringArray const \_\_cdecl juce::MidiOutput::getDevices(void)” (?getDevices@MidiOutput@juce@@SA?BVStringArray@2@XZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutGetNumDevs@0 referenced in function “public: static class juce::StringArray const \_\_cdecl juce::MidiOutput::getDevices(void)” (?getDevices@MidiOutput@juce@@SA?BVStringArray@2@XZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutOpen@20 referenced in function “public: static class juce::MidiOutput \* \_\_cdecl juce::MidiOutput::openDevice(int)” (?openDevice@MidiOutput@juce@@SAPAV12@H@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutClose@4 referenced in function “public: \_\_thiscall juce::MidiOutput::~MidiOutput(void)” (??1MidiOutput@juce@@QAE@XZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutReset@4 referenced in function “public: void \_\_thiscall juce::MidiOutput::reset(void)” (?reset@MidiOutput@juce@@QAEXXZ)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutGetVolume@8 referenced in function “public: bool \_\_thiscall juce::MidiOutput::getVolume(float &,float &)” (?getVolume@MidiOutput@juce@@QAE\_NAAM0@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutSetVolume@8 referenced in function “public: void \_\_thiscall juce::MidiOutput::setVolume(float,float)” (?setVolume@MidiOutput@juce@@QAEXMM@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutShortMsg@8 referenced in function “public: void \_\_thiscall juce::MidiOutput::sendMessageNow(class juce::MidiMessage const &)” (?sendMessageNow@MidiOutput@juce@@QAEXABVMidiMessage@2@@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutUnprepareHeader@12 referenced in function “public: void \_\_thiscall juce::MidiOutput::sendMessageNow(class juce::MidiMessage const &)” (?sendMessageNow@MidiOutput@juce@@QAEXABVMidiMessage@2@@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutLongMsg@12 referenced in function “public: void \_\_thiscall juce::MidiOutput::sendMessageNow(class juce::MidiMessage const &)” (?sendMessageNow@MidiOutput@juce@@QAEXABVMidiMessage@2@@Z)  
juce\_win32\_Midi.obj : error LNK2019: unresolved external symbol \_\_imp\_\_midiOutPrepareHeader@12 referenced in function “public: void \_\_thiscall juce::MidiOutput::sendMessageNow(class juce::MidiMessage const &)” (?sendMessageNow@MidiOutput@juce@@QAEXABVMidiMessage@2@@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetGetConnectedState@8 referenced in function “bool \_\_cdecl juce::juce\_isOnLine(void)” (?juce\_isOnLine@juce@@YA\_NXZ)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetCloseHandle@4 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_HttpSendRequestA@20 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_HttpOpenRequestA@32 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_FtpOpenFileA@20 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetConnectA@32 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetCrackUrlA@16 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetOpenA@20 referenced in function “void \* \_\_cdecl juce::juce\_openInternetFile(class juce::String const &,class juce::String const &,bool)” (?juce\_openInternetFile@juce@@YAPAXABVString@1@0\_N@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetReadFile@16 referenced in function “int \_\_cdecl juce::juce\_readFromInternetFile(void \*,void \*,int)” (?juce\_readFromInternetFile@juce@@YAHPAX0H@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol \_\_imp\_\_InternetSetFilePointer@20 referenced in function "int \__cdecl juce::juce\_seekInInternetFile(void \*,int)" (?juce\_seekInInternetFile@juce@@YAHPAXH@Z)  
juce\_win32\_Network.obj : error LNK2019: unresolved external symbol imp\_\_HttpQueryInfoA@20 referenced in function "int cdecl juce::juce\_getStatusCodeFor(void \*)" (?juce\_getStatusCodeFor@juce@@YAHPAX@Z)  
juce\_win32\_SystemStats.obj : error LNK2019: unresolved external symbol imp\_\_timeBeginPeriod@4 referenced in function "public: static void cdecl juce::SystemStats::initialiseStats(void)" (?initialiseStats@SystemStats@juce@@SAXXZ)  
juce\_win32\_Windowing.obj : error LNK2019: unresolved external symbol DrawDibDraw@52 referenced in function "public: void **thiscall juce::WindowsBitmapImage::blitToWindow(struct HWND** \*,struct HDC \*,bool,int,int,class juce::RectangleList const &)" (?blitToWindow@WindowsBitmapImage@juce@@QAEXPAUHWND@@PAUHDC@@NHHABVRectangleList@2@@Z)  
juce\_win32\_Windowing.obj : error LNK2019: unresolved external symbol DrawDibOpen@0 referenced in function "public: void **thiscall juce::WindowsBitmapImage::blitToWindow(struct HWND** \*,struct HDC \*,bool,int,int,class juce::RectangleList const &)" (?blitToWindow@WindowsBitmapImage@juce@@QAEXPAUHWND@@PAUHDC_@@\_NHHABVRectangleList@2@@Z)

Regards  
Yogesh

---

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [May 30, 2006, 1:19pm UTC](https://forum.juce.com/t/juce-as-dll/861/6 "2006-05-30T13:19:55Z")

</div>

Hi,  
I managed to get dll built. I had to link to the  
kernel32.lib  
user32.lib and so on…  
using the project settings of the JUCE solution file.

Also in juce\_StandardHeader.h file, “juce\_PlatformDefs.h” must  
be included before the places where you use the JUCE\_WIN32.  
coz JUCE\_WIN32 is defined in platformdefs.h.

Also I tried to build juce demo using the DLL, I built. It  
does not work. It may be because all classes are not exported  
to dll. Eg Colours.

Please let me know if I am doing any thing wrong.

Regards  
Yogesh

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 30, 2006, 1:30pm UTC](https://forum.juce.com/t/juce-as-dll/861/7 "2006-05-30T13:30:51Z")

</div>

no… There’s already a juce DLL configuration, you don’t need to change any settings in the juce project itself! Just build the “Debug DLL” and “Release DLL” configurations! Then in your app, define JUCE\_DLL before it includes juce.h

---

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [May 30, 2006, 1:41pm UTC](https://forum.juce.com/t/juce-as-dll/861/8 "2006-05-30T13:41:09Z")

</div>

Hi,  
I am using VC++ 7.1 What I do is, upgrade the vc6.0 project file.  
I do not get the “Debug DLL” and “Release DLL” configurations.

Also have you tried linking the dll, so built with juce demo?

Please help.  
Yogesh

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 30, 2006, 1:47pm UTC](https://forum.juce.com/t/juce-as-dll/861/9 "2006-05-30T13:47:15Z")

</div>

Ah - I thought there were vc6 projects for that as well, but it seems they’re only in the vcexpress version.

I think it should all work though, as long as you define JUCE\_BUILD\_DLL globally for the project when you build the dll.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 30, 2006, 1:47pm UTC](https://forum.juce.com/t/juce-as-dll/861/10 "2006-05-30T13:47:52Z")

</div>

(or just use vcexpress to build the DLLs, of course…)

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.juce.com/u/thomas)\
**Post date:** [May 30, 2006, 2:07pm UTC](https://forum.juce.com/t/juce-as-dll/861/11 "2006-05-30T14:07:20Z")

</div>

… if you don’t have vcexpress, just change the vcexpress workspace and project files like described [here](http://www.adbe.org/juceforum/viewtopic.php?t=694)

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [May 30, 2006, 8:00pm UTC](https://forum.juce.com/t/juce-as-dll/861/12 "2006-05-30T20:00:38Z")

</div>

VCExpress is a huge hassle to setup, and it does not allow plugins like Visual Assist. So it is completely and utterly useless (Visual Studio itself is not at all pleasent to work in without Visual Assist after all 🙂 ).

What is the point of having a vcexpress version since any version after 6 can pull in and upgrade from a 6 project version?

You may also think about that one make manager (don’t recall the name, I can find it if need-be) that outputs project’s of many things, from near any version of VS to gcc to whatnot…

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.juce.com/u/thomas)\
**Post date:** [May 30, 2006, 10:20pm UTC](https://forum.juce.com/t/juce-as-dll/861/13 "2006-05-30T22:20:21Z")

</div>

yes, we use [CMake](http://www.cmake.org), it just works and is used in many big and complex projects.  
We even integrated Juce and its dependancies in the build process on the three platforms.

There is another one called [SCons](http://www.scons.org) but it looks much less mature.

beside, I tried visual assist before, the only useful features are now in vcexpress and in a much better and faster way… it’s never been lighter and simplier. And most of all, it has finally a decently c++ standard conformant compiler.

---

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [May 31, 2006, 6:25am UTC](https://forum.juce.com/t/juce-as-dll/861/14 "2006-05-31T06:25:04Z")

</div>

Hi all,  
Thanks for the tip, to convert the vcexpress project.  
But my initial question remains the same. Has anybody tried using  
juce as dll and building the juce demo with it?

I get linker error when I do that. Because all classes are not exported to dll. Ex. SliderListener, AudioDeviceSelectorComponent and some more

Also to create JUCE\_debug.lib I have to change “juce\_standardHeaders.h”.  
Because JUCE\_API is never defined to \_\_declspec (dllexport).

When I fix the above problems things go fine 😃  
Jules, can you please look into it.

Thanks,  
Yogesh Kini

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 31, 2006, 7:55am UTC](https://forum.juce.com/t/juce-as-dll/861/15 "2006-05-31T07:55:42Z")

</div>

Ah, sorry, when I add new classes I keep forgetting to make sure they’re set up for use in a DLL - sorry! It’s easy though - all you have to do is to add JUCE\_API in the class declaration if you find one that I’ve missed out.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [May 31, 2006, 6:19pm UTC](https://forum.juce.com/t/juce-as-dll/861/16 "2006-05-31T18:19:34Z")

</div>

VC2k5 does not at all support all of VA’s things, it did add a couple, but even looking at basic things, VC2k5’s intellisense get’s hung up and bloated too easily, just turn it off and use VA’s instead, far better, just for that even. Not to mention I like my full setup of quick-code pastes and other such things I use often that are not in VC/any\_version.

---

<div class="post-metadata">

**Author:** ![kini1982](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kini1982](https://forum.juce.com/u/kini1982)\
**Post date:** [June 2, 2006, 5:20am UTC](https://forum.juce.com/t/juce-as-dll/861/17 "2006-06-02T05:20:01Z")

</div>

Hi Jules,  
I was able to build the juce dll as you told me.I compiled the juce demo and used the dll instead of static lib. It compiles and links properly, But juce Demo crashen in the “MainDemoWindow” constructor.

commandManager-\>registerAllCommandForTarget(contentComp);

Has any one else noticed this problem?

Regards,  
Yogesh

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 2, 2006, 9:14am UTC](https://forum.juce.com/t/juce-as-dll/861/18 "2006-06-02T09:14:32Z")

</div>

Ok, just had a go of this myself, and was a bit puzzled because although I thought that it used to be compiling the dll correctly, in fact it wasn’t - it was just compiling the static one… and when I fixed this, there were loads of errors that I should have spotted earlier. Sorry about that! I’m going through it now so will have it fixed in the next release. And if I see the same crash you mention, I’ll let you know how to fix it.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 2, 2006, 10:12am UTC](https://forum.juce.com/t/juce-as-dll/861/19 "2006-06-02T10:12:08Z")

</div>

Right. This is a really nasty problem.

The crash happens because the dll passes an array to the app, and the app adds items to it. Because arrays are templated, they can’t be exported from a dll, so the app and the dll end up with two separate versions of the array code, which use different allocators. So when one module creates an array, the other module will blow up if it tries to use it.

To be honest, I’ve no idea how you could get around this, except by changing every single interface in the whole library to make sure no templated objects are never passed in or out of a juce class.

Yet another reason why I always use static linking - it’s just so much less hassle!

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [June 3, 2006, 1:23am UTC](https://forum.juce.com/t/juce-as-dll/861/20 "2006-06-03T01:23:09Z")

</div>

Instead of embedding the allocator, you should have it as an internal class which is instanced by the object to handle creation/destruction. Boost uses that pattern for everything templated to prevent anything like that.

Yes, I am sorry for talking about boost so much recently, but everything I’ve talked about it is just so appropriate for what is being talked about. \>.\>

[Next page](https://forum.juce.com/t/juce-as-dll/861.md?page=2)
