Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove python2 from matlab CMakeLists.txt #2279

Closed
wants to merge 1 commit into from
Closed

Remove python2 from matlab CMakeLists.txt #2279

wants to merge 1 commit into from

Conversation

eshelman
Copy link

@eshelman eshelman commented Apr 8, 2015

This is a proposed fix for Issue #2078

Builds with MATLAB support are complaining library not found for -lpython2 when Python support is enabled. Linking to Python is not necessary for the MATLAB build, so that library should be stripped out.

This is a proposed fix for Issue #2078

Builds with MATLAB support are complaining `library not found for -lpython2` when Python support is enabled. Linking to Python is not necessary for the MATLAB build, so that library should be stripped out.
@shelhamer
Copy link
Member

@Nerei do you know why Python is included in the MATLAB build? This looks like a fix, but please comment + / - for the merge.

Thanks @eshelman.

@ronghanghu
Copy link
Member

@eshelman @shelhamer this is not the right fix after PythonLayer is introduced. Python lib could be necessary if you want to use a net in MatCaffe that has PythonLayer, so it shouldn't be stripped. I think the correct solution to #2078 would be changing -lpython2 to specific python library such as -lpython2.7.

@Nerei
Copy link

Nerei commented May 30, 2015

@eshelman @shelhamer
Yes, agree that this looks like a fix. Python was included into link just because, for simplicity, I link all libraries that are linked to Caffe (they were accumulated in Caffe_LINKER_LIBS list). For static caffe + octave it is what is exactly required. For Matlab, only shared Caffe is supported now, so suppose linking Caffe dependencies can be omitted.

@ronghanghu For PythonLayer, is python linked to Caffe directly now? If so, than it shouldn't be a an issue, right? Or, have I missed something? I can't check this now, I am here from tablet device.

@Nerei
Copy link

Nerei commented May 30, 2015

@ronghanghu Just checked, Python was added to Caffe link list in 3d30510, when PythonLayer was introduced. It seems after that, this issue with Matlab appeared. From my view, just removing python form the list is ok.

LGTM

@ronghanghu
Copy link
Member

For static caffe + octave it is what is exactly required. For Matlab, only shared Caffe is supported now, so suppose linking Caffe dependencies can be omitted.

@Nerei Forgive me if I am wrong, but I think Dynamic linking #1842 did not cover matcaffe, and matcaffe is still using static linking against libcaffe.a instead of libcaffe.so? Why "only shared Caffe is supported now"?

@Nerei
Copy link

Nerei commented May 30, 2015

@ronghanghu By default CMake builds shared caffe (it doesn't build both). With static caffe Matlab doesn't work at all. For Matlab, I didn't find flags equivalent to -Wl,--whole-archive for gcc/octave. Such hack is required for static caffe use, otherwise linker doesn't link required caffe layers from static archive.

@ronghanghu
Copy link
Member

@Nerei I am using the Makefile and use make instead of cmake, and I believe matcaffe is still statically linked against libcaffe.a instead of libcaffe.so, at least so with the Makefile (and it works). To verify this, I deleted caffe/build/lib/libcaffe.so after building. After that, although the command line tools became broken, I can still use matcaffe without any problem.

By default CMake builds shared caffe (it doesn't build both). With static caffe Matlab doesn't work at all.

I am not very familiar with CMake and those CMakeLists.txt in Caffe. Not sure why it is.

@shelhamer shelhamer added RH and removed ES labels Aug 7, 2015
@abhijitkundu
Copy link
Contributor

The addition of -lpython2 instead of -lpython2.7 is due to wrong behaviour in the caffe_parse_linker_libs function in cmake/Utils.cmake. The pull request #3650 solves this.

However if python is indeed not required for matlab wrapper, then it should be removed.

However the fix proposed in this pull request of simply removing python from the linkerflags by string matching is very hacky.

@eshelman
Copy link
Author

eshelman commented Feb 9, 2016

Let's not hack things. I'll close this, as it's my hack ;-)

@eshelman eshelman closed this Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants