Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
cbpporter is currently offline  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 #22291 is a reply to message #22290] Wed, 01 July 2009 08:18 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Can't help with any of your question, but I have something to add about those crashes...

Sometimes I use TheIDE for PHP editing, and sometimes I get confused when switching a lot between browser, and I hit F5 = refresh in TheIDE => instant crash. (the project contains only some php and css files) (some older svn version of theIDE, probably 3-4 months old)
Re: Some small issues with TheIDE and DLLs [message #22292 is a reply to message #22290] Wed, 01 July 2009 08:58 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
for the linux question, i was able to make a so file with the dll flag, but i needed to add a compiler option entry in the package organizer

options(DLL && GCC) -fPIC

cocob

[Updated on: Wed, 01 July 2009 08:59]

Report message to a moderator

Re: Some small issues with TheIDE and DLLs [message #22293 is a reply to message #22290] Wed, 01 July 2009 10:58 Go to previous messageGo to next message
mirek is currently offline  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 #22294 is a reply to message #22290] Wed, 01 July 2009 11:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Tue, 30 June 2009 22:58

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.



Ah, now noticed this one Smile

Well, of course, each process has its own copy of .dll (.so) global data. In fact, only code sections are shared (as they are for multiple process of single binary).

Mirek
Re: Some small issues with TheIDE and DLLs [message #22320 is a reply to message #22294] Fri, 03 July 2009 13:35 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Even with problems stated above, I managed to get things working.
Most of the functionality is working and I haven’t had any problems with C++ initialization sections (I guess DLL mechanism is smart enough to call the code that initializes all the global class variables).

There is just one issue. I can't create TopWindows with code from the DLL. Even in simple cases, a function exported by the DLL which creates a TopWindow and calls OpenMain won't show it (if called without DLL the windows appears and is unresponsive until event loop; I would like the same behavior with DLLs), and a function which starts the EventLoop will try to write to NULL.

Is this related to the TLS issue you mentioned above? I'm loading the DLL with LoadLibrary/GetProcAddress.
Re: Some small issues with TheIDE and DLLs [message #22438 is a reply to message #22320] Wed, 15 July 2009 17:26 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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) 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@@QAEXABV?$basic_string@DU?$char_traits@D>@std@@V?$allocator@D>@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?$basic_string@DU?$char_traits@D>@std@@V?$allocator@D>@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@@QAEXABV?$basic_string@DU?$char_traits@D>@std@@V?$allocator@D>@2@@std@@@Z)
$blitz.obj : error LNK2019: unresolved external symbol "public: __thiscall MyEngine::Plugin::Plugin(class MyEngine::Plugin const &)" (??0Plugin@MyE
ngine@@QAE>@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@@V?$allocator@D>@2@@std@@VPlugin>@MyEngine@@@std@@QAE>@ABV?$basic_string@DU
?$char_traits@D>@std@@V?$allocator@D>@2@@1>@ABVPlugin>@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

Previous Topic: Editing Python scripts in TheIde
Next Topic: Font for Edit/Output window - width between the chars is too big
Goto Forum:
  


Current Time: Thu Apr 18 23:30:49 CEST 2024

Total time taken to generate the page: 0.03491 seconds