|
|
Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » Some small issues with TheIDE and DLLs
Some small issues with TheIDE and DLLs [message #22290] |
Wed, 01 July 2009 04:58 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
I need to generate a DLL from TheIDE which exports some functions with implementations that use U++ classes.
First I tried setting the "All shared" option. This was a long shot and I was sure it wouldn't work, but the build process crashed. It shouldn't crash.
After some searching on the site I found that you are supposed to set the "DLL" configuration flag. This seems to have worked. I get a rather large DLL (probably the linker doesn't know what to exclude and includes all), an ".exp" file and a ".lib" file. Everything seems to work. Except when I hit run, I get a nice error message that the DLL can't be run (which is true of course) and a nice crash. It shouldn't crash.
But when building with MINGW I don't get the ".lib". This is needed if I don't do manual loading of the DLL. (Also the DLL is more than twice as big when compared to the MSC version, but I guess this is to be expected).
I have a few questions:
1. Should I compile with USEMALLOC option. Will U++'s malloc implementation cause problems if I free in the client application something allocated by the host? Will it be okay if all allocation and freeing is done by calls to the DLL?
2. Will there be issues with "icpp"s and other initialization tricks that U++ uses?
3. Can I use the the "DLL" flag under Linux or must it be changed to "SO". Same issue, I don't want a .so for every package, I want one big one.
4. Is there some macro provided by U++ as a platform independent equivalent of __declspec(dllexport) for writing DLLs?
5. What happens to global variables. What if my functions alter such variables. Will there be multiple such instances for different clients or will they override each other. Can this cause problems with all the global variables U++ uses internally? And is this behavior consistent across platforms?
Thank You
|
|
|
|
|
Re: Some small issues with TheIDE and DLLs [message #22293 is a reply to message #22290] |
Wed, 01 July 2009 10:58 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
cbpporter wrote on Tue, 30 June 2009 22:58 | I need to generate a DLL from TheIDE which exports some functions with implementations that use U++ classes.
First I tried setting the "All shared" option. This was a long shot and I was sure it wouldn't work, but the build process crashed. It shouldn't crash.
|
With MSC?
Quote: |
After some searching on the site I found that you are supposed to set the "DLL" configuration flag. This seems to have worked. I get a rather large DLL (probably the linker doesn't know what to exclude and includes all), an ".exp" file and a ".lib" file. Everything seems to work. Except when I hit run, I get a nice error message that the DLL can't be run (which is true of course) and a nice crash. It shouldn't crash.
|
Definitely. Will look into it ASAP.
Quote: |
But when building with MINGW I don't get the ".lib". This is needed if I don't do manual loading of the DLL. (Also the DLL is more than twice as big when compared to the MSC version, but I guess this is to be expected).
|
Not sure we even want to support mingw there....
Quote: |
I have a few questions:
1. Should I compile with USEMALLOC option. Will U++'s malloc implementation cause problems if I free in the client application something allocated by the host? Will it be okay if all allocation and freeing is done by calls to the DLL?
|
Depends.If all allocations / freeing is done by calls to the DLL, then AFAIK it should be ok.
If not, then AFAIK you can have problems with USEMALLOC as well...
Generally, DLL interfaces are designed so that either memory is handled by Win32 API, or handled by calls to DLL (no explicit frees).
Quote: |
2. Will there be issues with "icpp"s and other initialization tricks that U++ uses?
|
I believe not, or not really big, as long as compiler/linker supports global constructors/destructors.
Quote: |
3. Can I use the the "DLL" flag under Linux or must it be changed to "SO". Same issue, I don't want a .so for every package, I want one big one.
|
It is still DLL (although it produces SO).
Quote: |
4. Is there some macro provided by U++ as a platform independent equivalent of __declspec(dllexport) for writing DLLs?
|
No.
Quote: |
5. What happens to global variables. What if my functions alter such variables. Will there be multiple such instances for different clients or will they override each other. Can this cause problems with all the global variables U++ uses internally? And is this behavior consistent across platforms?
|
In POSIX, everything behaves exactly as normal.
In Win32, global variables exist, but are not accessible from outside of DLL.
One special consideration is TLS variables in Win32 - they are mutually exclusive with run-time loading of .dll (if that is the right term, I mean loading .dll explicitly, not by linker).
Mirek
|
|
|
|
|
Re: Some small issues with TheIDE and DLLs [message #22438 is a reply to message #22320] |
Wed, 15 July 2009 17:26 |
|
Ok!
About static and dynamic libraries.
I tried to export from visual studio project to u++ example and can't to simulate same situation in U++. Maybe I'm not know U++ so all!
I attached Both variants, visual studio c++ 2008 expres edition and U++ version.
For MSC expres compiles and works fine but for U++ I cant compiled.
This example contains 4 packages(project):
myengine - core project that compiles in dll and links in all other packages as static link
myapplication - main console exe file
opengl_plugin - dll plugin
zip_plugin - dll plugin
If anybody can help me on this simple example I will can to continue my test on linux too. I'm interesting in plugin framework. Short good wiki founded here, here and here:
Thanks for attention!
Add:
For details in U++ on I compile package "myengine" I have following error:
Quote: |
----- myengine ( DLL MYENGINE_EXPORTS MAIN MSC9 DEBUG DEBUG_FULL BLITZ WIN32 MSC )
cd D:\ILupascu\sourcecode\cpp\upp\plugin_cpp_example1\myengine
BLITZ: storage_server.cpp myengine.cpp
$blitz.cpp
"C:\Program Files\Microsoft Visual Studio 9.0\Vc\Bin\cl.exe" -nologo -W3 -GR -c -I"D:\ILupascu\sourcecode\cpp\upp\plugin_cpp_example1" -I"C:\Progra
m Files\Microsoft SDKs\Windows\v6.0A\Include" -I"C:\Program Files\Microsoft Visual Studio 9.0\Vc\Include" -I"C:\upp\sdl\include" -DflagDLL -Dfl
agMYENGINE_EXPORTS -DflagMAIN -DflagMSC9 -DflagDEBUG -DflagDEBUG_FULL -DflagBLITZ -DflagWIN32 -DflagMSC -DbmYEAR=2009 -DbmMONTH=7 -DbmDAY=16 -D
bmHOUR=14 -DbmMINUTE=32 -DbmSECOND=41 -EHsc -Zi -MTd -Od -Gy -Fd" C:/upp/out/myengine/MSC9.Debug.Debug_full.Dll.Main.Myengine_ exports\myengine-
1.pdb" -Tp " C:/upp/out/myengine/MSC9.Debug.Debug_full.Dll.Main.Myengine_ exports\$blitz.cpp " -Fo"C:/upp/out/myengine/MSC9.Debug.Debug_full.Dll.M
ain.Myengine_exports\$blitz.obj"
myengine: 2 file(s) built in (0:00.96), 484 msecs / file, duration = 985 msecs, parallelization 0%
Linking...
link -nologo -machine:I386 -pdb:" C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exports\myengi ne.pdb " -out:"C:\upp\out\MSC9.Debug.Debug_full.Dll.Mye
ngine_exports\myengine.dll" -incremental:yes -debug -OPT:NOREF -subsystem:console -DLL -LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v6.0A\
Lib" -LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib" -LIBPATH:"C:\upp\sdl\lib" "C:\upp\out\myengine\MSC9.Debug.Debug_full.Dll
.Main.Myengine_exports\$blitz.obj"
Creating library C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exports\myengi ne.lib and object C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exp
orts\myengine.exp
$blitz.obj : error LNK2019: unresolved external symbol "public: __thiscall MyEngine::Plugin::~Plugin(void)" (??1Plugin@MyEngine@@QAE@XZ" target="_blank">>@XZ) referenced
in function "public: void __thiscall MyEngine::Kernel::loadPlugin(class std::basic_string<char,struct std::char_traits<char>,class std::alloca
tor<char> > const &)" (?loadPlugin@Kernel@MyEngine" target="_blank">>@MyEngine@@QAEXABV?$basic_string@DU?$char_traits@D@std" target="_blank">>@std@@V?$allocator@D@2" target="_blank">>@2@@std@@@Z)
$blitz.obj : error LNK2019: unresolved external symbol "public: __thiscall MyEngine::Plugin::Plugin(class std::basic_string<char,struct std::char_t
raits<char>,class std::allocator<char> > const &)" (??0Plugin@MyEngine@@QAE@ABV" target="_blank">>@ABV?$basic_string@DU?$char_traits@D@std" target="_blank">>@std@@V?$allocator@D@2" target="_blank">>@2@@std@@@Z)
referenced in function "public: void __thiscall MyEngine::Kernel::loadPlugin(class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &)" (?loadPlugin@Kernel@MyEngine" target="_blank">>@MyEngine@@QAEXABV?$basic_string@DU?$char_traits@D@std" target="_blank">>@std@@V?$allocator@D@2" target="_blank">>@2@@std@@@Z)
$blitz.obj : error LNK2019: unresolved external symbol "public: __thiscall MyEngine::Plugin::Plugin(class MyEngine::Plugin const &)" (??0Plugin@MyE
ngine@@QAE@ABV01" target="_blank">>@ABV01@@Z) referenced in function "public: __thiscall std::pair<class std::basic_string<char,struct std::char_traits<char>,class std:
:allocator<char> > const ,class MyEngine::Plugin>::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
const ,class MyEngine::Plugin>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class MyEngine:
:Plugin const &)" (??0?$pair@$$CBV?$basic_string@DU?$char_traits@D@std" target="_blank">>@std@@V?$allocator@D@2" target="_blank">>@2@@std@@VPlugin@MyEngine" target="_blank">>@MyEngine@@@std@@QAE@ABV" target="_blank">>@ABV?$basic_string@DU
?$char_traits@D@std" target="_blank">>@std@@V?$allocator@D@2" target="_blank">>@2@@1@ABVPlugin" target="_blank">>@ABVPlugin@MyEngine" target="_blank">>@MyEngine@@@Z)
C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exports\myengi ne.dll : fatal error LNK1120: 3 unresolved externals
"C:\Program Files\Microsoft Visual Studio 9.0\Vc\Bin\link.exe" -nologo -machine:I386 -pdb:"C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exports\my
engine.pdb" -out:" C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exports\myengi ne.dll " -incremental:yes -debug -OPT:NOREF -subsystem:console -DL
L -LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" -LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib" -LIBPATH:"C:\upp\
sdl\lib" " C:\upp\out\myengine\MSC9.Debug.Debug_full.Dll.Main.Myengine_ exports\$blitz.obj "
Error executing "C:\Program Files\Microsoft Visual Studio 9.0\Vc\Bin\link.exe" -nologo -machine:I386 -pdb:"C:\upp\out\MSC9.Debug.Debug_full.Dll.Mye
ngine_exports\myengine.pdb" -out:" C:\upp\out\MSC9.Debug.Debug_full.Dll.Myengine_exports\myengi ne.dll " -incremental:yes -debug -OPT:NOREF -subsy
stem:console -DLL -LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" -LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib" -
LIBPATH:"C:\upp\sdl\lib" " C:\upp\out\myengine\MSC9.Debug.Debug_full.Dll.Main.Myengine_ exports\$blitz.obj "
Exitcode: 1120
There were errors. (0:01.15)
|
In visual studio build I have folowing command lines:
Quote: | Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\RSP0000016923892.rsp " with contents
[
/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "MYENGINE_EXPORTS" /D "_VC80_UPGRADE=0x0710" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /Wp64 /ZI /TP .\storage_server.cpp
.\plugin.cpp
.\myengine.cpp
]
Creating command line "cl.exe @d:\ILupascu\help\programming\cpp\best_plugin_example\myengi ne\Debug\RSP0000016923892.rsp /nologo /errorReport:prompt"
Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\TMP0000026923892.tmp " with contents
[
2 /* ISOLATIONAWARE_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\myengine.dll.embed.manifest"
]
Creating command line "rc.exe /fo".\Debug\myengine.dll.embed.manifest.res" d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\TMP0000026923892.tmp "
Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\RSP0000036923892.rsp " with contents
[
/OUT:"../Debug/myengine.dll" /INCREMENTAL /DLL /MANIFEST /MANIFESTFILE:"Debug\myengine.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"../Debug/myengine.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE:NO /IMPLIB:"../Debug/myengine.lib" /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
".\Debug\myengine.obj"
".\Debug\plugin.obj"
".\Debug\storage_server.obj"
".\Debug\myengine.dll.embed.manifest.res"
]
Creating command line "link.exe @d:\ILupascu\help\programming\cpp\best_plugin_example\myengi ne\Debug\RSP0000036923892.rsp /NOLOGO /ERRORREPORT:PROMPT"
Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\RSP0000046923892.rsp " with contents
[
/out:.\Debug\myengine.dll.embed.manifest /notify_update /manifest
.\Debug\myengine.dll.intermediate.manifest
]
Creating command line "mt.exe @d:\ILupascu\help\programming\cpp\best_plugin_example\myengi ne\Debug\RSP0000046923892.rsp /nologo"
Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\BAT0000056923892.bat " with contents
[
@echo Manifest resource last updated at %TIME% on %DATE% > .\Debug\mt.dep
]
Creating command line " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\BAT0000056923892.bat "
Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\TMP0000066923892.tmp " with contents
[
2 /* ISOLATIONAWARE_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\myengine.dll.embed.manifest"
]
Creating command line "rc.exe /fo".\Debug\myengine.dll.embed.manifest.res" d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\TMP0000066923892.tmp "
Creating temporary file " d:\ILupascu\help\programming\cpp\best_plugin_example\myengin e\Debug\RSP0000076923892.rsp " with contents
[
/OUT:"../Debug/myengine.dll" /INCREMENTAL /DLL /MANIFEST /MANIFESTFILE:"Debug\myengine.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"../Debug/myengine.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE:NO /IMPLIB:"../Debug/myengine.lib" /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
".\Debug\myengine.obj"
".\Debug\plugin.obj"
".\Debug\storage_server.obj"
".\Debug\myengine.dll.embed.manifest.res"
]
Creating command line "link.exe @d:\ILupascu\help\programming\cpp\best_plugin_example\myengi ne\Debug\RSP0000076923892.rsp /NOLOGO /ERRORREPORT:PROMPT"
|
[Updated on: Thu, 16 July 2009 13:33] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Wed May 08 07:33:39 CEST 2024
Total time taken to generate the page: 0.02952 seconds
|
|
|