Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] Re: RE: Re: RE: CMake DLL generation and .lib linking error


Chronological Thread 
  • From: Solomon Boulos < >
  • To:
  • Subject: [Manta] Re: RE: Re: RE: CMake DLL generation and .lib linking error
  • Date: Thu, 30 Oct 2008 15:24:10 -0700

The AtomicCounter code is #included depending on your configuration. This is mostly due to the legacy of the way SCIRun did it, but you shouldn't get linker errors when referring to AtomicCounter directly. Again, if you build manta as a giant library (that is all of Manta's sub-libraries are statically build and linked in) and then treat Manta as a tool you are using (so all of manta becomes one big .dll or .lib) you'll be much happier.

As James explained as well, we don't export any symbols manually so all of Manta's sub-libraries will probably be completely void of symbols. If you statically link against Manta, you can use anything from any header file in Manta directly. Also, static variables are "per-library" so if Manta_Core and Manta_Factory both have a static initialization of an object, both libraries will do so upon loading (this is that thread init on load problem you had earlier). If Manta is just one library, then all of Manta's initialization is clearly just going to happen once. I can't see any reason to use any of Manta's sub-libraries directly, so you probably just want to be able to produce Manta.dll and link your application against that.

Windows library linking is an enormous nightmare, I'd suggest finding someone that knows the area well (I don't know anyone that does) or stick to the simpler solution by building everything statically into a single dynamic library.

Solomon

On Oct 30, 2008, at 2:37 PM, Bo Huang wrote:

So, essentially Manta related happens in the dll. The main exe would call the dll and doesn’t know about Manta at all. In this fashion, there is only one memory space. I guess this is indicative that my mentioned method of converting all manta libs to dll would work to prevent static variables from being duplicated. That is, even if scene_0.dll refers to the static variables defined in manta_core.dll, no additional copies of these statics would be created in scene_0.dll.
 
I also observed that Core/CMakelist.txt does not include AtomicCounter_default.cc or AtomicCounter_x86.cc. Hence I get linking errors when other components such as Manta_interface refers to AtomicCounter. Previously when I compiled these components as libs rather than dlls I did not encounter this.
 
If I include either source into CMakelist.txt, the compilation fails because other needed manta headers are not included. Should I manually fix either source? I may encounter more such occurrences.
 
Thanks
 
Bo.
 

 
When I was working on a plugin that used Manta, I built the Manta libraries as static, then linked them all into the final plugin (which was a dll).  This way I could get access to all the classes without having to export any Manta things.  I didn't attemp to load any of the scene files, because the plugin generated the scene geometry I needed.  This worked on Mac, Linux and Windows.

James

Right now I am working within Manta to load at run time scenes such as scene_0.dll, rather than compiling scene_0.cc into Manta at compile time. When that works the program I am developing that uses Manta will come next. The intention is to use Manta purely as Dlls rather than Libs, which would presumably sidestep the duplicated static variable problem I posted earlier. I think this would work because there would be no static linkage.

 

I see that either I stick __declspec(dllexport) to all classes.

 

Or, like you suggested, export the class Thread, which contains that static member threadids. Since Thread is part of the project Manta_Core and the desire is to get Manta_Core.dll, I would probably have to export all classes in this project?

 

 

 

The CMake variable is BUILD_SHARED_LIBS. Take a look at /CMakeLists.txt line:33.

 

The code doesn't contain the declspec modifiers to export/import symbols on Windows... so the default build is static. Come to think of it, could you get away with a static build of all the Manta libraries and then explicitly export a small number of symbols used by the program you are embedding Manta within?

 

Abe

 

On Oct 30, 2008, at 10:43 AM, Bo Huang wrote:

 

Which flags in CMake dictates creation of DLLs rather than Libs?

 

I just noticed my MSVC projects generate .libs such as Manta_Core.lib rather than Manta_Core.dll. I could manually convert them but the settings will be gone when CMake regenerates the .vcprojs.

 

Also:

 

When I manually converted the vcproj for Manta_core from generating .lib to .dll, Winnm.lib was not linked and caused linking error for the timeBeginPeriod() function. I notice that this lib is mentioned in Core/CMakelist.txt, but doesn't seem to have made a difference.

 

Thanks

 

Bo

 

 




Archive powered by MHonArc 2.6.16.

Top of page