Skip to content

Minimal MSVC compatibility adjustments - #2136

Closed
classner wants to merge 0 commit into
BVLC:masterfrom
classner:master
Closed

Minimal MSVC compatibility adjustments#2136
classner wants to merge 0 commit into
BVLC:masterfrom
classner:master

Conversation

@classner

Copy link
Copy Markdown

Second attempt to submit my minimal changeset for full MSVC compatibility.

These adjustments are as non-invasive and minimal as possible, in the hope to be merged into the main branch. This would enable "external" build systems to build caffe out-of-the box on Windows (for example the caffe-brewer.

@Nerei

Nerei commented Mar 24, 2015

Copy link
Copy Markdown

@ChrisLS Have you tried to execute tests? I suspect it may not work. If I am not mistaken, __declspec(dllexport) is required everywhere.

@Nerei

Nerei commented Mar 24, 2015

Copy link
Copy Markdown

@ChrisLS Btw, great work with caffe-brewer!!! This is exactly what I wanted to create but haven't found time slot yet. No, this is better that what I wanted ;-)

I found answer on my previous question, you use /OPT:NOREF option and static linking. trick with adding caffe objects to executable.

I hope this would be solved in future in more conventional way by adding dllexport's and linking dll library

@classner

Copy link
Copy Markdown
Author

Hi @Nerei,
all the tests are passing on Windows (take into account the note about having at least 1TB of disk space available)! The system is in productive use and I use the caffe-brewer to link the object files to another project.

Sure, it would be a lot more convenient if Microsoft offered a way to force full static linking. However, as I wrote in the README.MD, /OPT:NOREF did not force the linkage of static global objects, hence resulting in unregistered layers.

@willyd

willyd commented Jun 19, 2015

Copy link
Copy Markdown
Contributor

@ChrisLS

The static linking of caffe object as given me a hard time. The /OPT:NOREF is just useless. The one thing that comes closest to the whole-archive option is the "Use Library Dependency Inputs" which forces a project to link the object files of another instead of the produced library.

CMake does not support this option yet (see this post: https://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=13032&graph=relation) so it's not possible to use this without modifying the VS projects by hand after CMake generation. Even then you can use this option only within the same solution so you cannot install the library and use it from a consuming project.

The workaround I found is to modify the layer ans class instantiation macros to define additional symbols that can be easily referenced to force symbol linking. So I added a post build script that parses the Caffe sources and generates a header file that when included in the consuming projects forces the linking of the objects. This is suboptimal but works. See my PR for details #2538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants