Support #1764
closedUsing plug-in dll with one excutable.
0%
Description
Hi,
I tried to make one excutable which has one and more dll as plug-in.
The excutable is a main app(e.g hello) and it calls dll which has widgets(e.g. Wt::WPushButton) explicitly as plug-in.
However, the excutable could not have the widgets and make error from several places 'Access violation' or 'Heap error' or 'bad memory error'
I did set -DSHARED_LIBS=ON but I could not resolve this problem.
Could you let me any idea about it?
I added my project (Test.zip) and hello.c (for main app).
Regards,
Files
Updated by Wim Dumon about 11 years ago
- Assignee set to Wim Dumon
- Priority changed from Urgent to Normal
Updated by Wim Dumon about 11 years ago
Hi Richard,
I ran your test case without any problem - no crashes and the behaviour is as expected (a button is shown). I suspect you have a build problem, since MSVS will be very picky on how you build your application.
I did not use your project file because I generated it using CMake because I'm more familiar to it. This is my cmake file for the DLL:
include_directories("c:/wt-install/include")
link_directories("c:/wt-install/lib")
include_directories("c:/Boost/include/boost-1_52/")
link_directories("c:/Boost/lib/")
add_library(Test SHARED dllmain.cpp)
target_link_libraries(Test wtd)
From your description, my first guess would be that you mix up runtime libraries. For this configuration to work, you must not use static runtime libraries (no /MT or /MTd - the DLL and EXE would have different heaps, but objects allocated by the DLL may be deleted by the EXE or vice versa), and you must not mix debug or non-debug runtimes in one project (no mixing of /MD and /MDd - same reason as before).
How does this translate to Wt? Wt libraries linked against the MSVS debug DLLs will have a 'd' suffix (wtd.lib, wthttpd.lib, ...). Wt libraries linked against the release crt will have no suffix (wt.lib, wthttp.lib, ...).
It's not a wise idea to use static wt libraries in your use case - I don't guarantee at all that this will work. Build Wt as a dll (SHARED_LIBS ON, like you mention), and link your exe as well as your DLL to the same wt library. For me, this worked like a charm.
BR,
Wim.
Updated by Richard Moon about 11 years ago
Hi Wim,
I fixed this issue. My project was linked dlls incorrectly.(dlls were from the previous version)
Thank you so much.