Debug same shared project. Avoid "it is being used by another process" - dll

¿Is there any way I can have the same library across multiple projects, and debug them without the random "it is being used by another process"?
I know that is possible to add the DLL directly, but if I need to debug the library in both projects at the same time?

Related

Consuming .dylib from a server runtime

I have a requirement where I have to get the compiled code dynamically from the server and execute them from the OS X application. In short, the idea is to have few classes and methods in the compiled code(it can be a .dylib, .a or a bundle) hosted on a server, and the application downloads it form the server and accesses those classes dynamically. The completed code might contains HTML, javascript, Objective-C, or Swift.
Option 1. Static library
It has to be part of the consuming application at compile time, so i think we can rule this option out.
Option 2. Dynamic library
I am struggling here, is it possible to download the dylib form the server and copy them in one of the application folders, and run from there dynamically using dlopen. is it possible?
Option 3. Bundle
I did not look into this yet, but the idea is similar to dylib.
Option 4. any other possibilities..
Surely you can download a dylib. Why should that be impossible?
Then you can store it in one of the paths the dynamic linker is looking for. This is described here.
Even I did not test it, I do not know, why this shouldn't work.

LabView doesn't unload dll when called in development environment

I have a LabView application that uses an external C DLL. When I run my application in the development environment, the DLL is blocked even after the the app is closed.
When I want to overwrite or delete the DLL, I have to first close LabView completely.
Is this a known issue? Can anyone offer a solution for this problem?
Yes, you must do two things in your LabVIEW application:
Specify the path to the library on the block diagram rather than in the configuration dialog (which changes LabVIEW's behavior from load-time linking to run-time linking).
When you're done using the DLL node, wire a null path to tell LabVIEW that you're done using it (which causes Windows' reference count to decrement to 0 and the OS will unlock the file).
More details here: Can I Dynamically Load and Unload a DLL in LabVIEW?

How to automate building of third party library using cmake

What I am looking for:
Download library
Extract It
Apply custom patch
Run configure
Run build command
What library I am trying to build are:
Openssl
Boost
Thrift
C-ares
Curl
Pcre
Nginx
ICU
JsonCPP
I think I can do these things using external module: http://cmake.org/cmake/help/v2.8.8/cmake.html#module:ExternalProject
But I have following question?
I have different type of build and with different directory. Is it
going to build all these library for every different target? If yes
it will be painful as all these library take one hour to build. Is
there a way I can control it and it only build it once. As library
remains same for all these targets.
On switching directory to different name. Cmake force everything to
be rebuild-ed. Will it be same for external library. If yes? How to
solve this problem. I don't want to rebuild the library if I am not
changing them and want to use them while switching to different
branches without building them.
Yes, you can use CMake's ExternalProject feature to accomplish what you want to do.
When using cross-compilation in combination with external projects, the source code will be built once for each toolchain. You could avoid rebuilds if you checked in the results of the build into a source-control system, and re-checked it out on each new person's machine, but I do not recommend this. Instead, have one of your "set up new computer" tasks actually be allowing the compilation to run overnight, which will also act as a test that the machine is actually usable. That set-up task can be launched by a system administrator prior to a new hire's arrival, or you can leave it to the new hire, as circumstances require.
I'm not completely certain what you are asking in your second question, but if the library is unchanged, CMake will detect that it is unchanged and not recompile it. Typically, the source code would be in a single directory tree: each compiled version would be built in a distinct location. Thus, developers can access any compiled version at any time just by switching directories. This is particularly helpful because it allows you to mount these directories over NFS to embedded hardware, et cetera.

run wxHaskell on other machine

I've compiled haskell program which uses wxHaskell library, now I would like to know how to make it run on other machines which doesn't have wxHaskell installed. Of course I can see errors and I can copy dlls written in output and copy them to that machine but what is professioal sollution, can I write any installer or something like that?
thanks for help
You will need to fully statically link your executable. How to do this varies from system to system, but in general involves passing the -static flag to GHC, and -optl-static to your linker.
If you use the recent cabalized wxHaskell implementations, it's pretty easy, since almost everything is statically linked.
I use InnoSetup, which is Open Source, and works very well. My script needs at least the following:
AppName=My Wonderful Application
AppVerName=My Wonderful Application 0.1.13
CreateAppDir=yes
DefaultDirName={pf}\MyWonderfulApplication
[Files]
Source: "path\to\your\wxWidgets.dll"
Source: "path\to\msvcrt.dll"
Source: "path\to\your\application.exe"
All of the paths except DefaultDirName are paths on your development machine.
The key items are your wxWidgets DLL (may be multiple DLLs, depending on how you built wxWidgets - I recommend and use the monolithic option, which creates a single DLL, wxmsw28u_gcc_custom.dll) and your application binary.
If you are linking to any other libraries, you will need them as well. Many 3rd party libraries on Windows require msvcrt.dll, which is why I've mentioned it.

Problems using dynamic linked libraries (wxWidgets) from a DLL

We created a plugin; it is a DLL (Run-Time Dynamic Linking) which uses a 3rd party library (wxWidgets) and also links dynamically to that. The host software seems to scan our plugin, but exported functions are not called. We checked all dependencies with DependencyWalker.
We see in the debugger that the plugin is loaded, but the DllMain is not called, and the plugin is unloaded.
We tried loading our plugin from a simple test application using LoadLibrary and GetProcAddress which recognized and called the exported functions.
Having wxWidgets linked statically worked fine, though.
Does anyone have an idea why the exported function, respectively DllMain are not called, or can point out a tool which is capable to monitor the whole DLL loading process?
If wxWidgets is loaded already into the process address space before your plugin is loaded (the host app could do that, or there might be another plugin linking to wxWidgets which is loaded before yours), then there might be a chance that it is another version, missing some of the entry points that your plugin needs. Running the host app under DependencyWalker or WinDbg should show you which wxWidgets DLL is loaded, and you could try to load your plugin from your test app using exactly the same wxWidgets DLL. That should reveal whether there are missing dependencies.
Perhaps the host software does some funky things when loading the plugin and doesn't like wxWindows.
Anyways, try using the ProcessExplorer from the SysInternals suite to check what the process is doing.